name: Build & Release
permissions:
contents: write
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:
inputs:
version:
description: "Add tag version: (e.g. -> v3.6.1)"
required: true
jobs:
pre-release:
uses: ./.github/workflows/pre_release.yaml
with:
tag-version: ${{ inputs.version || github.ref_name }}
create-tag:
needs: pre-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
git pull
git checkout HEAD
- uses: mukunku/tag-exists-action@v1.6.0
id: check-tag
with:
tag: ${{ inputs.version || github.ref_name }}
- name: Create tag
uses: actions/github-script@v7
if: steps.check-tag.outputs.exists == 'false'
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ inputs.version }}',
sha: context.sha
})
create-release:
needs: [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/${{ inputs.version || github.ref_name }}
build-and-release:
needs: [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
- name: Git Pull
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/${{ inputs.version || github.ref_name }}
publish-crate:
needs: [create-tag]
uses: ./.github/workflows/publish.yaml
secrets: inherit