Skip to content

create tag if there's a new Sarasa Gothic version #11339

create tag if there's a new Sarasa Gothic version

create tag if there's a new Sarasa Gothic version #11339

name: create tag if there's a new Sarasa Gothic version
on:
# runs every 3 hours
schedule:
- cron: '0 */3 * * *'
# allow manually trigger
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-22.04
outputs:
should-update: ${{ steps.check.outputs.should-update }}
latest-tag-with-revision: ${{ steps.check.outputs.latest-tag-with-revision }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: check
id: check
run: |
# get the latest tag
LATEST_TAG=$(curl --silent https://api.github.com/repos/be5invis/Sarasa-Gothic/releases/latest | jq -r .tag_name)
if [[ "${LATEST_TAG}" == "null" ]]; then
echo cannot get latest tag of be5invis/Sarasa-Gothic, skipping...
exit 1
fi
echo latest tag of be5invis/Sarasa-Gothic is ${LATEST_TAG}
# set initial revision as 0
LATEST_TAG_WITH_REVISION="${LATEST_TAG}-0"
# check if we already have a matching tag
if git rev-parse ${LATEST_TAG_WITH_REVISION} >/dev/null 2>&1; then
echo "${LATEST_TAG_WITH_REVISION}" tag exists, do nothing.
echo "should-update=false" >> $GITHUB_OUTPUT
exit 0
fi
echo a newer version is available
echo "should-update=true" >> $GITHUB_OUTPUT
echo "latest-tag-with-revision=${LATEST_TAG_WITH_REVISION}" >> $GITHUB_OUTPUT
tag:
needs: check
if: ${{ needs.check.outputs.should-update == 'true' }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.WORKFLOW_PERSONAL_ACCESS_TOKEN }}
- name: create tag ${{ needs.check.outputs.latest-tag-with-revision }}
run: |
LATEST_TAG_WITH_REVISION="${{ needs.check.outputs.latest-tag-with-revision }}"
echo ${LATEST_TAG_WITH_REVISION} tag does not exist, tag it to trigger next action.
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git tag -a ${LATEST_TAG_WITH_REVISION} -m "πŸŽ‰ build: release version ${LATEST_TAG_WITH_REVISION}"
git push origin --tags