ardent 0.3.3

Opinionated formatter for NSIS scripts
Documentation
name: Release

on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            artifact-name: linux-x64
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            artifact-name: linux-arm64
            use-cross: true
          - target: x86_64-apple-darwin
            os: macos-latest
            artifact-name: darwin-x64
          - target: aarch64-apple-darwin
            os: macos-latest
            artifact-name: darwin-arm64
          - target: x86_64-pc-windows-gnu
            os: ubuntu-latest
            artifact-name: windows-x64
            use-cross: true
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1

      - name: Install Rust toolchain
        if: "!matrix.use-cross"
        run: rustup target add ${{ matrix.target }}

      - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
        with:
          key: ${{ matrix.target }}

      - name: Install cross-compilation tools
        if: matrix.use-cross
        run: cargo install cross

      - name: Build (cross)
        if: matrix.use-cross
        run: cross build --release --target ${{ matrix.target }}

      - name: Build (native)
        if: "!matrix.use-cross"
        run: cargo build --release --target ${{ matrix.target }}

      - name: Get version
        id: version
        run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT

      - name: Create zip
        run: |
          if [[ "${{ matrix.target }}" == *windows* ]]; then
            BIN=ardent.exe
          else
            BIN=ardent
          fi
          zip --junk-paths "ardent-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact-name }}.zip" \
            "target/${{ matrix.target }}/release/${BIN}" LICENSE

      - name: Upload artifact
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        with:
          name: ardent-${{ matrix.artifact-name }}
          path: ardent-*.zip

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          merge-multiple: true

      - name: Create release
        uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
        with:
          files: ardent-*.zip

  publish:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

      - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1

      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}