A bunch of CI improvements #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: | |
push: | |
branches: [main] | |
pull_request: # TODO: Don't do this on PR's | |
workflow_dispatch: | |
jobs: | |
changes: | |
name: Detect changes | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
updater: ${{ steps.filter.outputs.updater }} | |
rust: ${{ steps.filter.outputs.rust }} | |
steps: | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
updater: | |
- 'apps/updater/**' | |
rust: | |
- 'apps/mattrax/**' | |
- 'apps/mattraxd/**' | |
- 'apps/mttx/**' | |
- 'crates/**' | |
- Cargo.toml | |
- Cargo.lock | |
updater: | |
name: Updater | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.updater == 'true' }} | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy to Deno Deploy | |
uses: denoland/deployctl@v1 | |
with: | |
project: mattrax-updater | |
entrypoint: src/main.ts | |
root: apps/updater | |
rust: | |
name: Rust | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.updater == 'true' }} | |
strategy: | |
matrix: | |
# TODO: Build for macOS, Linux, and Windows | |
target: [unknown-linux-gnu, apple-darwin, windows-gnu] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: "true" | |
- name: Install Zig toolchain | |
uses: korandoru/setup-zig@v1 | |
with: | |
zig-version: 0.12.0 | |
- name: | |
Install 'cargo-zigbuild' | |
# The Rust cache action is not happy with `cargo bininstall` so we do a manual install. | |
run: | | |
curl -s https://api.github.com/repos/rust-cross/cargo-zigbuild/releases/latest \ | |
| grep "browser_download_url.*.x86_64-unknown-linux-musl.tar.gz\"" \ | |
| cut -d : -f 2,3 \ | |
| tr -d \" \ | |
| wget -qi - | |
tar -xf cargo-zigbuild-*.tar.gz | |
mv cargo-zigbuild /usr/local/bin | |
- name: Add 'aarch64-${{ matrix.target }}' target | |
run: rustup target add aarch64-${{ matrix.target }} | |
- name: Add 'x86_64-${{ matrix.target }}' target | |
run: rustup target add x86_64-${{ matrix.target }} | |
- name: Build (x86_64) | |
run: cargo zigbuild --locked --release --target aarch64-${{ matrix.target }} | |
- name: Build (arm64) | |
run: cargo zigbuild --locked --release --target x86_64-${{ matrix.target }} | |
# TODO: Upload to R2 | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: rust | |
steps: | |
- run: echo "Hello World" | |
# TODO: Cloudflare workers deploy |