ci: update release process with release-please #62
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: Release binaries | |
on: | |
workflow_call: | |
inputs: | |
tag: | |
type: string | |
description: 'The tag to use for the Docker image.' | |
required: true | |
workflow_dispatch: | |
inputs: | |
prerelease_name: | |
description: "Suffix to use for manual pre-release." | |
required: false | |
type: string | |
default: "" | |
pull_request: | |
jobs: | |
build: | |
name: Build binaries | |
strategy: | |
matrix: | |
include: | |
- arch: x86_64-unknown-linux-gnu | |
platform: ubuntu-24.04 | |
- arch: aarch64-unknown-linux-gnu | |
platform: ubuntu-24.04 | |
- arch: x86_64-apple-darwin | |
platform: macos-latest | |
- arch: aarch64-apple-darwin | |
platform: macos-latest | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.tag || '' }} | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
rustflags: "" | |
- name: Install target | |
run: rustup target add ${{ matrix.arch }} | |
- name: Install cross v0.2.5 from source | |
run: cargo install cross --git https://github.com/cross-rs/cross --tag v0.2.5 | |
- name: Build anvil-zksync for ${{ matrix.arch }} | |
run: | | |
[[ "${{ matrix.arch }}" == *"linux"* ]] && make build-static-${{ matrix.arch }} || make build-${{ matrix.arch }} | |
- name: Pack anvil-zksync | |
run: | | |
tar -czf anvil-zksync-${{ inputs.tag || 'v0.0.0' }}-${{ matrix.arch }}.tar.gz \ | |
./target/${{ matrix.arch }}/release/anvil-zksync | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: anvil-zksync-${{ matrix.arch }} | |
path: | | |
anvil-zksync-${{ inputs.tag || 'v0.0.0' }}-${{ matrix.arch }}.tar.gz | |
./target/${{ matrix.arch }}/release/anvil-zksync | |
upload-binaries: | |
name: Upload binaries | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
attestations: write | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.tag || '' }} | |
- name: Define release name | |
id: release_tag | |
shell: 'bash -ex {0}' | |
run: | | |
[ ! -z "${{ inputs.tag }}" ] && TAG="${{ inputs.tag }}" \ | |
|| TAG="$(git rev-parse --short HEAD)" | |
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}" | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: "anvil-zksync-*" | |
path: artifacts | |
- name: Binaries attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-path: 'artifacts/**/anvil-zksync' | |
- name: Update release-please release artifacts | |
if: ${{ inputs.tag != '' }} | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ inputs.tag }} | |
files: 'artifacts/**/anvil-zksync*.tar.gz' | |
- name: Create release | |
if: ${{ inputs.tag == '' }} | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: 'anvil-zksync ${{ inputs.prerelease_name}} ${{ steps.release_tag.outputs.tag }}' | |
tag_name: ${{ steps.release_tag.outputs.tag }} | |
prerelease: true | |
files: 'artifacts/**/anvil-zksync*.tar.gz' |