name: Release VPS agent on: push: tags: - "v*.*.*" permissions: contents: read releases: write jobs: release-agent: name: Build and publish Linux agent runs-on: ubuntu-latest timeout-minutes: 45 env: BINFMT_IMAGE: "tonistiigi/binfmt:qemu-v10.2.3-68" steps: - name: Checkout tag uses: https://gitea.com/actions/checkout@v4 with: fetch-depth: 1 - name: Validate tag and package version shell: bash run: | set -Eeuo pipefail tag="${GITHUB_REF_NAME}" if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then printf 'invalid release tag: %s\n' "$tag" >&2 exit 1 fi package_version="$(awk -F ' *= *' '$1 == "version" {gsub(/"/, "", $2); print $2; exit}' agent/Cargo.toml)" if [[ "v$package_version" != "$tag" ]]; then printf 'tag %s does not match agent/Cargo.toml version %s\n' "$tag" "$package_version" >&2 exit 1 fi - name: Prepare multi-architecture builder shell: bash run: | set -Eeuo pipefail for command_name in docker curl jq file sha256sum; do command -v "$command_name" >/dev/null || { printf 'runner prerequisite is missing: %s\n' "$command_name" >&2 exit 1 } done docker info >/dev/null docker buildx version >/dev/null docker run --privileged --rm "$BINFMT_IMAGE" --install arm64 docker buildx inspect --bootstrap - name: Build static Linux binaries shell: bash run: | set -Eeuo pipefail docker buildx build \ --platform linux/amd64 \ --file agent/Dockerfile.release \ --target artifact \ --output type=local,dest=build/linux-amd64 \ . docker buildx build \ --platform linux/arm64 \ --file agent/Dockerfile.release \ --target artifact \ --output type=local,dest=build/linux-arm64 \ . - name: Package and verify assets shell: bash run: | set -Eeuo pipefail ./scripts/package-agent-release.sh \ --output dist \ --amd64 build/linux-amd64/vps-agent \ --arm64 build/linux-arm64/vps-agent file dist/vps-agent-linux-amd64 dist/vps-agent-linux-arm64 grep -q 'statically linked' < <(file -b dist/vps-agent-linux-amd64) grep -q 'statically linked' < <(file -b dist/vps-agent-linux-arm64) - name: Publish Gitea release shell: bash env: GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | set -Eeuo pipefail ./scripts/publish-gitea-release.sh "$GITHUB_REF_NAME" dist