Files
nuwiki/.gitea/workflows/release.yaml
gffranco 8cff0c2d68
CI / cargo fmt --check (push) Successful in 29s
CI / cargo clippy (push) Successful in 22s
CI / cargo test (push) Successful in 35s
CI / editor keymaps (push) Successful in 2m4s
Release / build x86_64-unknown-linux-gnu (push) Successful in 34s
Release / build aarch64-unknown-linux-musl (push) Successful in 55s
Release / build aarch64-unknown-linux-gnu (push) Successful in 1m50s
Release / build x86_64-unknown-linux-musl (push) Successful in 47s
Release / gitea release (push) Successful in 37s
ci(release): add libc6-dev-arm64-cross for aarch64-gnu builds
gcc-aarch64-linux-gnu ships the cross compiler and binutils only;
linking glibc binaries also requires the target libc crt/dev files
(Scrt1.o, crti.o), which live in libc6-dev-arm64-cross.

Without it, the aarch64-unknown-linux-gnu build failed with:
  ld: cannot find Scrt1.o: No such file or directory
  ld: cannot find crti.o: No such file or directory

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 01:27:57 +00:00

157 lines
5.2 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: short
jobs:
build:
name: build ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
apt: ""
rustflags: ""
- target: aarch64-unknown-linux-gnu
# gcc-aarch64-linux-gnu ships the cross compiler/binutils
# but no target libc; libc6-dev-arm64-cross adds Scrt1.o,
# crti.o, and friends needed at link time.
apt: "gcc-aarch64-linux-gnu libc6-dev-arm64-cross"
rustflags: ""
- target: x86_64-unknown-linux-musl
apt: "musl-tools"
rustflags: ""
- target: aarch64-unknown-linux-musl
apt: ""
rustflags: "-C linker=rust-lld -C link-self-contained=yes"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.83
with:
targets: ${{ matrix.target }}
- name: Install cross toolchain
if: matrix.apt != ''
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends ${{ matrix.apt }}
- name: Cache cargo state
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-release-${{ matrix.target }}-
- name: Build nuwiki-ls
env:
# Per-target linker overrides. Cargo ignores the entries that
# don't match the current target, so setting all of them here
# keeps the matrix declarative.
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: musl-gcc
RUSTFLAGS: ${{ matrix.rustflags }}
run: cargo build --release --target ${{ matrix.target }} -p nuwiki-ls
- name: Package archive
id: package
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
archive="nuwiki-ls-${version}-${{ matrix.target }}.tar.gz"
tar -czf "$archive" -C "target/${{ matrix.target }}/release" nuwiki-ls
echo "archive=$archive" >> "$GITHUB_OUTPUT"
- name: Upload build artifact
# Gitea Actions doesn't support upload-artifact v4 (uses a
# GitHub-only backend API); pin to v3.
uses: actions/upload-artifact@v3
with:
name: nuwiki-ls-${{ matrix.target }}
path: ${{ steps.package.outputs.archive }}
if-no-files-found: error
retention-days: 7
release:
name: gitea release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all build artifacts
# Paired with upload-artifact@v3 above. v3 has no merge-multiple
# option and nests each artifact under its own subdirectory.
uses: actions/download-artifact@v3
with:
path: ./artifacts
- name: Ensure jq + curl
run: |
if ! command -v jq >/dev/null 2>&1; then
apt-get update && apt-get install -y --no-install-recommends jq
fi
if ! command -v curl >/dev/null 2>&1; then
apt-get update && apt-get install -y --no-install-recommends curl
fi
- name: Create Gitea release + upload assets
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GITEA_SERVER: ${{ github.server_url }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
if [ -z "${RELEASE_TOKEN:-}" ]; then
echo "::error::RELEASE_TOKEN secret is not set"
exit 1
fi
echo "Releasing $TAG to $GITEA_SERVER/$REPO"
payload=$(jq -n --arg tag "$TAG" --arg name "$TAG" \
'{tag_name: $tag, name: $name, draft: false, prerelease: false}')
release_id=$(curl --fail --silent --show-error \
-H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/json" \
-d "$payload" \
"$GITEA_SERVER/api/v1/repos/$REPO/releases" \
| jq -r '.id')
if [ -z "$release_id" ] || [ "$release_id" = "null" ]; then
echo "::error::failed to create release"
exit 1
fi
echo "Created release id=$release_id"
# download-artifact@v3 nests each artifact under its own dir
# (artifacts/<artifact-name>/<file>), so recurse.
for archive in $(find artifacts -name '*.tar.gz' -type f); do
name="$(basename "$archive")"
echo "Uploading $name …"
curl --fail --silent --show-error \
-H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/gzip" \
--data-binary "@$archive" \
"$GITEA_SERVER/api/v1/repos/$REPO/releases/$release_id/assets?name=$name" \
>/dev/null
done
echo "All assets uploaded."