ci:rename rust.yml to build.yml && misc #33
Workflow file for this run
This file contains hidden or 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 Binaries | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
build: | |
name: Build Binary | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
include: | |
- os: ubuntu-latest | |
artifact_name: aw-watcher-lastfm-linux | |
- os: macos-latest | |
artifact_name: aw-watcher-lastfm-macos | |
- os: windows-latest | |
artifact_name: aw-watcher-lastfm-windows.exe | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build project | |
run: cargo build --release | |
- name: Rename binary | |
shell: bash | |
run: | | |
cd target/release | |
if [ "${{ matrix.os }}" == "windows-latest" ]; then | |
mv aw-watcher-lastfm.exe ${{ matrix.artifact_name }} | |
else | |
mv aw-watcher-lastfm ${{ matrix.artifact_name }} | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.artifact_name }} | |
path: target/release/${{ matrix.artifact_name }} | |
release: | |
name: Create Release | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: rename and zip artifacts | |
run: | | |
cd artifacts | |
for file in */*; do | |
if [[ $file == *"windows"* ]]; then | |
mv "$file" aw-watcher-lastfm.exe | |
zip "aw-watcher-lastfm-windows.zip" aw-watcher-lastfm.exe | |
rm aw-watcher-lastfm.exe | |
else | |
mv "$file" aw-watcher-lastfm | |
zip "${file%/*}.zip" aw-watcher-lastfm | |
rm aw-watcher-lastfm | |
fi | |
done | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
name: Release ${{ github.ref_name }} | |
draft: true | |
prerelease: false | |
files: | | |
artifacts/*.zip |