Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: rust-release

# Builds cross-platform Rust binaries and uploads to GitHub Releases.
# Triggered by auto-release creating a v* tag, or manually.
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v0.1.0)'
required: true

permissions:
contents: write

jobs:
build:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: envcache-linux-amd64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: envcache-linux-arm64
- target: x86_64-apple-darwin
os: macos-latest
artifact: envcache-darwin-amd64
- target: aarch64-apple-darwin
os: macos-latest
artifact: envcache-darwin-arm64

steps:
- uses: actions/checkout@v4

- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}

- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/envcache dist/${{ matrix.artifact }}
chmod +x dist/${{ matrix.artifact }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}

upload:
name: upload to release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist

- name: Upload binaries to release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.release.tag_name || github.event.inputs.tag }}
files: dist/**/*
35 changes: 33 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
- '.devcontainer/**'
- '.github/workflows/**'
jobs:
test:
test-shell:
name: shell (lint + bats)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -21,9 +22,39 @@ jobs:
- run: npm run lint
- run: npm test

test-rust:
name: rust (fmt + clippy + test)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache cargo registry and build
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

- name: Check formatting
run: cargo fmt --check

- name: Run clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test

tests:
name: tests
needs: [test]
needs: [test-shell, test-rust]
runs-on: ubuntu-latest
if: always()
steps:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ CLAUDE.md
.envcache.secrets
envcache.secrets

# Rust (future)
# Rust build artifacts
/target/
Cargo.lock
# Note: Cargo.lock IS committed — this is a binary, not a library
Loading
Loading