chore(version): amt-macros-v0.2.1 #6
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: Build Release Artifacts | |
on: | |
push: | |
tags: | |
- '**-v[0-9]+.[0-9]+.[0-9]+' | |
workflow_dispatch: | |
jobs: | |
extract-info: | |
runs-on: ubuntu-latest | |
outputs: | |
crate: ${{ steps.extract-crate.outputs.crate }} | |
version: ${{ steps.extract-crate.outputs.version }} | |
steps: | |
- name: Extract Crate and Version | |
id: extract-crate | |
run: | | |
echo "crate=$(echo ${{ github.event.ref }} | sed -E 's/refs\/tags\/(.+)-v[0-9]+\.[0-9]+\.[0-9]+/\1/')" >> "$GITHUB_OUTPUT" | |
echo "version=$(echo ${{ github.event.ref }} | sed -E 's/refs\/tags\/.+-(v[0-9]+\.[0-9]+\.[0-9]+)/\1/')" >> "$GITHUB_OUTPUT" | |
build-artifacts: | |
needs: [extract-info] | |
name: Build ${{ needs.extract-info.outputs.crate }} for ${{ matrix.system }} | |
strategy: | |
fail-fast: false | |
matrix: | |
system: | |
- x86_64-linux | |
- aarch64-linux | |
- x86_64-windows | |
- aarch64-windows | |
- x86_64-darwin | |
- aarch64-darwin | |
runs-on: ${{ endsWith(matrix.system, 'darwin') && 'macos-latest' || 'ubuntu-latest' }} | |
permissions: | |
contents: write | |
outputs: | |
binary: ${{ steps.binary-name.outputs.binary }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
- uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- name: Is there a binary? | |
id: binary-exists | |
run: | | |
metadata=$(nix develop --impure --command cargo metadata --no-deps --format-version 1) | |
has_binary=$(echo "$metadata" | jq -r '.packages | map(select(.targets[].kind[] | contains("bin")) | .name) | any(. == "${{ needs.extract-info.outputs.crate }}")') | |
echo "result=$([[ $has_binary == "true" ]] && echo "success" || echo "failure")" >> "$GITHUB_OUTPUT" | |
# Setup after develop invocation to avoid caching anything other than the build artifacts. | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: amt | |
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
- name: Build Release Artifact for ${{ matrix.system }} | |
run: nix build .#${{ needs.extract-info.outputs.crate }}-${{ matrix.system }}-release -L --accept-flake-config | |
- name: Change the name of the artifact | |
if: steps.binary-exists.outputs.result == 'success' | |
id: binary-name | |
run: | | |
binary=$(find result/bin -type f -exec basename {} \;) | |
updated_binary=$(echo "$binary" | sed -E "s/${{ needs.extract-info.outputs.crate }}/${{ needs.extract-info.outputs.crate }}-${{ matrix.system }}/") | |
cp result/bin/"$binary" /tmp/"$updated_binary" | |
echo "binary=$updated_binary" >> "$GITHUB_OUTPUT" | |
- name: Upload Release Artifact for ${{ matrix.system }} | |
if: steps.binary-exists.outputs.result == 'success' | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: /tmp/${{ steps.binary-name.outputs.binary }} | |
publish-crates-io: | |
name: Publish to crates.io | |
needs: [extract-info, build-artifacts] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cachix/install-nix-action@v30 | |
- uses: DeterminateSystems/magic-nix-cache-action@v8 | |
- name: Publish to crates.io | |
run: | | |
nix develop --impure -c cargo publish \ | |
--locked \ | |
--no-verify \ | |
--token ${{ secrets.CARGO_AUTH_TOKEN }} \ | |
--package ${{ needs.extract-info.outputs.crate }} |