summaryrefslogtreecommitdiff
path: root/.github/workflows/hamlib-upstream-check.yml
blob: 121babd15435213e4c024b4b947d7c94c253961d (plain)
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
106
107
108
109
110
111
112
113
114
name: Hamlib Upstream Check

on:
  schedule:
    # Weekly, Monday 12:00 UTC. Courtesy check for new Hamlib 4.x releases.
    - cron: '0 12 * * MON'
  workflow_dispatch:

permissions:
  contents: read
  issues: write

jobs:
  check:
    # Mirrored to the public repo at GA; upstream watch runs internal-only.
    if: github.repository == 'WSJTX/wsjtx-internal'
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false

      - name: Check for newer upstream release
        env:
          GH_TOKEN: ${{ github.token }}
          # Extension hook: to add Qt, Boost, fftw, or any other upstream,
          # duplicate this workflow with different COMPONENT / REPO / MAJOR
          # values, or convert this job into a matrix over those keys.
          # The step logic below only reads these three env vars plus the
          # hamlib_branch line in ci.yml, so swapping is mechanical.
          COMPONENT: Hamlib
          REPO: Hamlib/Hamlib
          MAJOR: "4"
        run: |
          set -euo pipefail

          # Single source of truth for the pinned version lives in ci.yml.
          # ci.yml and release.yml must agree on hamlib_branch; CI failure
          # is the signal if they drift, so this step reads ci.yml only.
          PINNED=$(grep -m1 'hamlib_branch:' .github/workflows/ci.yml \
            | sed -E 's/.*"([^"]+)".*/\1/')
          if [[ -z "$PINNED" ]]; then
            echo "::error::Could not read pinned ${COMPONENT} version from ci.yml"
            exit 1
          fi
          echo "Pinned:   ${PINNED}"

          # Highest tag in the MAJOR.x series. Strict three-component filter
          # skips partial tags like "4.6" and anything non-semver. sort -V
          # handles numeric ordering correctly for dotted versions.
          LATEST=$(gh api "/repos/${REPO}/tags" --paginate -q '.[].name' \
            | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
            | awk -F. -v m="${MAJOR}" '$1 == m' \
            | sort -V \
            | tail -n1)
          if [[ -z "${LATEST}" ]]; then
            echo "::error::No ${COMPONENT} ${MAJOR}.x tags found upstream"
            exit 1
          fi
          echo "Upstream: ${LATEST}"

          if [[ "${LATEST}" == "${PINNED}" ]]; then
            echo "Pinned version is current. Nothing to do."
            exit 0
          fi

          HIGHEST=$(printf '%s\n%s\n' "${PINNED}" "${LATEST}" | sort -V | tail -n1)
          if [[ "${HIGHEST}" != "${LATEST}" ]]; then
            echo "Pinned (${PINNED}) is ahead of upstream (${LATEST}); no action."
            exit 0
          fi

          # Avoid filing a duplicate if last week's tracking issue is still
          # open. "in:title" + the specific version number is tight enough
          # to never collide with an unrelated issue.
          if gh issue list --state open \
               --search "${COMPONENT} ${LATEST} in:title" \
               --json number -q '.[].number' | grep -q .; then
            echo "Tracking issue already open for ${COMPONENT} ${LATEST}. Nothing to do."
            exit 0
          fi

          TITLE="Upstream: ${COMPONENT} ${LATEST} available (pinned at ${PINNED})"
          BODY=$(cat <<EOF
          Automated upstream version check.

          - **Component:** ${COMPONENT}
          - **Pinned:** \`${PINNED}\`
          - **Latest upstream ${MAJOR}.x tag:** \`${LATEST}\`

          ## To bump

          Update \`hamlib_branch\` in:

          - \`.github/workflows/ci.yml\` (six target jobs)
          - \`.github/workflows/release.yml\` (six target jobs)
          - \`.github/scripts/linux-ci-image-config.sh\`
          - \`.github/scripts/tsan-linux-deps-config.sh\`

          Update both exact commits, publish and validate a candidate Linux
          image generation, update the remaining platform pins, then let CI run
          on all six targets.

          ## Notes

          - This check only tracks the ${MAJOR}.x series. A future ${COMPONENT} ${MAJOR}+1 major release would require design review and is intentionally ignored here.
          - Close this issue once the bump PR is merged. The next weekly run will re-file if another ${MAJOR}.x release appears.

          _Filed by \`.github/workflows/hamlib-upstream-check.yml\`._
          EOF
          )

          gh issue create --title "${TITLE}" --body "${BODY}"