Automated Releases #248
This file contains hidden or 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: Automated Releases | |
| on: | |
| # This Workflow is triggered through the GitHub API: | |
| # curl -X Post \ | |
| # -H "Authorization: Bearer <token>" \ | |
| # -d '{"ref":"develop"}' \ | |
| # https://api.github.com/repos/simple-icons/simple-icons-font/actions/workflows/auto-release.yml/dispatches | |
| # Replacing <token> by a personal access token with scope `public_repo` | |
| workflow_dispatch: | |
| # It is also triggered on a schedule, every Tuesday, Thursday, and Saturday at midnight UTC. | |
| # This is to ensure that the fonts are released regularly, if, for some reason, the | |
| # previous workflow dispatch failed to trigger a release. | |
| schedule: | |
| - cron: 0 0 * * 2,4,6 | |
| jobs: | |
| check-is-fork: | |
| name: Check if running in a fork | |
| runs-on: ubuntu-latest | |
| outputs: | |
| is-fork: ${{ steps.check.outputs.is-fork }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/check-is-fork | |
| id: check | |
| with: | |
| in-fork-message: 'Auto release only can be executed in the main repository, skipping.' | |
| get-releases: | |
| name: Get release versions | |
| runs-on: ubuntu-latest | |
| needs: check-is-fork | |
| if: needs.check-is-fork.outputs.is-fork != 'true' | |
| outputs: | |
| si: ${{ steps.get-releases.outputs.si }} | |
| lib: ${{ steps.get-releases.outputs.lib }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: develop | |
| - name: Compare release versions | |
| id: get-releases | |
| run: | | |
| simple_icons_version="$(curl --retry 15 -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 | |
| auto-release: | |
| name: Automated release | |
| runs-on: ubuntu-latest | |
| needs: get-releases | |
| if: needs.get-releases.outputs.si != needs.get-releases.outputs.lib | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.BOT_APP_ID }} | |
| private-key: ${{ secrets.BOT_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| # Ensure we are checked out on the develop branch | |
| ref: develop | |
| # Fetch everything so we can checkout master | |
| fetch-depth: 0 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.x | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Update README CDN URLs | |
| # Update CDN URLs in README | |
| run: node scripts/update-cdn-urls.js | |
| - name: Update simple-icons dependency and package version | |
| id: update | |
| run: | | |
| new_version="$(node scripts/bump-version.js)" | |
| echo "new-version=$new_version" >> $GITHUB_OUTPUT | |
| - name: Sanity check | |
| run: npm run build | |
| - name: Configure GIT credentials | |
| run: | | |
| git config user.name "simple-icons[bot]" | |
| git config user.email "simple-icons[bot]@users.noreply.github.com" | |
| - name: Commit updates | |
| run: | | |
| git add . | |
| git commit -m "Bump version" | |
| - name: Merge develop into master | |
| run: | | |
| git checkout master | |
| git merge develop --no-ff -m "Release ${{ steps.update.outputs.new-version }}" | |
| - name: Push version bump | |
| run: | | |
| # Set up remote using a Personal Access Token | |
| git remote remove origin | |
| git remote add origin https://${{ secrets.RELEASE_TOKEN }}@github.com/simple-icons/simple-icons-font.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 |