Merge pull request #3 from parnexcodes/test-release-workflow #8
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 Nimbus | |
on: | |
push: | |
branches-ignore: | |
- main | |
pull_request: | |
branches-ignore: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Install MinGW-w64 | |
run: sudo apt-get update && sudo apt-get install -y mingw-w64 | |
- name: Add Windows GNU target | |
run: rustup target add x86_64-pc-windows-gnu | |
- name: Build Nimbus | |
run: | | |
chmod +x build.sh | |
./build.sh | |
- name: Set Version | |
id: version | |
run: | | |
VERSION="v0.${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)" | |
echo "::set-output name=version::$VERSION" | |
- name: Create Pre-release | |
if: github.ref != 'refs/heads/main' | |
uses: elgohr/Github-Release-Action@v5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
title: Pre-release ${{ steps.version.outputs.version }} | |
tag: ${{ steps.version.outputs.version }} | |
prerelease: true | |
- name: Upload Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ steps.version.outputs.version }} ./builds/nimbus-linux ./builds/nimbus-windows.exe | |
main-release: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Build Nimbus | |
run: | | |
chmod +x build.sh | |
./build.sh | |
- name: Set Version | |
id: version | |
run: | | |
VERSION="v0.${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)" | |
echo "::set-output name=version::$VERSION" | |
- name: Create Release | |
uses: elgohr/Github-Release-Action@v5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
title: Release ${{ steps.version.outputs.version }} | |
tag: ${{ steps.version.outputs.version }} | |
- name: Upload Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload ${{ steps.version.outputs.version }} ./builds/nimbus-linux ./builds/nimbus-windows.exe |