Skip to content

Check for Updates

Check for Updates #644

Workflow file for this run

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@v5
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