Build & Release #5
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 | |
permissions: | |
# To upload files to GitHub Releases | |
contents: write | |
on: | |
push: | |
tags: | |
- v[0-9]+.[0-9]+.[0-9]+* | |
workflow_dispatch: | |
inputs: | |
tag-version: | |
type: string | |
description: "Tag version: (e.g. -> v3.6.1)" | |
upload-binaries: | |
type: boolean | |
default: true | |
bump-msrv: | |
type: boolean | |
jobs: | |
tag-name: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- id: get-latest-tag | |
if: ${{ !inputs.tag-version }} | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
outputs: | |
tag: ${{ steps.get-latest-tag.outputs.tag || inputs.tag-version || github.ref_name }} | |
pre-release: | |
needs: tag-name | |
uses: ./.github/workflows/pre_release.yaml | |
with: | |
bump-version: ${{ needs.tag-name.outputs.tag }} | |
bump-msrv: ${{ inputs.bump-msrv }} | |
create-tag: | |
needs: [tag-name, pre-release] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: git pull | |
- uses: mukunku/tag-exists-action@v1.6.0 | |
id: check-tag | |
with: | |
tag: ${{ needs.tag-name.outputs.tag }} | |
- name: Create tag | |
if: steps.check-tag.outputs.exists == 'false' | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git tag ${{ needs.tag-name.outputs.tag }} | |
git push origin ${{ needs.tag-name.outputs.tag }} | |
create-release: | |
needs: [tag-name, create-tag] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch Repository | |
uses: actions/checkout@v4 | |
- uses: taiki-e/create-gh-release-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
changelog: CHANGELOG.md | |
allow-missing-changelog: true | |
ref: refs/tags/${{ needs.tag-name.outputs.tag }} | |
build-and-release: | |
needs: [tag-name, create-release] | |
name: ${{ matrix.target }} (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {os: ubuntu-latest, target: x86_64-unknown-linux-gnu, cross: false} | |
- {os: ubuntu-latest, target: x86_64-unknown-linux-musl, cross: true} | |
- {os: ubuntu-latest, target: aarch64-unknown-linux-gnu, cross: true} | |
- {os: ubuntu-latest, target: aarch64-unknown-linux-musl, cross: true} | |
- {os: windows-latest, target: x86_64-pc-windows-msvc, cross: false} | |
- {os: windows-latest, target: x86_64-pc-windows-gnu, cross: true} | |
- {os: windows-latest, target: aarch64-pc-windows-msvc, cross: false} | |
- {os: macos-latest, target: x86_64-apple-darwin, cross: false} | |
- {os: macos-latest, target: aarch64-apple-darwin, cross: false} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- run: git pull | |
- name: Install stable toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
target: ${{ matrix.target }} | |
- name: Install cross-compilation tools | |
if: ${{ matrix.cross }} == 'true' | |
uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
- uses: taiki-e/upload-rust-binary-action@v1 | |
with: | |
bin: ${{ github.event.repository.name }} | |
target: ${{ matrix.target }} | |
include: attribution | |
archive: $bin-$tag-$target | |
token: ${{ secrets.GITHUB_TOKEN }} | |
ref: refs/tags/${{ needs.tag-name.outputs.tag }} | |
checksum: sha256 | |
dry-run: ${{ !inputs.upload-binaries }} | |
publish-crate: | |
needs: [create-tag] | |
uses: ./.github/workflows/publish.yaml | |
secrets: inherit |