Skip to content

Commit 2cfd715

Browse files
authored
Build all missing stable versions and filter pre-releases (#12)
1 parent 936fe22 commit 2cfd715

2 files changed

Lines changed: 74 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ jobs:
6868
if: startsWith(github.ref, 'refs/tags/v') || inputs.release
6969
permissions:
7070
contents: write
71+
concurrency:
72+
group: release-publish
73+
cancel-in-progress: false
7174

7275
steps:
7376
- name: Download all artifacts
@@ -88,6 +91,9 @@ jobs:
8891
runs-on: ubuntu-latest
8992
permissions:
9093
contents: write
94+
concurrency:
95+
group: release-publish-${{ matrix.target }}
96+
cancel-in-progress: false
9197
strategy:
9298
matrix:
9399
target:
@@ -162,6 +168,9 @@ jobs:
162168
contents: read
163169
pages: write
164170
id-token: write
171+
concurrency:
172+
group: pages-deploy
173+
cancel-in-progress: false
165174
environment:
166175
name: github-pages
167176
url: ${{ steps.deployment.outputs.page_url }}

.github/workflows/check-update.yml

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,79 @@ on:
55
- cron: '0 6 * * *' # Daily at 6 AM UTC
66
workflow_dispatch:
77

8+
permissions:
9+
contents: read
10+
actions: write
11+
812
jobs:
913
check:
1014
runs-on: ubuntu-latest
1115
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
2118
env:
2219
GH_TOKEN: ${{ github.token }}
2320
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"
2771
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'
3074
env:
3175
GH_TOKEN: ${{ github.token }}
3276
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

Comments
 (0)