Check for Updates #2777
This file contains hidden or 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 Updates | |
| on: | |
| schedule: | |
| - cron: "37 */6 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| version-check: | |
| name: Compare Local and Remote Versions | |
| runs-on: ubuntu-latest | |
| 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 | |
| - name: Get remote version | |
| id: get_remote_version | |
| env: | |
| VERSION_CHECK_URL: ${{ vars.VERSION_CHECK_URL }} | |
| run: | | |
| set -e | |
| echo "Getting version from $VERSION_CHECK_URL" | |
| REMOTE_VERSION=$(./scripts/retry_clearskyinstitute.sh get_version "$VERSION_CHECK_URL") | |
| echo "Remote version: $REMOTE_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "remote_version=$REMOTE_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Get current release version | |
| id: get_release_version | |
| env: | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| URL="https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" | |
| echo "Getting version from $URL" | |
| CURRENT_VERSION=$(curl -s -m 10 -H "Authorization: token $GITHUB_TOKEN" "$URL" | jq -r '.tag_name' | sed 's/^v//') | |
| echo "Current version: $CURRENT_VERSION" >> $GITHUB_STEP_SUMMARY | |
| echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Compare versions | |
| id: compare_versions | |
| env: | |
| CURRENT_VERSION : ${{ steps.get_release_version.outputs.current_version }} | |
| REMOTE_VERSION : ${{ steps.get_remote_version.outputs.remote_version }} | |
| run: | | |
| set -e | |
| if [ "$(printf '%s\n' "$CURRENT_VERSION" "$REMOTE_VERSION" | sort -V --reverse | head -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 | |
| new-release: | |
| name: Create New Release | |
| runs-on: ubuntu-latest | |
| needs: version-check | |
| if: ${{ needs.version-check.outputs.update_required == 'true' }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Check IP | |
| run: curl https://icanhazip.com && curl https://ipv4.icanhazip.com | |
| - name: Get Release Notes | |
| env: | |
| VERSION_CHECK_URL: ${{ vars.VERSION_CHECK_URL }} | |
| run: | | |
| set -e | |
| chmod +x ./scripts/retry_clearskyinstitute.sh | |
| echo "Getting release notes from $VERSION_CHECK_URL" | |
| ./scripts/retry_clearskyinstitute.sh get_content "$VERSION_CHECK_URL" ./release_notes.txt | |
| - name: Download HamClock | |
| run: | | |
| set -e | |
| ./scripts/retry_clearskyinstitute.sh download "https://www.clearskyinstitute.com/ham/HamClock/ESPHamClock.zip" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} | |
| NEW_VERSION: ${{ needs.version-check.outputs.remote_version }} | |
| with: | |
| tag_name: v${{ needs.version-check.outputs.remote_version }} | |
| body_path: ./release_notes.txt | |
| generate_release_notes: true | |
| append_body: true | |
| make_latest: true | |
| files: ./ESPHamClock.zip |