Let users bring their own domain instead of DuckDNS in setup #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release decenzed-node | |
| # Triggered by pushing a version tag (e.g. `git tag v1.2.0 && git push origin v1.2.0`). | |
| # Builds the node binaries for every platform (desktop + OpenWRT router CPUs), | |
| # generates a checksum manifest, and publishes a Release in the PUBLIC | |
| # distribution repo (icecube092/decenzed-node) using DECENZED_NODE_GIT_TOKEN. | |
| # Nodes auto-update from that repo's releases (update_manifest.txt points at its | |
| # /releases/latest/download/manifest.json). The OpenWRT one-line installer | |
| # (install-openwrt.sh) is attached to the release too. | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: read | |
| env: | |
| # Build matrix, one target per line: name|GOOS|GOARCH|EXTRA_ENV|MANIFEST_KEY | |
| # MANIFEST_KEY must equal selfupdate.platformKey() for that build: for amd64/ | |
| # arm64/desktop it is GOOS_GOARCH; for ARM/MIPS float variants it is the exact | |
| # flavour (baked into the binary via -X selfupdate.VariantKey) so the updater | |
| # and install-openwrt.sh both resolve the same asset. | |
| TARGETS: | | |
| linux-amd64|linux|amd64||linux_amd64 | |
| linux-386|linux|386||linux_386 | |
| linux-arm64|linux|arm64||linux_arm64 | |
| linux-armv7|linux|arm|GOARM=7|linux_armv7 | |
| linux-armv6|linux|arm|GOARM=6|linux_armv6 | |
| linux-armv5|linux|arm|GOARM=5|linux_armv5 | |
| linux-mips-softfloat|linux|mips|GOMIPS=softfloat|linux_mips_softfloat | |
| linux-mipsle-softfloat|linux|mipsle|GOMIPS=softfloat|linux_mipsle_softfloat | |
| linux-mips64le|linux|mips64le||linux_mips64le | |
| linux-mips64|linux|mips64||linux_mips64 | |
| darwin-amd64|darwin|amd64||darwin_amd64 | |
| darwin-arm64|darwin|arm64||darwin_arm64 | |
| windows-amd64|windows|amd64||windows_amd64 | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| env: | |
| DIST_REPO: icecube092/decenzed-node | |
| TAG: ${{ github.ref_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: src/go.mod | |
| cache-dependency-path: src/go.sum | |
| - name: Install UPX | |
| run: | | |
| set -euo pipefail | |
| UPX_VER=4.2.4 | |
| curl -fsSL -o /tmp/upx.tar.xz \ | |
| "https://github.com/upx/upx/releases/download/v${UPX_VER}/upx-${UPX_VER}-amd64_linux.tar.xz" | |
| tar -C /tmp -xf /tmp/upx.tar.xz | |
| sudo install "/tmp/upx-${UPX_VER}-amd64_linux/upx" /usr/local/bin/upx | |
| upx --version | head -1 | |
| - name: Build binaries (desktop + OpenWRT router CPUs) | |
| working-directory: src | |
| run: | | |
| set -euo pipefail | |
| mkdir -p ../dist | |
| printf '%s\n' "$TARGETS" | while IFS='|' read -r name goos goarch extra key; do | |
| [ -z "$name" ] && continue | |
| out="decenzed-node-${name}" | |
| [ "$goos" = "windows" ] && out="${out}.exe" | |
| echo "==> $out (key=$key)" | |
| env ${extra:+$extra} GOOS="$goos" GOARCH="$goarch" CGO_ENABLED=0 \ | |
| go build -trimpath \ | |
| -ldflags "-s -w -X main.version=${TAG} -X decenzed/node_app/internal/selfupdate.VariantKey=${key}" \ | |
| -o "../dist/${out}" ./cmd/decenzed-node || exit 1 | |
| # Compress only the genuinely flash-tight router builds: 32-bit ARM | |
| # (armv5/6/7) and 32-bit MIPS, the arches found on 8-16 MB-flash | |
| # devices. Everything else ships uncompressed — desktop/server (amd64, | |
| # 386, windows, macOS) and arm64 routers, which have ample flash | |
| # (NAND/eMMC/SD), so we avoid the antivirus / VirusTotal false | |
| # positives UPX packing causes; and the 64-bit MIPS arches, which UPX | |
| # can't pack anyway. Done BEFORE the manifest step so its SHA-256 | |
| # covers the (possibly) compressed file. | |
| case "${goos}/${goarch}" in | |
| linux/arm|linux/mips|linux/mipsle) | |
| upx -q --best --lzma "../dist/${out}" >/dev/null 2>&1 \ | |
| && echo " upx: compressed (flash-constrained router arch)" \ | |
| || echo " upx: skipped (unsupported arch?) — kept uncompressed" ;; | |
| *) | |
| echo " upx: skipped (desktop/arm64/64-bit MIPS — kept uncompressed)" ;; | |
| esac | |
| done || exit 1 | |
| echo "----- built -----" | |
| ls -la ../dist | |
| - name: Generate manifest.json | |
| run: | | |
| set -euo pipefail | |
| { | |
| echo '{' | |
| echo " \"version\": \"${TAG#v}\"," | |
| echo ' "assets": {' | |
| first=1 | |
| printf '%s\n' "$TARGETS" | while IFS='|' read -r name goos goarch extra key; do | |
| [ -z "$name" ] && continue | |
| out="decenzed-node-${name}" | |
| [ "$goos" = "windows" ] && out="${out}.exe" | |
| sha="$(sha256sum "dist/${out}" | cut -d' ' -f1)" | |
| size="$(wc -c < "dist/${out}" | tr -d ' ')" | |
| url="https://github.com/${DIST_REPO}/releases/download/${TAG}/${out}" | |
| [ "$first" -eq 0 ] && echo ',' | |
| first=0 | |
| printf ' "%s": { "url": "%s", "sha256": "%s", "size": %s }' "$key" "$url" "$sha" "$size" | |
| done | |
| echo | |
| echo ' }' | |
| echo '}' | |
| } > dist/manifest.json | |
| echo "----- manifest.json -----" | |
| cat dist/manifest.json | |
| - name: Publish release in ${{ env.DIST_REPO }} | |
| env: | |
| GH_TOKEN: ${{ secrets.DECENZED_NODE_GIT_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| gh release create "$TAG" \ | |
| --repo "$DIST_REPO" \ | |
| --title "$TAG" \ | |
| --notes "Automated release of decenzed-node $TAG" \ | |
| dist/decenzed-node-* dist/manifest.json install-openwrt.sh |