pub-release: tag v1.18.0+tth.<date>, dated title and asset names
pub-release / release (push) Successful in 21m58s
pub-release / release (push) Successful in 21m58s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8ec702e9b6
commit
d4afea1eb3
1 file changed
+57
-32
@@ -11,7 +11,10 @@
|
|||||||
#
|
#
|
||||||
# Runs on every push to main -- the export pushes there only after an
|
# Runs on every push to main -- the export pushes there only after an
|
||||||
# upstream merge (private repo, tth-upstream-sync) -- and by hand.
|
# upstream merge (private repo, tth-upstream-sync) -- and by hand.
|
||||||
# Release tag tth-<sha8>, titled with the stamped version (v1.18.0-tth<sha>);
|
# Release tag v1.18.0+tth.<commit date>[.n] (the n-th release of that day),
|
||||||
|
# titled "v1.18.0+tth · 12. 11. 2026"; assets carry the tag in their names, the
|
||||||
|
# body the version the node reports (`ver`: v1.18.0-tth<sha>). Until 12. 11.
|
||||||
|
# 2026 the tags were tth-<sha8>; pruning and the changelog know both;
|
||||||
# the newest KEEP releases stay, older ones are deleted. The body is a
|
# the newest KEEP releases stay, older ones are deleted. The body is a
|
||||||
# changelog since the previous release: our own commits, then the upstream
|
# changelog since the previous release: our own commits, then the upstream
|
||||||
# PRs the upstream merges brought in.
|
# PRs the upstream merges brought in.
|
||||||
@@ -83,39 +86,58 @@ jobs:
|
|||||||
|
|
||||||
- name: Commit and tag
|
- name: Commit and tag
|
||||||
id: src
|
id: src
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||||
|
REPLACE: ${{ github.event.inputs.replace }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
git fetch -q --tags
|
git fetch -q --tags
|
||||||
sha=$(git rev-parse HEAD)
|
sha=$(git rev-parse HEAD)
|
||||||
echo "sha=$sha" >>"$GITHUB_OUTPUT"
|
# upstream base as tools/build_version.py finds it: "companion-v1.18.0" -> v1.18.0
|
||||||
echo "tag=tth-${sha:0:8}" >>"$GITHUB_OUTPUT"
|
desc=$(git describe --tags --abbrev=0 --match '*v[0-9]*' --exclude '*+tth*' --exclude 'backup/*' HEAD)
|
||||||
git describe --tags --abbrev=0 --match '*v[0-9]*' HEAD
|
[[ $desc =~ v[0-9].* ]] && base=${BASH_REMATCH[0]} || base=$desc
|
||||||
|
# the COMMIT's date (Prague), so a rebuild of the same commit keeps its tag
|
||||||
- name: Release exists?
|
day=$(TZ=Europe/Prague git show -s --format=%cd --date=format-local:%Y%m%d HEAD)
|
||||||
env:
|
human=$(TZ=Europe/Prague git show -s --format=%cd --date=format-local:'%-d. %-m. %Y' HEAD)
|
||||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
|
||||||
TAG: ${{ steps.src.outputs.tag }}
|
|
||||||
REPLACE: ${{ github.event.inputs.replace }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
api="$GITEA/api/v1/repos/$GITHUB_REPOSITORY"
|
api="$GITEA/api/v1/repos/$GITHUB_REPOSITORY"
|
||||||
auth="header = \"Authorization: token $TOKEN\""
|
auth="header = \"Authorization: token $TOKEN\""
|
||||||
id=$(curl -sS --config - "$api/releases/tags/$TAG" <<<"$auth" | jq -r '.id // empty')
|
enc() { jq -rn --arg s "$1" '$s|@uri'; }
|
||||||
if [ -n "$id" ]; then
|
# v1.18.0+tth.20261112, a second release of the day .2, ...
|
||||||
if [ "$REPLACE" != "true" ]; then
|
n=1
|
||||||
echo "::error::release $TAG already exists (id $id); set replace=true to rebuild it"
|
while :; do
|
||||||
exit 1
|
tag="$base+tth.$day"
|
||||||
|
[ "$n" -eq 1 ] || tag="$tag.$n"
|
||||||
|
rel=$(curl -sS --config - "$api/releases/tags/$(enc "$tag")" <<<"$auth")
|
||||||
|
id=$(jq -r '.id // empty' <<<"$rel")
|
||||||
|
[ -n "$id" ] || break
|
||||||
|
if [ "$(jq -r .target_commitish <<<"$rel")" = "$sha" ]; then
|
||||||
|
if [ "$REPLACE" != "true" ]; then
|
||||||
|
echo "::error::release $tag already exists (id $id); set replace=true to rebuild it"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
curl -sSf --config - -X DELETE "$api/releases/$id" <<<"$auth"
|
||||||
|
curl -sSf --config - -X DELETE "$api/tags/$(enc "$tag")" <<<"$auth" || true
|
||||||
|
echo "removed old $tag"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
curl -sSf --config - -X DELETE "$api/releases/$id" <<<"$auth"
|
n=$((n + 1))
|
||||||
curl -sSf --config - -X DELETE "$api/tags/$TAG" <<<"$auth" || true
|
done
|
||||||
echo "removed old $TAG"
|
title="$base+tth · $human"
|
||||||
fi
|
[ "$n" -eq 1 ] || title="$title ($n)"
|
||||||
|
echo "release $tag: $title (commit $sha)"
|
||||||
|
{
|
||||||
|
echo "sha=$sha"
|
||||||
|
echo "tag=$tag"
|
||||||
|
echo "title=$title"
|
||||||
|
} >>"$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Setup Build Environment
|
- name: Setup Build Environment
|
||||||
uses: ./.github/actions/setup-build-environment
|
uses: ./.github/actions/setup-build-environment
|
||||||
|
|
||||||
- name: Build and package
|
- name: Build and package
|
||||||
id: build
|
id: build
|
||||||
|
env:
|
||||||
|
TAG: ${{ steps.src.outputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
sha=$(git rev-parse --short=8 HEAD)
|
sha=$(git rev-parse --short=8 HEAD)
|
||||||
@@ -131,15 +153,15 @@ jobs:
|
|||||||
b=".pio/build/$env"
|
b=".pio/build/$env"
|
||||||
if [ -f "$b/firmware.zip" ]; then # nRF52
|
if [ -f "$b/firmware.zip" ]; then # nRF52
|
||||||
python3 bin/uf2conv/uf2conv.py "$b/firmware.hex" -c -o "$b/firmware.uf2" -f 0xADA52840
|
python3 bin/uf2conv/uf2conv.py "$b/firmware.hex" -c -o "$b/firmware.uf2" -f 0xADA52840
|
||||||
cp "$b/firmware.uf2" "$dist/$env$suffix-$sha.uf2"
|
cp "$b/firmware.uf2" "$dist/$env$suffix-$TAG.uf2"
|
||||||
cp "$b/firmware.zip" "$dist/$env$suffix-$sha.zip"
|
cp "$b/firmware.zip" "$dist/$env$suffix-$TAG.zip"
|
||||||
v=$(grep -m1 -aoE 'v[0-9]+\.[0-9]+\.[0-9]+-tth[0-9a-f]+\+?' "$b/firmware.elf" || true)
|
v=$(grep -m1 -aoE 'v[0-9]+\.[0-9]+\.[0-9]+-tth[0-9a-f]+\+?' "$b/firmware.elf" || true)
|
||||||
case "$v" in *+) echo "::error::$env is dirty ($v)"; exit 1 ;; esac
|
case "$v" in *+) echo "::error::$env is dirty ($v)"; exit 1 ;; esac
|
||||||
[ -n "$version" ] || version="$v"
|
[ -n "$version" ] || version="$v"
|
||||||
else # ESP32
|
else # ESP32
|
||||||
PLATFORMIO_BUILD_FLAGS="$PUB_FLAGS $2" pio run -t mergebin -e "$env"
|
PLATFORMIO_BUILD_FLAGS="$PUB_FLAGS $2" pio run -t mergebin -e "$env"
|
||||||
cp "$b/firmware.bin" "$dist/$env$suffix-$sha.bin"
|
cp "$b/firmware.bin" "$dist/$env$suffix-$TAG.bin"
|
||||||
cp "$b/firmware-merged.bin" "$dist/$env$suffix-$sha-merged.bin"
|
cp "$b/firmware-merged.bin" "$dist/$env$suffix-$TAG-merged.bin"
|
||||||
fi
|
fi
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
}
|
}
|
||||||
@@ -155,6 +177,7 @@ jobs:
|
|||||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||||
SHA: ${{ steps.src.outputs.sha }}
|
SHA: ${{ steps.src.outputs.sha }}
|
||||||
TAG: ${{ steps.src.outputs.tag }}
|
TAG: ${{ steps.src.outputs.tag }}
|
||||||
|
TITLE: ${{ steps.src.outputs.title }}
|
||||||
VERSION: ${{ steps.build.outputs.version }}
|
VERSION: ${{ steps.build.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -176,7 +199,7 @@ jobs:
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done < <(curl -sSf --config - "$api/releases?limit=50" <<<"$auth" |
|
done < <(curl -sSf --config - "$api/releases?limit=50" <<<"$auth" |
|
||||||
jq -r --arg t "$TAG" 'map(select(.tag_name | startswith("tth-")) | select(.tag_name != $t))
|
jq -r --arg t "$TAG" 'map(select(.tag_name | startswith("tth-") or test("[+]tth[.]")) | select(.tag_name != $t))
|
||||||
| sort_by(.created_at) | reverse | .[] | "\(.tag_name) \(.target_commitish)"')
|
| sort_by(.created_at) | reverse | .[] | "\(.tag_name) \(.target_commitish)"')
|
||||||
# no older release: the last 20 commits of our own line
|
# no older release: the last 20 commits of our own line
|
||||||
[ -n "$base" ] || base=$(git rev-list --first-parent --max-count=21 "$SHA" | tail -1)
|
[ -n "$base" ] || base=$(git rev-list --first-parent --max-count=21 "$SHA" | tail -1)
|
||||||
@@ -205,10 +228,12 @@ jobs:
|
|||||||
done
|
done
|
||||||
n=${#ups[@]}
|
n=${#ups[@]}
|
||||||
body=$(
|
body=$(
|
||||||
echo "$VERSION"
|
echo "$TITLE"
|
||||||
|
echo
|
||||||
|
echo "Verze v uzlu · \`ver\`: $VERSION"
|
||||||
echo
|
echo
|
||||||
if [ -n "$prev" ]; then
|
if [ -n "$prev" ]; then
|
||||||
echo "Od předchozího vydání · since [$prev]($web/releases/tag/$prev)"
|
echo "Od předchozího vydání · since [$prev]($web/releases/tag/$(jq -rn --arg s "$prev" '$s|@uri'))"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
echo "### Změny forku · fork changes"
|
echo "### Změny forku · fork changes"
|
||||||
@@ -224,22 +249,22 @@ jobs:
|
|||||||
echo
|
echo
|
||||||
echo "commit $SHA, run $GITHUB_RUN_NUMBER"
|
echo "commit $SHA, run $GITHUB_RUN_NUMBER"
|
||||||
)
|
)
|
||||||
jq -n --arg t "$TAG" --arg c "$SHA" --arg n "$VERSION" --arg b "$body" \
|
jq -n --arg t "$TAG" --arg c "$SHA" --arg n "$TITLE" --arg b "$body" \
|
||||||
'{tag_name: $t, target_commitish: $c, name: $n, body: $b}' >"$RUNNER_TEMP/rel.json"
|
'{tag_name: $t, target_commitish: $c, name: $n, body: $b}' >"$RUNNER_TEMP/rel.json"
|
||||||
id=$(curl -sSf --config - -X POST -H 'Content-Type: application/json' \
|
id=$(curl -sSf --config - -X POST -H 'Content-Type: application/json' \
|
||||||
--data-binary "@$RUNNER_TEMP/rel.json" "$api/releases" <<<"$auth" | jq -r .id)
|
--data-binary "@$RUNNER_TEMP/rel.json" "$api/releases" <<<"$auth" | jq -r .id)
|
||||||
for f in dist/*; do
|
for f in dist/*; do
|
||||||
curl -sSf --config - -X POST -F "attachment=@$f" \
|
curl -sSf --config - -X POST -F "attachment=@$f" \
|
||||||
"$api/releases/$id/assets?name=$(basename "$f")" <<<"$auth" >/dev/null
|
"$api/releases/$id/assets?name=$(jq -rn --arg s "${f##*/}" '$s|@uri')" <<<"$auth" >/dev/null
|
||||||
echo "uploaded $(basename "$f")"
|
echo "uploaded $(basename "$f")"
|
||||||
done
|
done
|
||||||
echo "released $TAG = $VERSION (id $id)"
|
echo "released $TAG = $VERSION (id $id)"
|
||||||
# keep the newest $KEEP, oldest go (with their tags)
|
# keep the newest $KEEP, oldest go (with their tags)
|
||||||
curl -sSf --config - "$api/releases?limit=50" <<<"$auth" |
|
curl -sSf --config - "$api/releases?limit=50" <<<"$auth" |
|
||||||
jq -r --argjson k "$KEEP" 'map(select(.tag_name | startswith("tth-")))
|
jq -r --argjson k "$KEEP" 'map(select(.tag_name | startswith("tth-") or test("[+]tth[.]")))
|
||||||
| sort_by(.created_at) | reverse | .[$k:][] | "\(.id) \(.tag_name)"' |
|
| sort_by(.created_at) | reverse | .[$k:][] | "\(.id) \(.tag_name)"' |
|
||||||
while read -r old_id old_tag; do
|
while read -r old_id old_tag; do
|
||||||
curl -sSf --config - -X DELETE "$api/releases/$old_id" <<<"$auth"
|
curl -sSf --config - -X DELETE "$api/releases/$old_id" <<<"$auth"
|
||||||
curl -sSf --config - -X DELETE "$api/tags/$old_tag" <<<"$auth" || true
|
curl -sSf --config - -X DELETE "$api/tags/$(jq -rn --arg s "$old_tag" '$s|@uri')" <<<"$auth" || true
|
||||||
echo "pruned $old_tag"
|
echo "pruned $old_tag"
|
||||||
done
|
done
|
||||||
Reference in new issue
Block a user