Files
EnvBao/.gitea/workflows/release.yml
mattandClaude Sonnet 5.5 e6e3d9049f
build-check / build-check (arm64, linux-arm64, linux-arm64) (push) Successful in 3m21s
test / test (push) Successful in 59s
build-check / build-check (amd64, linux-amd64, linux-amd64) (push) Successful in 1m15s
CI: build Linux releases in Debian 12 for older-glibc compatibility; deploy new releases via playbooks repo
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 16:01:45 +00:00

142 lines
5.1 KiB
YAML

name: release
# Runs when a SemVer tag such as v1.4.0 or v2.0.0-rc.1 is pushed.
on:
push:
tags: ["v*"]
jobs:
validate:
runs-on: linux-amd64
outputs:
version: ${{ steps.v.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: v
name: Validate tag is SemVer
run: |
version="$(python3 scripts/version_from_tag.py "${GITHUB_REF_NAME}")"
echo "version=${version}" >> "$GITHUB_OUTPUT"
build-linux:
needs: validate
strategy:
fail-fast: true
matrix:
include:
# PyInstaller cannot cross-compile: each target builds on a matching runner.
# Building inside Debian 12 (glibc 2.36) keeps the binaries runnable on bookworm and newer.
- { runner: linux-amd64, target: linux-amd64, deb_arch: amd64 }
- { runner: linux-arm64, target: linux-arm64, deb_arch: arm64 }
runs-on: ${{ matrix.runner }}
container:
image: node:20-bookworm
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.13"
- name: Install dependencies
run: uv sync --all-groups --frozen
- name: Test
run: uv run pytest -q --cov
- name: Stamp version from tag
run: python3 scripts/version_from_tag.py "${GITHUB_REF_NAME}"
- name: Build one-dir application
run: uv run pyinstaller envbao.spec --clean --noconfirm
- name: Smoke test
run: test "$(./dist/envbao/envbao --version)" = "envbao ${VERSION}"
- name: Check glibc requirement is Debian 12 compatible (<= 2.36)
run: |
max="$(objdump -T dist/envbao/envbao dist/envbao/_internal/*.so* 2>/dev/null | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -Vu | tail -1)"
echo "max glibc symbol: ${max}"
test "$(printf '%s\n2.36\n' "${max}" | sort -V | tail -1)" = "2.36"
- name: Package
run: |
mkdir -p out
tar -C dist -czf "out/envbao-${VERSION}-${{ matrix.target }}.tar.gz" envbao
python3 scripts/packaging/build_deb.py "${VERSION}" "${{ matrix.deb_arch }}" dist out
ls -l out
- uses: actions/upload-artifact@v3
with:
name: envbao-${{ matrix.target }}
path: out/*
build-macos:
needs: validate
runs-on: macos-arm64
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: "3.13"
- name: Install dependencies
run: uv sync --all-groups --frozen
- name: Test
run: uv run pytest -q --cov
- name: Stamp version from tag
run: python3 scripts/version_from_tag.py "${GITHUB_REF_NAME}"
- name: Build one-dir application
run: uv run pyinstaller envbao.spec --clean --noconfirm
- name: Smoke test
run: test "$(./dist/envbao/envbao --version)" = "envbao ${VERSION}"
- name: Package
run: |
mkdir -p out
tar -C dist -czf "out/envbao-${VERSION}-macos-arm64.tar.gz" envbao
sh scripts/packaging/build_pkg.sh "${VERSION}" dist out
ls -l out
- uses: actions/upload-artifact@v3
with:
name: envbao-macos-arm64
path: out/*
release:
needs: [validate, build-linux, build-macos]
runs-on: linux-amd64
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Checksums
run: |
mkdir release
cp artifacts/*/* release/
(cd release && sha256sum * > SHA256SUMS)
- name: Publish Gitea release
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ github.ref_name }}
VERSION: ${{ needs.validate.outputs.version }}
run: |
set -eu
case "$VERSION" in *-*) pre=true ;; *) pre=false ;; esac
id="$(curl -fsS -X POST "$API/releases" \
-H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"prerelease\":$pre}" \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
for f in release/*; do
curl -fsS -X POST "$API/releases/$id/assets?name=$(basename "$f")" \
-H "Authorization: token $TOKEN" -F "attachment=@$f" >/dev/null
done
# Ask the playbooks repo to roll the new release out to every node.
deploy:
needs: release
runs-on: linux-amd64
continue-on-error: true
steps:
- name: Trigger playbooks deploy (envbao)
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
SERVER: ${{ github.server_url }}
run: |
curl -fsS -X POST "$SERVER/api/v1/repos/matt/playbooks/actions/workflows/deploy.yml/dispatches" \
-H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d '{"ref":"main","inputs":{"playbook":"envbao","limit":"","check_only":"false","allow_reboot":"false"}}'