Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: update release workflow to use platform-specific runners #13

chore: update release workflow to use platform-specific runners

chore: update release workflow to use platform-specific runners #13

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
jobs:
github-release-draft:
name: 'Create GitHub Release Draft'
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Get the version
id: get_version
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT
- name: Create Release Draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.get_version.outputs.VERSION }} \
--title "v${{ steps.get_version.outputs.VERSION }}" \
--draft \
--generate-notes
linux-binary:
name: 'Upload Binary for Linux'
strategy:
matrix:
platform:
- target: x86_64-unknown-linux-musl
runs-on: ubuntu-latest
- target: aarch64-unknown-linux-musl
runs-on: ubuntu-latest-arm
runs-on: ${{ matrix.platform.runs-on }}
needs: github-release-draft
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install dependent packages
run: sudo apt install -y musl-tools
- run: rustup update stable
- run: rustup default stable
- run: rustup target add ${{ matrix.platform.target }}
- run: cargo build --release --target=${{ matrix.platform.target }}
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv target/${{ matrix.platform.target }}/release/sorastats sorastats-${{ needs.github-release-draft.outputs.version }}.${{ matrix.platform.target }}
gh release upload ${{ needs.github-release-draft.outputs.version }} \
sorastats-${{ needs.github-release-draft.outputs.version }}.${{ matrix.platform.target }}
macos-binary:
name: 'Upload Binary for MacOS'
runs-on: macos-latest
needs: github-release-draft
strategy:
matrix:
target: ["x86_64-apple-darwin", "aarch64-apple-darwin"]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- run: rustup update stable
- run: rustup default stable
- run: rustup target add ${{ matrix.target }}
- run: cargo build --release --target=${{ matrix.target }}
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv target/${{ matrix.target }}/release/sorastats sorastats-${{ needs.github-release-draft.outputs.version }}.${{ matrix.target }}
gh release upload ${{ needs.github-release-draft.outputs.version }} \
sorastats-${{ needs.github-release-draft.outputs.version }}.${{ matrix.target }}
publish-crates:
name: 'Publish to crates.io'
runs-on: ubuntu-latest
needs:
- github-release-draft
- linux-binary
- macos-binary
permissions:
id-token: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
- run: rustup update stable
- run: rustup default stable
- name: Authenticate with crates.io
uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}