Skip to content

pipeline

pipeline #16

Workflow file for this run

name: Build & Release CacheBolt
on:
push:
tags:
- 'v*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: true
CARGO_PROFILE_RELEASE_OPT_LEVEL: "z"
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
build-and-upload:
needs: create-release
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
ext: ""
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
ext: ""
archive: tar.gz
- target: x86_64-pc-windows-gnu
os: ubuntu-latest
ext: ".exe"
archive: zip
- target: aarch64-apple-darwin
os: macos-latest
ext: ""
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
ext: ""
archive: tar.gz
continue-on-error: true
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build Astro UI
run: |
cd ui
npm ci
npm run build
cd ..
- name: Install cross-compilers and dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
gcc-aarch64-linux-gnu \
gcc-mingw-w64 \
musl-tools \
cmake \
nasm \
pkg-config \
libssl-dev \
zip
- name: Create symlink for aarch64-unknown-linux-gnu-gcc
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo ln -s /usr/bin/aarch64-linux-gnu-gcc /usr/bin/aarch64-unknown-linux-gnu-gcc
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
- name: Build
run: |
if [[ "${{ matrix.target }}" == "x86_64-pc-windows-gnu" ]]; then
export RUSTFLAGS="-D warnings"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
export RUSTFLAGS="-D warnings"
else
export RUSTFLAGS="-D warnings -C link-arg=-Wl,--compress-debug-sections=zlib"
fi
cargo build --release \
--target=${{ matrix.target }} \
--no-default-features \
--features "google-cloud-storage/rustls-tls,azure_storage/enable_reqwest_rustls"
- name: Archive binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/cachebolt${{ matrix.ext }} dist/
if [[ "${{ matrix.archive }}" == "zip" ]]; then
zip -j cachebolt-${{ matrix.target }}.zip dist/*
else
tar -czvf cachebolt-${{ matrix.target }}.tar.gz -C dist .
fi
- name: Upload binary archive to GitHub Release
if: success()
uses: softprops/action-gh-release@v2
with:
files: |
cachebolt-${{ matrix.target }}.${{ matrix.archive }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload binary as artifact
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: actions/upload-artifact@v4
with:
name: cachebolt-x86_64-unknown-linux-musl
path: target/x86_64-unknown-linux-musl/release/cachebolt
docker-publish:
needs: build-and-upload
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Download prebuilt binary
uses: actions/download-artifact@v4
with:
name: cachebolt-x86_64-unknown-linux-musl
path: ./bin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version and lowercase owner
id: meta
run: |
echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
echo "OWNER_LC=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ steps.meta.outputs.OWNER_LC }}/cachebolt:latest
ghcr.io/${{ steps.meta.outputs.OWNER_LC }}/cachebolt:${{ steps.meta.outputs.VERSION }}
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
build-args: |
BINARY=./bin/cachebolt
validate-builds:
needs: build-and-upload
runs-on: ubuntu-latest
if: always()
steps:
- name: Ensure at least one build succeeded
run: |
echo "Evaluating success of matrix builds..."
if [[ "${{ needs.build-and-upload.result }}" == "failure" ]]; then
echo "❌ All builds failed."
exit 1
else
echo "✅ At least one build succeeded."
fi