Files
btest-rs/.gitea/workflows/release.yml
Siavash Sameni 99a751fa28
Some checks failed
Build & Release / build-linux-x86_64 (push) Failing after 24s
CI / test (push) Successful in 1m6s
Build & Release / build-linux-aarch64 (push) Failing after 28s
Build & Release / build-linux-armv7 (push) Failing after 32s
Build & Release / release (push) Has been skipped
Fix CI: replace actions/checkout with manual git clone
The act runner executes actions/checkout inside the job container,
but that action is a Node.js script and rust:1.86-slim has no node.
Use plain git clone instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 14:10:15 +04:00

199 lines
6.4 KiB
YAML

name: Build & Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build-linux-x86_64:
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 musl-tools
rustup target add x86_64-unknown-linux-musl
- name: Checkout
run: |
git config --global --add safe.directory '*'
git clone --depth 1 --branch ${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git /build
- name: Build
run: cargo build --release --target x86_64-unknown-linux-musl
working_directory: /build
- name: Package
run: |
mkdir -p /artifacts
cd /build/target/x86_64-unknown-linux-musl/release
tar czf /artifacts/btest-linux-x86_64.tar.gz btest
sha256sum /artifacts/btest-linux-x86_64.tar.gz > /artifacts/btest-linux-x86_64.tar.gz.sha256
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: btest-linux-x86_64
path: /artifacts/
build-linux-aarch64:
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 gcc-aarch64-linux-gnu
rustup target add aarch64-unknown-linux-musl
- name: Checkout
run: |
git config --global --add safe.directory '*'
git clone --depth 1 --branch ${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git /build
- name: Configure cross-linker
run: |
mkdir -p /build/.cargo
cat > /build/.cargo/config.toml << 'TOML'
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-gnu-gcc"
rustflags = ["-C", "target-feature=+crt-static"]
TOML
- name: Build
run: cargo build --release --target aarch64-unknown-linux-musl
working_directory: /build
- name: Package
run: |
mkdir -p /artifacts
cd /build/target/aarch64-unknown-linux-musl/release
tar czf /artifacts/btest-linux-aarch64.tar.gz btest
sha256sum /artifacts/btest-linux-aarch64.tar.gz > /artifacts/btest-linux-aarch64.tar.gz.sha256
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: btest-linux-aarch64
path: /artifacts/
build-linux-armv7:
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 gcc-arm-linux-gnueabihf
rustup target add armv7-unknown-linux-musleabihf
- name: Checkout
run: |
git config --global --add safe.directory '*'
git clone --depth 1 --branch ${GITHUB_REF_NAME} ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git /build
- name: Configure cross-linker
run: |
mkdir -p /build/.cargo
cat > /build/.cargo/config.toml << 'TOML'
[target.armv7-unknown-linux-musleabihf]
linker = "arm-linux-gnueabihf-gcc"
rustflags = ["-C", "target-feature=+crt-static"]
TOML
- name: Build
run: cargo build --release --target armv7-unknown-linux-musleabihf
working_directory: /build
- name: Package
run: |
mkdir -p /artifacts
cd /build/target/armv7-unknown-linux-musleabihf/release
tar czf /artifacts/btest-linux-armv7.tar.gz btest
sha256sum /artifacts/btest-linux-armv7.tar.gz > /artifacts/btest-linux-armv7.tar.gz.sha256
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: btest-linux-armv7
path: /artifacts/
release:
needs: [build-linux-x86_64, build-linux-aarch64, build-linux-armv7]
runs_on: ubuntu-latest
container:
image: ubuntu:latest
steps:
- name: Install tools
run: apt-get update && apt-get install -y --no-install-recommends curl jq ca-certificates
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: /artifacts
- name: List artifacts
run: find /artifacts -type f | sort
- name: Create release and upload
env:
TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
GITEA_URL="${GITHUB_SERVER_URL}"
REPO="${GITHUB_REPOSITORY}"
echo "Creating release ${TAG} for ${REPO}..."
# Create release
RELEASE_BODY="## btest-rs ${TAG}
### 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 |
| macOS | Build locally | \`cargo build --release\` |
### Quick Install
\`\`\`bash
# Download and extract
tar xzf btest-linux-x86_64.tar.gz
sudo mv btest /usr/local/bin/
# Or use the systemd installer
sudo ./install-service.sh --auth-user admin --auth-pass password
\`\`\`"
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}"
# Upload each artifact file
for file in /artifacts/btest-linux-*/*.tar.gz /artifacts/btest-linux-*/*.sha256; do
if [ -f "$file" ]; then
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'
fi
done
echo "Release ${TAG} published!"