Skip to content

Update release.yml

Update release.yml #6

Workflow file for this run

name: Cargo Release Workflow
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
all-go:
name: all systems go
runs-on: ubuntu-latest
needs:
- test
- build
- release
steps:
- run: exit 0
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
architecture: [x64, x86]
toolchain: [stable]
steps:
- uses: actions/checkout@v3
- name: Run Tests
run: cargo test --verbose
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
architecture: [x64, x86]
toolchain: [stable]
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release --verbose
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}-${{ matrix.architecture }}
path: target/release/
release:
needs:
- test
- build
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
architecture: [ x64, x86 ]
toolchain: [ stable ]
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Set Build File Variables
id: vars
run: |
name=$(awk -F '= ' '/^\[package\]/{found=1} found && /^name/{gsub(/["]/, "", $2); print $2; exit}' Cargo.toml)
echo "name=$name" >> $GITHUB_OUTPUT
os="${{ matrix.os }}"
os_sans_latest=$(echo "$os" | sed 's/-latest//')
echo "os=$os_sans_latest" >> $GITHUB_OUTPUT
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
echo "ext=.exe" >> $GITHUB_OUTPUT
else
echo "ext=" >> $GITHUB_OUTPUT
fi
- name: Prepare Artifacts
run: |
source=${{ matrix.os }}-${{ matrix.architecture }}/${{ steps.vars.outputs.name }}${{ steps.vars.outputs.ext }}
target=bin/${{ steps.vars.outputs.name }}-${{ steps.vars.outputs.os }}-${{ matrix.architecture }}${{ steps.vars.outputs.ext }}
mkdir bin
mv $source $target
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
bin/${{ steps.vars.outputs.name }}-${{ steps.vars.outputs.os }}-${{ matrix.architecture }}${{ steps.vars.outputs.ext }}