-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (46 loc) · 1.96 KB
/
CheckForNewRelease.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Check for New Release
# c.f. https://stackoverflow.com/a/77002385
on:
# schedule:
# - cron: '0 0 * * *'
workflow_dispatch:
env:
REMOTE_USER: torakiki
REMOTE_REPO: pdfsam
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Get latest remote release
id: get_remote_release
run: |
# Fetch release information and extract the release tag
REMOTE_RELEASE_TAG=$(curl -s https://api.github.com/repos/$REMOTE_USER/$REMOTE_REPO/releases/latest | jq -r '.tag_name')
echo "remote_release_tag=$REMOTE_RELEASE_TAG" >> $GITHUB_OUTPUT
echo "latest remote release: $REMOTE_RELEASE_TAG"
- name: Get latest local release
id: get_local_release
run: |
# Fetch release information and extract the release tag
LOCAL_RELEASE_TAG=$(curl -s https://api.github.com/repos/$GITHUB_ACTION_REPOSITORY/releases/latest | jq -r '.tag_name')
echo "local_release_tag=$LOCAL_RELEASE_TAG" >> $GITHUB_OUTPUT
echo "latest local release: $LOCAL_RELEASE_TAG"
- name: Compare releases
id: compare_releases
run: |
# Read the release info from the downloaded artifact
PREVIOUS_RELEASE=$(cat xyz-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_remote_release.outputs.REMOTE_RELEASE_TAG }}" != "${{ steps.get_local_release.outputs.LOCAL_RELEASE_TAG }}" ]; then
echo "release_changed=true" >> $GITHUB_OUTPUT
echo "Release changed: true"
else
echo "release_changed=false" >> $GITHUB_OUTPUT
echo "Release changed: false"
fi
# - name: Call workflow to build code
# if: steps.compare_release.outputs.release_changed == 'true'
# uses: benc-uk/workflow-dispatch@v1
# with:
# workflow: publish.yml