-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (93 loc) · 4.08 KB
/
version-check.yml
File metadata and controls
105 lines (93 loc) · 4.08 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Check for Updates
on:
#schedule:
# - cron: "28 */6 * * *"
workflow_dispatch:
env:
VERSION_CHECK_URL: https://www.clearskyinstitute.com/ham/HamClock/version.pl
jobs:
version-check:
name: Compare Local and Remote Versions
runs-on: ubuntu-latest
permissions: write-all
outputs:
update_required: ${{ steps.compare_versions.outputs.update_required }}
current_version: ${{ steps.get_release_version.outputs.current_version }}
remote_version: ${{ steps.get_remote_version.outputs.remote_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-tags: true
fetch-depth: 0
- name: Get current version
id: get_current_version
run: |
set -e
echo "Getting version from git repo"
CURRENT_VERSION=$(git describe --tags --abbrev=0)
echo "Current version: $CURRENT_VERSION" >> $GITHUB_STEP_SUMMARY
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Get remote version
id: get_remote_version
run: |
set -e
echo "Getting version from $VERSION_CHECK_URL"
REMOTE_VERSION=$(curl -s $VERSION_CHECK_URL | head -n 1)
echo "Remote version: $REMOTE_VERSION" >> $GITHUB_STEP_SUMMARY
echo "remote_version=$REMOTE_VERSION" >> $GITHUB_OUTPUT
- name: Compare versions
id: compare_versions
env:
CURRENT_VERSION: ${{ steps.get_current_version.outputs.current_version }}
REMOTE_VERSION: ${{ steps.get_remote_version.outputs.remote_version }}
run: |
set -e
echo "Current version: $CURRENT_VERSION" >> $GITHUB_STEP_SUMMARY
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
if [ "$(printf '%s\n' "$CURRENT_VERSION" "$REMOTE_VERSION" | sort -V | tail -n 1)" == "$CURRENT_VERSION" ]; then
echo "Current version $CURRENT_VERSION is greater than or equal to Remote version $REMOTE_VERSION."
echo "No update required." >> $GITHUB_STEP_SUMMARY
echo "update_required=false" >> $GITHUB_OUTPUT
else
echo "Remote version $REMOTE_VERSION is newer than Current version $CURRENT_VERSION."
echo "Creating release... :rocket:" >> $GITHUB_STEP_SUMMARY
echo "update_required=true" >> $GITHUB_OUTPUT
fi
- name: Clear Cached HamClock
if: ${{ steps.compare_versions.outputs.update_required }}
continue-on-error: true
run: gh cache delete hamclock
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
- name: Cache HamClock
id: cache-hamclock
if: ${{ steps.compare_versions.outputs.update_required }}
uses: actions/cache@v4
with:
path: ESPHamClock.zip
key: hamclock
- name: Download HamClock
if: ${{ ! steps.cache-hamclock.outputs.cache-hit && steps.compare_versions.outputs.update_required }}
run: curl -o ESPHamClock.zip https://www.clearskyinstitute.com/ham/HamClock/ESPHamClock.zip
- name: Download HamClock
if: ${{ ! steps.cache-hamclock.outputs.cache-hit && steps.compare_versions.outputs.update_required }}
run: |
curl -o upstream-release-notes.txt $VERSION_CHECK_URL
echo "Release notes from [HamClock](https://www.clearskyinstitute.com/ham/HamClock/)." > release-notes.md
echo '```'>> release-notes.md
cat upstream-release-notes.txt >> release-notes.md
echo '```'>> release-notes.md
- name: Create Release
if: ${{ steps.compare_versions.outputs.update_required }}
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
NEW_VERSION: ${{ steps.get_remote_version.outputs.remote_version }}
with:
tag_name: v${{ steps.get_remote_version.outputs.remote_version }}
body_path: ./release-notes.md
generate_release_notes: true
append_body: true
make_latest: true