# 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. # # Defaults follow the Czech mesh (meshcore.cz wiki: nastaveni_site_meshcore_cz, # instalace_repeateru, regiony), PUB_FLAGS below. They apply to a node with # no saved settings (fresh, or after an erase); a reflash keeps what is set. # # Runs on every push to main -- the export pushes there only after an # upstream merge (private repo, tth-upstream-sync) -- and by hand. # Release tag tth-, titled with the stamped version (v1.18.0-tth); # the newest KEEP releases stay, older ones are deleted. # 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": push: branches: [main] 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 KEEP: 5 # 869.432/62.5/SF7/CR5; repeater + room server: zero-hop advert off, flood # advert 25 h, af 9 (= 10 % duty cycle); repeater: regions cz,cs next to *. # Path hash 2 B is this fork's default anyway. TX power stays the board's. # FILTER_CHANNEL_PSKS = [channel_filter] in platformio.ini (#meshcore, Public, # #test -- public keys): compiles the repeater's `filter` (deny-forward by # sender name); inert until an operator adds a name. PUB_FLAGS: >- -D LORA_FREQ=869.432 -D LORA_BW=62.5 -D LORA_SF=7 -D LORA_CR=5 -D ADVERT_INTERVAL_DEFAULT=0 -D FLOOD_ADVERT_INTERVAL_DEFAULT=25 -D AIRTIME_FACTOR_DEFAULT=9.0 -D DEFAULT_REGIONS=\"cz,cs\" -D FILTER_CHANNEL_PSKS=\"2fa78a5aef618e7c2a78f0ab5c8869b3,8b3387e9c5cdea6ac9e5edbaa115cd72,9cd8fcf22a47333b591d96a2b848b73f\" 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 || github.sha }} - 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) # PlatformIO appends these after each env's flags: last -D wins export PLATFORMIO_BUILD_FLAGS="$PUB_FLAGS" 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. Czech mesh defaults (meshcore.cz): 869.432 MHz / 62.5 kHz / SF7 / CR5; repeater: zero-hop advert off, flood advert 25 h, af 9 (10 % duty cycle), regions cz + cs. Apply to a fresh or erased node only.' 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)" # keep the newest $KEEP, oldest go (with their tags) curl -sSf --config - "$api/releases?limit=50" <<<"$auth" | jq -r --argjson k "$KEEP" 'map(select(.tag_name | startswith("tth-"))) | sort_by(.created_at) | reverse | .[$k:][] | "\(.id) \(.tag_name)"' | while read -r old_id old_tag; do curl -sSf --config - -X DELETE "$api/releases/$old_id" <<<"$auth" curl -sSf --config - -X DELETE "$api/tags/$old_tag" <<<"$auth" || true echo "pruned $old_tag" done