Skip to content

Commit

Permalink
Update rust.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Melechtna authored Apr 30, 2024
1 parent 289aa73 commit 508e535
Showing 1 changed file with 60 additions and 58 deletions.
118 changes: 60 additions & 58 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,75 @@ on:
branches: [ main ]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Build (Linux)
run: cargo build --release

- 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
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build (macOS)
run: cargo build --release --target x86_64-apple-darwin

- name: Upload Release Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-bin
path: target/${{ matrix.os }}-x86_64/release
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
# Specific Windows build steps if needed (e.g., setting environment variables)
- name: Build (Windows)
run: cargo build --release --target x86_64-pc-windows-gnu

release:
needs: build
upload-artifacts:
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-latest # Can be any OS

steps:
- uses: actions/checkout@v4
- 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: Upload Linux Binary
uses: actions/upload-artifact@v3
with:
name: linux-bin
path: target/linux-x86_64/release

- 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: Upload macOS Binary
uses: actions/upload-artifact@v3
with:
name: macos-bin
path: target/macos-x86_64/release

- name: Extract Artifacts
run: |
for file in *.zip; do unzip "$file"; done
- name: Upload Windows Binary
uses: actions/upload-artifact@v3
with:
name: windows-bin
path: target/windows-x86_64/release

release:
needs: upload-artifacts
runs-on: ubuntu-latest # Can be any OS
steps:
- uses: actions/checkout@v4

- name: Upload Linux Binary
uses: actions/upload-artifact@v3
with:
name: linux-bin
path: ${{ runner.workspace }}/target/linux-x86_64/release
- 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: Upload macOS Binary
uses: actions/upload-artifact@v3
with:
name: macos-bin
path: ${{ runner.workspace }}/target/macos-x86_64/release
- name: Create Release
uses: nlopes/release-action@v2
with:
tag_name: ${{ github.ref }} # Use pushed tag name
release_name: "LBA2SD-$(date +%Y.%m.%d) (built on ${{ format('{:%Y-%m-%d}', github.event.time) }})"
body: |
Binaries included:
- ubuntu-latest
- macos-latest
- windows-latest
- name: Upload Windows Binary
uses: actions/upload-artifact@v3
with:
name: windows-bin
path: ${{ runner.workspace }}/target/windows-x86_64/release
- name: Extract Artifacts
run: |
for file in *.zip; do unzip "$file"; done

0 comments on commit 508e535

Please sign in to comment.