Check for new release of upscayl #5421
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: Check for new release of upscayl | |
on: | |
schedule: | |
- cron: '3 * * * *' | |
workflow_dispatch: | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download previous release info | |
id: download-artifact | |
uses: dawidd6/action-download-artifact@v2 # It's not possible to use actions/upload-artifact as of the time of writing | |
with: | |
name: upscayl-release-info | |
workflow_conclusion: success | |
workflow: build-and-publish.yml | |
if_no_artifact_found: warn | |
- name: Get latest release | |
id: get_release | |
run: | | |
# Fetch release information and extract the release tag | |
RELEASE_TAG=$(curl -s https://api.github.com/repos/upscayl/upscayl/releases/latest | jq -r '.tag_name') | |
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT | |
echo "latest release: $RELEASE_TAG" | |
- name: Compare with previous release | |
id: compare_release | |
run: | | |
# Read the release info from the downloaded artifact | |
PREVIOUS_RELEASE=$(cat upscayl-release-info 2> /dev/null || echo "NONE") | |
echo "previous release: $PREVIOUS_RELEASE" | |
# Compare the fetched release tag with the previous release tag | |
if [ "${{ steps.get_release.outputs.RELEASE_TAG }}" != "$PREVIOUS_RELEASE" ]; then | |
echo "release_changed=true" >> $GITHUB_OUTPUT | |
echo "Release changed: true" | |
else | |
echo "release_changed=false" >> $GITHUB_OUTPUT | |
echo "Release changed: false" | |
fi | |
if [ "$PREVIOUS_RELEASE" == "NONE" ]; then | |
echo "release_changed=false" >> $GITHUB_OUTPUT | |
echo "Not running build workflow because there is no previous release!" | |
fi | |
if [ "${{ steps.get_release.outputs.RELEASE_TAG }}" == "null" ]; then | |
echo "release_changed=false" >> $GITHUB_OUTPUT | |
echo "Not running build workflow because getting current release failed!" | |
fi | |
- name: Call workflow to build code | |
if: steps.compare_release.outputs.release_changed == 'true' | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: build-and-publish.yml |