feat: update GitHub actions and fix code formatting #27
Workflow file for this run
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: release | |
on: | |
push: | |
tags: ["v[0-9]+.[0-9]+.[0-9]+*"] | |
# branches: ["main"] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build: | |
name: ${{ matrix.toolchain.name }} | |
runs-on: ${{ matrix.toolchain.runs_on }} | |
strategy: | |
fail-fast: true | |
matrix: | |
toolchain: | |
- {runs_on: ubuntu-latest, name: "Linux x86_64", archive_name: "linux-x86_64"} | |
- {runs_on: macos-11, name: "macOS x86_64", archive_name: "macos-x86_64"} | |
- {runs_on: macos-14, name: "macOS AArch64", archive_name: "macos-aarch64"} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
- name: Install Dependencies | |
if: ${{ matrix.toolchain.archive_name == 'linux-x86_64' }} | |
run: | | |
sudo apt-get -y update | |
sudo apt-get -y install pandoc | |
- name: Install Dependencies | |
if: ${{ matrix.toolchain.archive_name != 'linux-x86_64' }} | |
run: brew install pandoc | |
- name: format Assets | |
run: cargo fmt --verbose --all --check | |
- name: Lint Assets | |
run: cargo clippy -- -Dwarnings | |
- name: Build Assets | |
run: | | |
cargo build --release | |
cd docs | |
pandoc --standalone --to man nvi.1.md -o nvi.1 | |
- name: Run Tests | |
run: cargo test | |
- name: Compress Assets | |
run: | | |
mkdir -p nvi/bin | |
mkdir -p nvi/man | |
cp ./target/release/nvi nvi/bin/ | |
cp ./docs/nvi.1 nvi/man/ | |
tar -zcvf ./nvi-${{ matrix.toolchain.archive_name }}.tar.gz nvi | |
- name: Upload Assets | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: nvi-${{ matrix.toolchain.archive_name }} | |
path: nvi-${{ matrix.toolchain.archive_name }}.tar.gz | |
retention-days: 1 | |
publish: | |
if: github.event_name != 'pull_request' | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
GH_REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- name: Set Tag Name | |
run: TAG_NAME=${{ github.ref }} | |
- name: Publish Release | |
run: gh release create $TAG_NAME --generate-notes --title "$TAG_NAME" --target $GITHUB_SHA nvi-macos-x86_64/* nvi-macos-aarch64/* nvi-linux-x86_64/* |