Some checks failed
CI / test (push) Failing after 1m35s
Disable release workflow trigger to prevent duplicate builds when tagging manually with pre-built binaries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
169 lines
6.0 KiB
YAML
169 lines
6.0 KiB
YAML
name: Build & Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'disabled-v*'
|
|
|
|
jobs:
|
|
release:
|
|
runs_on: ubuntu-latest
|
|
container:
|
|
image: rust:1.86-slim
|
|
steps:
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update && apt-get install -y --no-install-recommends \
|
|
git curl jq ca-certificates zip unzip \
|
|
musl-tools \
|
|
gcc-aarch64-linux-gnu \
|
|
gcc-arm-linux-gnueabihf \
|
|
gcc-mingw-w64-x86-64
|
|
rustup target add \
|
|
x86_64-unknown-linux-musl \
|
|
aarch64-unknown-linux-musl \
|
|
armv7-unknown-linux-musleabihf \
|
|
x86_64-pc-windows-gnu \
|
|
aarch64-linux-android \
|
|
armv7-linux-androideabi
|
|
# Install Android NDK for cross-compilation
|
|
NDK_VER=r27c
|
|
curl -sL https://dl.google.com/android/repository/android-ndk-${NDK_VER}-linux.zip -o /tmp/ndk.zip
|
|
unzip -q /tmp/ndk.zip -d /opt && rm /tmp/ndk.zip
|
|
export ANDROID_NDK_HOME=/opt/android-ndk-${NDK_VER}
|
|
|
|
- name: Ensure code is present
|
|
run: |
|
|
git config --global --add safe.directory '*'
|
|
if [ ! -f "Cargo.toml" ]; then
|
|
git clone --depth 1 --branch ${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git /tmp/src
|
|
cp -a /tmp/src/. .
|
|
fi
|
|
|
|
- name: Configure cross-linkers
|
|
run: |
|
|
mkdir -p .cargo
|
|
cat > .cargo/config.toml << 'TOML'
|
|
[target.aarch64-unknown-linux-musl]
|
|
linker = "aarch64-linux-gnu-gcc"
|
|
rustflags = ["-C", "target-feature=+crt-static"]
|
|
|
|
[target.armv7-unknown-linux-musleabihf]
|
|
linker = "arm-linux-gnueabihf-gcc"
|
|
rustflags = ["-C", "target-feature=+crt-static"]
|
|
|
|
[target.x86_64-pc-windows-gnu]
|
|
linker = "x86_64-w64-mingw32-gcc"
|
|
|
|
[target.aarch64-linux-android]
|
|
linker = "/opt/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang"
|
|
|
|
[target.armv7-linux-androideabi]
|
|
linker = "/opt/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi35-clang"
|
|
TOML
|
|
|
|
- name: Build Linux x86_64
|
|
run: cargo build --release --target x86_64-unknown-linux-musl
|
|
|
|
- name: Build Linux aarch64
|
|
run: cargo build --release --target aarch64-unknown-linux-musl
|
|
|
|
- name: Build Linux armv7
|
|
run: cargo build --release --target armv7-unknown-linux-musleabihf
|
|
|
|
- name: Build Windows x86_64
|
|
run: cargo build --release --target x86_64-pc-windows-gnu
|
|
|
|
- name: Build Android aarch64 (ARMv8)
|
|
run: cargo build --release --target aarch64-linux-android
|
|
|
|
- name: Build Android armv7 (ARMv7)
|
|
run: cargo build --release --target armv7-linux-androideabi
|
|
|
|
- name: Package all
|
|
run: |
|
|
mkdir -p /artifacts
|
|
|
|
cd target/x86_64-unknown-linux-musl/release
|
|
tar czf /artifacts/btest-linux-x86_64.tar.gz btest
|
|
cd -
|
|
|
|
cd target/aarch64-unknown-linux-musl/release
|
|
tar czf /artifacts/btest-linux-aarch64.tar.gz btest
|
|
cd -
|
|
|
|
cd target/armv7-unknown-linux-musleabihf/release
|
|
tar czf /artifacts/btest-linux-armv7.tar.gz btest
|
|
cd -
|
|
|
|
cd target/x86_64-pc-windows-gnu/release
|
|
zip /artifacts/btest-windows-x86_64.zip btest.exe
|
|
cd -
|
|
|
|
cd target/aarch64-linux-android/release
|
|
tar czf /artifacts/btest-android-aarch64.tar.gz btest
|
|
cd -
|
|
|
|
cd target/armv7-linux-androideabi/release
|
|
tar czf /artifacts/btest-android-armv7.tar.gz btest
|
|
cd -
|
|
|
|
cd /artifacts
|
|
sha256sum * > checksums-sha256.txt
|
|
cat checksums-sha256.txt
|
|
ls -lh
|
|
|
|
- name: Create release and upload
|
|
env:
|
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
run: |
|
|
TAG="${GITHUB_REF_NAME}"
|
|
GITEA_URL="${GITHUB_SERVER_URL}"
|
|
REPO="${GITHUB_REPOSITORY}"
|
|
REGISTRY="git.manko.yoga"
|
|
|
|
RELEASE_BODY="## Downloads
|
|
|
|
| Platform | Architecture | File |
|
|
|----------|-------------|------|
|
|
| Linux | x86_64 | btest-linux-x86_64.tar.gz |
|
|
| Linux | aarch64 (RPi 64-bit) | btest-linux-aarch64.tar.gz |
|
|
| Linux | armv7 (RPi 32-bit) | btest-linux-armv7.tar.gz |
|
|
| Windows | x86_64 | btest-windows-x86_64.zip |
|
|
| Android | aarch64 (ARMv8, Termux) | btest-android-aarch64.tar.gz |
|
|
| Android | armv7 (ARMv7, Termux) | btest-android-armv7.tar.gz |
|
|
| macOS | aarch64 / x86_64 | Run \`scripts/build-macos-release.sh --upload ${TAG}\` |
|
|
| Docker | x86_64 | \`docker pull ${REGISTRY}/manawenuz/btest-rs:${TAG}\` |
|
|
|
|
### Quick Install (Linux)
|
|
\`\`\`bash
|
|
tar xzf btest-linux-x86_64.tar.gz
|
|
sudo mv btest /usr/local/bin/
|
|
\`\`\`
|
|
|
|
### Docker
|
|
\`\`\`bash
|
|
docker run --rm -p 2000:2000 -p 2001-2100:2001-2100/udp ${REGISTRY}/manawenuz/btest-rs:${TAG} -s -v
|
|
\`\`\`"
|
|
|
|
RELEASE_ID=$(curl -sf -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "$(jq -n --arg tag "$TAG" --arg name "btest-rs $TAG" --arg body "$RELEASE_BODY" \
|
|
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')" \
|
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases" | jq -r '.id')
|
|
|
|
echo "Created release ID: ${RELEASE_ID}"
|
|
|
|
for file in /artifacts/*.tar.gz /artifacts/*.zip /artifacts/checksums-sha256.txt; do
|
|
FILENAME=$(basename "$file")
|
|
echo "Uploading: ${FILENAME}"
|
|
curl -sf -X POST \
|
|
-H "Authorization: token ${TOKEN}" \
|
|
-F "attachment=@${file}" \
|
|
"${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \
|
|
| jq -r '.name // .message'
|
|
done
|
|
|
|
echo "Release ${TAG} published!"
|