name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
plan:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: none
outputs:
val: ${{ steps.plan.outputs.manifest }}
tag: ${{ !github.event.pull_request.head.sha && github.ref_name || '' }}
tag-flag: ${{ !github.event.pull_request.head.sha && format('--tag={0}', github.ref_name) || '' }}
publishing: ${{ !github.event.pull_request.head.sha }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
- id: plan
run: |
cargo dist plan ${{ !github.event.pull_request.head.sha && format('--tag={0}', github.ref_name) || '' }} --output-format=json > dist-manifest.json
echo "manifest=$(cat dist-manifest.json)" >> "$GITHUB_OUTPUT"
- name: Store manifest
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: dist-manifest.json
path: dist-manifest.json
build-local-artifacts:
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
needs:
- plan
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != '' }}
permissions:
contents: read
id-token: none
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
runs-on: ${{ matrix.runner }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: dist-manifest-${{ matrix.idx }}.json
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
submodules: recursive
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 - name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
- name: Build artifacts
run: cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
- name: Generate Syft SBOMs
shell: bash
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b "$HOME/.local/bin"
find dist -maxdepth 1 -type f -print0 | while IFS= read -r -d '' artifact; do
"$HOME/.local/bin/syft" "file:${artifact}" -o cyclonedx-json > "${artifact}.sbom.cdx.json"
done
- name: Store manifest
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: ${{ env.BUILD_MANIFEST_NAME }}
path: dist-manifest.json
- name: Upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: artifacts-${{ matrix.idx }}
path: dist/
host:
needs:
- plan
- build-local-artifacts
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.27.0/cargo-dist-installer.sh | sh"
- name: Collect artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 with:
pattern: artifacts-*
path: dist/
merge-multiple: true
- name: Collect manifests
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 with:
pattern: dist-manifest-*.json
merge-multiple: true
- name: Host artifacts
run: cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json