Skip to content

v0.4.7

v0.4.7 #7

Workflow file for this run

name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
BINARY_NAME: zero
R2_BUCKET: zero-releases
DL_DOMAIN: dl.zerofiles.app
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
runner: macos-latest
os_arch: macos-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Building version: $VERSION"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup mold linker
if: runner.os == 'Linux'
uses: rui314/setup-mold@v1
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-release-${{ matrix.target }}"
cache-on-failure: true
- name: Build
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
RUSTFLAGS: ${{ matrix.rustflags }}
run: cargo build --release --target ${{ matrix.target }} -p zero-cli
- name: Package artifact
run: |
ARTIFACT_NAME="${BINARY_NAME}-${VERSION}-${{ matrix.os_arch }}"
mkdir -p dist/${ARTIFACT_NAME}
cp target/${{ matrix.target }}/release/${BINARY_NAME} dist/${ARTIFACT_NAME}/
cp LICENSE README.md dist/${ARTIFACT_NAME}/ 2>/dev/null || true
# Include macOS app icon for bundle creation during install
if [[ "${{ matrix.os_arch }}" == macos-* ]] && [ -f resources/AppIcon.icns ]; then
cp resources/AppIcon.icns dist/${ARTIFACT_NAME}/
fi
cd dist
tar -czf ${ARTIFACT_NAME}.tgz ${ARTIFACT_NAME}
shasum -a 512 ${ARTIFACT_NAME}.tgz | cut -d' ' -f1 > ${ARTIFACT_NAME}.tgz.sha512
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os_arch }}
path: dist/${{ env.BINARY_NAME }}-${{ env.VERSION }}-${{ matrix.os_arch }}.tgz*
release:
name: Upload to R2
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- name: Ensure AWS CLI
run: |
if ! command -v aws &>/dev/null; then
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
unzip -q awscliv2.zip && sudo ./aws/install
fi
aws --version
- name: Upload to R2
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
run: |
# Upload versioned artifacts (immutable, cache forever)
for file in dist/*; do
aws s3 cp "$file" "s3://${R2_BUCKET}/v${VERSION}/$(basename $file)" \
--cache-control "public, max-age=31536000, immutable" \
--no-progress
done
# Update latest.txt (short cache so installs pick up new versions quickly)
echo "$VERSION" > latest.txt
aws s3 cp latest.txt s3://${R2_BUCKET}/latest.txt \
--cache-control "public, max-age=60" \
--content-type "text/plain" \
--no-progress
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $GITHUB_REF_NAME \
--title "$GITHUB_REF_NAME" \
--notes "Download: https://${DL_DOMAIN}/v${VERSION}/"