Release #789
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
schedule: | |
- cron: 0 0 * * 1,2,3,4,5 | |
workflow_dispatch: | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Ensure we are checked out on the develop branch | |
ref: develop | |
# Ensure custom credentials are used when pushing | |
persist-credentials: false | |
# Fetch everything so we can checkout master | |
fetch-depth: 0 | |
- name: Use NodeJS v20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Compare release versions | |
id: get-releases | |
run: | | |
simple_icons_version="$(curl --retry 5 -s https://api.github.com/repos/simple-icons/simple-icons/releases/latest | jq -r .tag_name)" | |
echo "si=$simple_icons_version" >> $GITHUB_OUTPUT | |
echo "lib=$(cat package.json | grep '"version":' | cut -d'"' -f4)" >> $GITHUB_OUTPUT | |
- name: Bump version | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: | | |
# Update versions in package.json | |
sed -i \ | |
's/"version": "${{ steps.get-releases.outputs.lib }}",/"version": "${{ steps.get-releases.outputs.si }}",/' \ | |
package.json | |
sed -i \ | |
's/"simple-icons": "${{ steps.get-releases.outputs.lib }}"/"simple-icons": "${{ steps.get-releases.outputs.si }}"/' \ | |
package.json | |
# Update version in README | |
sed -i \ | |
's/${{ steps.get-releases.outputs.lib }}/${{ steps.get-releases.outputs.si }}/g' \ | |
README.md | |
# Update version in addon | |
v_major="$(echo ${{ steps.get-releases.outputs.si }} | cut -d'.' -f1)" | |
v_minor="$(echo ${{ steps.get-releases.outputs.si }} | cut -d'.' -f2)" | |
v_patch="$(echo ${{ steps.get-releases.outputs.si }} | cut -d'.' -f3)" | |
sed -i -E \ | |
"s/(\"|')version(\"|'): [(][0-9]+, [0-9]+, [0-9]+[)],/\1version\2: ($v_major, $v_minor, $v_patch),/" \ | |
simple_icons_blender.template | |
- name: Blender cache setup | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
uses: actions/cache@v4 | |
id: cache-blender | |
with: | |
path: | | |
blender-* | |
_blender-executable-path.txt | |
key: ${{ runner.os }}-2.93.9 | |
- name: Download Blender 2.93.9 | |
if: (steps.cache-blender.outputs.cache-hit != 'true' && steps.get-releases.outputs.lib != steps.get-releases.outputs.si) | |
id: download-blender | |
run: | | |
python -m pip install --upgrade blender-downloader | |
echo "$(blender-downloader 2.93.9 --extract --remove-compressed \ | |
--quiet --print-blender-executable)" > _blender-executable-path.txt | |
- name: Install dependencies | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
id: install-dependencies | |
run: | | |
npm install | |
python -m pip install --upgrade pip | |
python -m pip install -r test-requirements.txt | |
blender_executable="$(< _blender-executable-path.txt tr -d '\n')" | |
python_blender_executable="$(pytest-blender --blender-executable $blender_executable)" | |
$python_blender_executable -m ensurepip | |
$python_blender_executable -m pip install pytest | |
echo "blender-executable=$blender_executable" >> $GITHUB_OUTPUT | |
- name: Build library | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: npm run build | |
- name: Test with pytest | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: pytest -s --blender-executable "${{ steps.install-dependencies.outputs.blender-executable }}" tests | |
- name: Commit | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: | | |
set -e | |
# Set up git credential | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
# Create a version bump commit | |
git add package.json simple_icons_blender.py simple_icons_blender.template README.md | |
git commit -m "Version bump" | |
# Merge develop into master | |
git checkout master | |
git merge develop -m "Release ${{ steps.get-releases.outputs.si }}" | |
# Set up remote using a Personal Access Token | |
git remote remove origin | |
git remote add origin https://${{secrets.RELEASE_TOKEN}}@github.com/mondeja/simple-icons-blender.git | |
# Push develop first, to prevent conflicts with parallel activity | |
git push origin develop | |
# Push master only after develop was safely pushed | |
git push origin master | |
- name: Create and push git tag | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
run: | | |
set -e | |
tag="${{ steps.get-releases.outputs.si }}" | |
git tag -a "${tag}" -m "" | |
git push origin "${tag}" | |
- name: Create GitHub release | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
id: create-release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
name: Release ${{ steps.get-releases.outputs.si }} | |
tag_name: ${{ steps.get-releases.outputs.si }} | |
body: | | |
See https://github.com/simple-icons/simple-icons/releases/tag/${{ steps.get-releases.outputs.si }} | |
- uses: shogo82148/actions-upload-release-asset@v1 | |
name: Upload release asset | |
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: simple_icons_blender.py |