name: Rust
on:
workflow_dispatch:
push:
branches: ["main"]
tags:
- "v*.*.*"
paths:
- "src/**"
- "Cargo.toml"
pull_request:
branches: ["main"]
paths:
- "src/**"
- "Cargo.toml"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --all-targets --all-features --verbose
- name: Run tests
run: cargo test --all-targets --all-features --verbose
build-linux:
needs: [test]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release --all-targets --all-features --verbose
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: iltz-linux-${{ github.ref_name }}
path: target/release/iltz
retention-days: 1
build-macos:
needs: [test]
runs-on: macos-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release --all-targets --all-features --verbose
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: iltz-macos-${{ github.ref_name }}
path: target/release/iltz
retention-days: 1
build-windows:
needs: [test]
runs-on: windows-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release --all-targets --all-features --verbose
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: iltz-windows-${{ github.ref_name }}
path: target/release/iltz.exe
retention-days: 1
release:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
needs: [build-linux, build-macos, build-windows]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: release
- name: Zip release files
run: |
mkdir -p release/${{ github.ref_name }}
zip -9 release/${{ github.ref_name }}/iltz-linux-${{ github.ref_name }}.zip release/iltz-linux-${{ github.ref_name }}/iltz
zip -9 release/${{ github.ref_name }}/iltz-macos-${{ github.ref_name }}.zip release/iltz-macos-${{ github.ref_name }}/iltz
zip -9 release/${{ github.ref_name }}/iltz-windows-${{ github.ref_name }}.zip release/iltz-windows-${{ github.ref_name }}/iltz.exe
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
draft: ${{ github.event_name == 'workflow_dispatch' }}
files: release/${{ github.ref_name }}/*