Attach MVR binaries to a release #26
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: Attach MVR binaries to a release | |
run-name: Attach MVR binaries to a ${{ inputs.mvr_tag }} release | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
env: | |
TAG_NAME: "${{ github.event.inputs.mvr_tag || github.ref }}" | |
CARGO_TERM_COLOR: always | |
# Disable incremental compilation. | |
# | |
# Incremental compilation is useful as part of an edit-build-test-edit cycle, | |
# as it lets the compiler avoid recompiling code that hasn't changed. However, | |
# on CI, we're not making small edits; we're almost always building the entire | |
# project from scratch. Thus, incremental compilation on CI actually | |
# introduces *additional* overhead to support making future builds | |
# faster...but no future builds will ever occur in any given CI environment. | |
# | |
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow | |
# for details. | |
CARGO_INCREMENTAL: 0 | |
# Allow more retries for network requests in cargo (downloading crates) and | |
# rustup (installing toolchains). This should help to reduce flaky CI failures | |
# from transient network timeouts or other issues. | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
# Don't emit giant backtraces in the CI logs. | |
RUST_BACKTRACE: short | |
jobs: | |
release: | |
name: Create GitHub Release | |
runs-on: ubuntu-latest | |
steps: | |
# Check out the repository | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# Create a release on GitHub | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: Release ${{ github.ref_name }} | |
generate_release_notes: true | |
build: | |
needs: release | |
name: Build & Publish Binaries | |
timeout-minutes: 120 | |
strategy: | |
matrix: | |
os: [ | |
ubuntu-ghcloud, # ubuntu-x86_64 | |
ubuntu-arm64, # ubuntu-arm64 | |
windows-ghcloud, # windows-x86_64 | |
macos-latest-xl, # macos-x86_64 | |
macos-latest-xlarge, # macos-arm64 | |
] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Clean up and validate ${{ env.TAG_NAME }} tag name | |
shell: bash | |
run: | | |
export mvr_tag=$(echo ${{ env.TAG_NAME }} | sed s/'refs\/tags\/'//) | |
[[ "${mvr_tag}" == "main" ]] && echo "tag cannot be equals to 'main'" && exit 1 | |
echo "mvr_tag=${mvr_tag}" >> $GITHUB_ENV | |
export mvr_version=$(echo ${mvr_tag} ) | |
echo "mvr_version=${mvr_version}" >> $GITHUB_ENV | |
- name: Check out ${{ env.mvr_tag }} | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3 | |
with: | |
ref: ${{ env.mvr_tag }} | |
- name: Set os/arch variables (Windows) | |
if: ${{ matrix.os == 'windows-ghcloud' }} | |
shell: bash | |
run: | | |
export arch=$(uname -m) | |
export os_type="windows-${arch}" | |
echo "os_type=${os_type}" >> $GITHUB_ENV | |
echo "extension=$(echo ".exe")" >> $GITHUB_ENV | |
- name: Set os/arch variables | |
if: ${{ matrix.os != 'windows-ghcloud' }} | |
shell: bash | |
run: | | |
export arch=$(uname -m) | |
export system_os=$(echo ${{ matrix.os }} | cut -d- -f1) | |
export os_type="${system_os}-${arch}" | |
echo "os_type=${system_os}-${arch}" >> $GITHUB_ENV | |
- name: Cargo build for ${{ matrix.os }} platform | |
shell: bash | |
run: | | |
[ -f ~/.cargo/env ] && source ~/.cargo/env | |
cargo build --release | |
cp target/release/mvr${{ env.extension }} target/release/mvr-${{ env.os_type }}${{ env.extension }} | |
- name: Attach artifacts to ${{ env.mvr_tag }} release in GH | |
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1 | |
with: | |
files: | | |
target/release/mvr-${{ env.os_type }}${{ env.extension }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |