|
5 | 5 | - cron: '0 6 * * *' # Daily at 6 AM UTC |
6 | 6 | workflow_dispatch: |
7 | 7 |
|
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + actions: write |
| 11 | + |
8 | 12 | jobs: |
9 | 13 | check: |
10 | 14 | runs-on: ubuntu-latest |
11 | 15 | steps: |
12 | | - - name: Get latest ESP-Hosted version |
13 | | - id: latest |
14 | | - run: | |
15 | | - VERSION=$(curl -s "https://components.espressif.com/api/components/espressif/esp_hosted" | jq -r '.versions[0].version') |
16 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
17 | | - echo "Latest ESP-Hosted version: $VERSION" |
18 | | -
|
19 | | - - name: Get latest release version |
20 | | - id: current |
| 16 | + - name: Determine versions to build |
| 17 | + id: todo |
21 | 18 | env: |
22 | 19 | GH_TOKEN: ${{ github.token }} |
23 | 20 | run: | |
24 | | - VERSION=$(gh release view --repo ${{ github.repository }} --json tagName -q '.tagName' 2>/dev/null | sed 's/^v//' || echo "none") |
25 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
26 | | - echo "Current release version: $VERSION" |
| 21 | + # Stable versions from the ESP component registry (exclude any semver |
| 22 | + # pre-release, i.e. anything with a '-' identifier like 3.0.0-rc1). |
| 23 | + AVAILABLE=$(curl -s "https://components.espressif.com/api/components/espressif/esp_hosted" \ |
| 24 | + | jq -r '.versions[].version | select(contains("-") | not)' \ |
| 25 | + | sort -Vu) |
| 26 | +
|
| 27 | + # Versions already released (strip leading v, skip manifest tag) |
| 28 | + RELEASED=$(gh release list --repo "${{ github.repository }}" --limit 200 \ |
| 29 | + --json tagName -q '.[].tagName' \ |
| 30 | + | grep -v '^manifest$' \ |
| 31 | + | sed 's/^v//' \ |
| 32 | + | sort -V) |
| 33 | +
|
| 34 | + # Highest version we've already released. If there are no releases, |
| 35 | + # bail out — this workflow only builds forward, not historical gaps. |
| 36 | + HIGHEST=$(echo "$RELEASED" | sort -V | tail -n1) |
| 37 | + if [ -z "$HIGHEST" ]; then |
| 38 | + echo "No existing releases; nothing to do (bootstrap a release manually)." |
| 39 | + MISSING="" |
| 40 | + else |
| 41 | + # Missing = stable versions strictly newer than HIGHEST |
| 42 | + MISSING=$(echo "$AVAILABLE" | awk -v h="$HIGHEST" ' |
| 43 | + function ver_gt(a, b, as, bs, i, an, bn) { |
| 44 | + n = split(a, as, "."); split(b, bs, ".") |
| 45 | + for (i = 1; i <= n; i++) { |
| 46 | + an = as[i] + 0; bn = bs[i] + 0 |
| 47 | + if (an > bn) return 1 |
| 48 | + if (an < bn) return 0 |
| 49 | + } |
| 50 | + return 0 |
| 51 | + } |
| 52 | + ver_gt($0, h)') |
| 53 | + fi |
| 54 | +
|
| 55 | + # Count non-empty lines |
| 56 | + COUNT=$(printf '%s\n' "$MISSING" | grep -cve '^$' || true) |
| 57 | +
|
| 58 | + echo "Available stable versions:" |
| 59 | + echo "$AVAILABLE" |
| 60 | + echo "Already released:" |
| 61 | + echo "$RELEASED" |
| 62 | + echo "Missing versions to build ($COUNT):" |
| 63 | + echo "$MISSING" |
| 64 | +
|
| 65 | + { |
| 66 | + echo "count=$COUNT" |
| 67 | + echo "missing<<EOF" |
| 68 | + echo "$MISSING" |
| 69 | + echo "EOF" |
| 70 | + } >> "$GITHUB_OUTPUT" |
27 | 71 |
|
28 | | - - name: Trigger build if new version |
29 | | - if: steps.latest.outputs.version != steps.current.outputs.version |
| 72 | + - name: Dispatch build for each missing version |
| 73 | + if: steps.todo.outputs.count != '0' |
30 | 74 | env: |
31 | 75 | GH_TOKEN: ${{ github.token }} |
32 | 76 | run: | |
33 | | - echo "New version available: ${{ steps.latest.outputs.version }}" |
34 | | - gh workflow run build.yml --repo ${{ github.repository }} -f version=${{ steps.latest.outputs.version }} -f release=true |
| 77 | + while IFS= read -r V; do |
| 78 | + [ -z "$V" ] && continue |
| 79 | + echo "Dispatching build for $V" |
| 80 | + gh workflow run build.yml --repo "${{ github.repository }}" \ |
| 81 | + -f version="$V" -f release=true |
| 82 | + sleep 5 |
| 83 | + done <<< "${{ steps.todo.outputs.missing }}" |
0 commit comments