pub-release: public firmware builds for the published fork
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d652164151
commit
7508a94415
1 file changed
+135
@@ -0,0 +1,135 @@
|
||||
# Public firmware builds of this fork -- runs only in the published repo
|
||||
# (git.rfa.cz tth-pub/meshcore-tth), skipped anywhere else.
|
||||
#
|
||||
# Generic envs only: upstream's placeholder BLE PIN (123456) and admin
|
||||
# password ("password") -- change both on the node after flashing. Nothing
|
||||
# here carries a site's identity or real secrets.
|
||||
#
|
||||
# Release tag tth-<sha8>, titled with the stamped version (v1.18.0-tth<sha>).
|
||||
# nRF52: .uf2 (drag onto the bootloader drive) and .zip (DFU over BLE or
|
||||
# serial); ESP32: -merged.bin (fresh install at 0x0) and .bin (update).
|
||||
name: pub-release
|
||||
|
||||
"on":
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: "commit to build (sha or ref)"
|
||||
required: false
|
||||
default: "main"
|
||||
replace:
|
||||
description: "replace an existing release of this commit"
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
concurrency:
|
||||
group: pub-release
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
GITEA: https://git.rfa.cz
|
||||
ENVS: >-
|
||||
Xiao_nrf52_repeater Xiao_nrf52_companion_radio_ble Xiao_nrf52_room_server Xiao_nrf52_sensor
|
||||
SenseCap_Solar_repeater SenseCap_Solar_companion_radio_ble
|
||||
RAK_4631_repeater RAK_4631_companion_radio_ble RAK_4631_room_server
|
||||
t1000e_repeater t1000e_companion_radio_ble
|
||||
Heltec_t114_repeater Heltec_t114_companion_radio_ble
|
||||
Heltec_v3_repeater Heltec_v3_companion_radio_ble
|
||||
|
||||
jobs:
|
||||
release:
|
||||
if: github.repository == 'tth-pub/meshcore-tth'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.inputs.ref }}
|
||||
|
||||
- name: Commit and tag
|
||||
id: src
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch -q --tags
|
||||
sha=$(git rev-parse HEAD)
|
||||
echo "sha=$sha" >>"$GITHUB_OUTPUT"
|
||||
echo "tag=tth-${sha:0:8}" >>"$GITHUB_OUTPUT"
|
||||
git describe --tags --abbrev=0 --match '*v[0-9]*' HEAD
|
||||
|
||||
- name: Release exists?
|
||||
env:
|
||||
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"
|
||||
auth="header = \"Authorization: token $TOKEN\""
|
||||
id=$(curl -sS --config - "$api/releases/tags/$TAG" <<<"$auth" | jq -r '.id // empty')
|
||||
if [ -n "$id" ]; 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/$TAG" <<<"$auth" || true
|
||||
echo "removed old $TAG"
|
||||
fi
|
||||
|
||||
- name: Setup Build Environment
|
||||
uses: ./.github/actions/setup-build-environment
|
||||
|
||||
- name: Build and package
|
||||
id: build
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sha=$(git rev-parse --short=8 HEAD)
|
||||
dist="$GITHUB_WORKSPACE/dist"
|
||||
mkdir -p "$dist"
|
||||
version=""
|
||||
for env in $ENVS; do
|
||||
echo "::group::$env"
|
||||
pio run -e "$env"
|
||||
b=".pio/build/$env"
|
||||
if [ -f "$b/firmware.zip" ]; then # nRF52
|
||||
python3 bin/uf2conv/uf2conv.py "$b/firmware.hex" -c -o "$b/firmware.uf2" -f 0xADA52840
|
||||
cp "$b/firmware.uf2" "$dist/$env-$sha.uf2"
|
||||
cp "$b/firmware.zip" "$dist/$env-$sha.zip"
|
||||
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
|
||||
[ -n "$version" ] || version="$v"
|
||||
else # ESP32
|
||||
pio run -t mergebin -e "$env"
|
||||
cp "$b/firmware.bin" "$dist/$env-$sha.bin"
|
||||
cp "$b/firmware-merged.bin" "$dist/$env-$sha-merged.bin"
|
||||
fi
|
||||
echo "::endgroup::"
|
||||
done
|
||||
cd "$dist"
|
||||
sha256sum -- * >SHA256SUMS
|
||||
cat SHA256SUMS
|
||||
echo "version=${version:-tth-$sha}" >>"$GITHUB_OUTPUT"
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN || github.token }}
|
||||
SHA: ${{ steps.src.outputs.sha }}
|
||||
TAG: ${{ steps.src.outputs.tag }}
|
||||
VERSION: ${{ steps.build.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
api="$GITEA/api/v1/repos/$GITHUB_REPOSITORY"
|
||||
auth="header = \"Authorization: token $TOKEN\""
|
||||
note='BLE PIN 123456 and admin password "password" are placeholders: change them after flashing.'
|
||||
body=$(printf '%s\n\ncommit %s, run %s\n\n%s\nWhat this fork changes against upstream: see README.md.\n' \
|
||||
"$VERSION" "$SHA" "$GITHUB_RUN_NUMBER" "$note")
|
||||
jq -n --arg t "$TAG" --arg c "$SHA" --arg n "$VERSION" --arg b "$body" \
|
||||
'{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' \
|
||||
--data-binary "@$RUNNER_TEMP/rel.json" "$api/releases" <<<"$auth" | jq -r .id)
|
||||
for f in dist/*; do
|
||||
curl -sSf --config - -X POST -F "attachment=@$f" \
|
||||
"$api/releases/$id/assets?name=$(basename "$f")" <<<"$auth" >/dev/null
|
||||
echo "uploaded $(basename "$f")"
|
||||
done
|
||||
echo "released $TAG = $VERSION (id $id)"
|
||||
Reference in new issue
Block a user