Fetch latest version #62
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: Fetch latest version | |
on: | |
schedule: | |
- cron: 0 0 * * 5 | |
workflow_dispatch: | |
jobs: | |
auto-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup repository | |
uses: actions/checkout@v4 | |
with: | |
ref: develop | |
fetch-depth: 0 | |
- name: Get release version | |
id: get-version | |
run: | | |
git pull origin master | |
simple_icons_version="$(curl --retry 5 -s https://api.github.com/repos/simple-icons/simple-icons-font/releases/latest | jq -r .tag_name)" | |
echo "::set-output name=si::$simple_icons_version" | |
echo "::set-output name=lib::$(cat package.json | grep '"version":' | cut -d'"' -f4)" | |
- name: Cancel if not new version | |
uses: actions/github-script@v6 | |
if: ${{ steps.get-version.outputs.lib == steps.get-version.outputs.si }} | |
with: | |
script: | | |
github.rest.actions.cancelWorkflowRun({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.runId, | |
}) | |
- name: Bump version and commit | |
run: | | |
echo "`jq '.version="${{ steps.get-version.outputs.si }}"' package.json`" > package.json | |
echo "`jq '.dependencies."simple-icons-font"="${{ steps.get-version.outputs.si }}"' package.json`" > package.json | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git commit -m "version bump" | |
git push origin develop | |
git switch master | |
git pull origin develop | |
git tag -a "${{ steps.get-version.outputs.si }}" -m "" | |
git push --follow-tags origin master |