name: CD
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-release:
name: Build Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: catenary
asset_name: catenary-linux-amd64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: catenary
asset_name: catenary-macos-amd64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: catenary
asset_name: catenary-macos-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: catenary.exe
asset_name: catenary-windows-amd64.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Rename and Prepare Asset
shell: bash
run: |
cd target/${{ matrix.target }}/release
cp ${{ matrix.artifact_name }} ../../../${{ matrix.asset_name }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: ${{ matrix.asset_name }}
create-release:
name: Create Release
needs: build-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: true
fail_on_unmatched_files: true
publish-crate:
name: Publish to Crates.io
needs: build-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish Crates
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
# Subcrates: skip if version already published
cargo publish -p catenary-proc || echo "catenary-proc: already published, skipping"
cargo publish -p catenary-ts || echo "catenary-ts: already published, skipping"
# Wait for crates.io index to propagate
sleep 30
cargo publish --allow-dirty