Update rust.yml #9
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 and Release | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build | |
run: | | |
if [[ runner.os == 'Linux' ]]; then | |
cargo build --release | |
elif [[ runner.os == 'macos' ]]; then | |
cargo build --release --target x86_64-apple-darwin | |
elif [[ runner.os == 'windows' ]]; then | |
cargo build --release --target x86_64-pc-windows-gnu | |
fi | |
- name: Upload Release Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ runner.os }}-bin | |
path: target/${{ matrix.os }}-x86_64/release | |
release: | |
needs: build | |
runs-on: ubuntu-latest # Can be any OS | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Artifacts | |
run: | | |
for os in ubuntu-latest macos-latest windows-latest; do | |
curl -LJO "https://github.com/${{ github.repository }}/actions/artifacts/${{ github.run_id }}/downloads/${os}-bin.zip" | |
done | |
- name: Create Release | |
uses: nlopes/release-action@v4 | |
with: | |
tag_name: ${{ github.ref }} # Use pushed tag name | |
release_name: "Release - ${{ github.sha }} (built on ${{ format('{:%Y-%m-%d}', github.event.time) }})" | |
body: | | |
binaries included: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
- name: Extract Artifacts | |
run: | | |
for file in *.zip; do unzip "$file"; done | |
- name: Upload Linux Binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: linux-bin | |
path: ${{ runner.workspace }}/target/linux-x86_64/release | |
- name: Upload macOS Binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: macos-bin | |
path: ${{ runner.workspace }}/target/macos-x86_64/release | |
- name: Upload Windows Binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: windows-bin | |
path: ${{ runner.workspace }}/target/windows-x86_64/release |