Skip to content

Release v0.2.4 for OpenWrt #24

Release v0.2.4 for OpenWrt

Release v0.2.4 for OpenWrt #24

Workflow file for this run

name: Build OpenWrt
run-name: Release v${{ inputs.version }} for OpenWrt
on:
workflow_dispatch:
inputs:
version:
description: "Release version without the v prefix (for example, 0.1.0)"
required: true
type: string
concurrency:
group: ${{ github.workflow }}-${{ inputs.version }}
cancel-in-progress: false
permissions:
contents: read
jobs:
build:
name: Build OpenWrt ${{ matrix.package_arch }}
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- goarch: amd64
package_arch: x86_64
check_args: ""
- goarch: arm64
package_arch: aarch64_generic
check_args: --skip-checks
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Validate version
env:
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [[ ! "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
echo "Invalid version: use a version such as 0.1.0 or 0.1.0-beta.1" >&2
exit 1
fi
git check-ref-format "refs/tags/v${VERSION}"
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Setup Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: backend/go.mod
cache-dependency-path: backend/go.sum
- name: Build OpenWrt ${{ matrix.goarch }}
env:
VERSION: ${{ inputs.version }}
run: python build.py --target openwrt --arch "${{ matrix.goarch }}" --version "$VERSION" ${{ matrix.check_args }}
- name: Upload workflow artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ackwrap-${{ inputs.version }}-openwrt-${{ matrix.goarch }}
path: |
dist/ackwrap-openwrt-${{ matrix.goarch }}
dist/ackwrap_${{ inputs.version }}-1_${{ matrix.package_arch }}.ipk
if-no-files-found: error
retention-days: 14
release:
name: Publish GitHub Release
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout release commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Download amd64 workflow artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ackwrap-${{ inputs.version }}-openwrt-amd64
path: dist
- name: Download arm64 workflow artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ackwrap-${{ inputs.version }}-openwrt-arm64
path: dist
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
tag="v${VERSION}"
assets=(
"dist/ackwrap-openwrt-amd64"
"dist/ackwrap_${VERSION}-1_x86_64.ipk"
"dist/ackwrap-openwrt-arm64"
"dist/ackwrap_${VERSION}-1_aarch64_generic.ipk"
)
resolve_remote_commit() {
local commit
commit="$(git ls-remote --tags origin "refs/tags/${tag}^{}" | cut -f1)"
if [[ -z "$commit" ]]; then
commit="$(git ls-remote --tags origin "refs/tags/$tag" | cut -f1)"
fi
printf '%s' "$commit"
}
remote_commit="$(resolve_remote_commit)"
if [[ -n "$remote_commit" && "$remote_commit" != "$GITHUB_SHA" ]]; then
echo "Tag $tag already points to another commit" >&2
exit 1
fi
if [[ -z "$remote_commit" ]]; then
git tag "$tag" "$GITHUB_SHA"
if ! git push origin "refs/tags/$tag"; then
remote_commit="$(resolve_remote_commit)"
if [[ "$remote_commit" != "$GITHUB_SHA" ]]; then
echo "Failed to publish tag $tag at $GITHUB_SHA" >&2
exit 1
fi
fi
fi
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists; assets were not overwritten"
exit 0
fi
if ! gh release create "$tag" "${assets[@]}" \
--verify-tag \
--title "$tag" \
--generate-notes; then
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag was published concurrently; assets were not overwritten"
exit 0
fi
exit 1
fi