lines-cli 0.3.6

Counts lines of code, fast.
name: release

on:
  release:
    types: [published]

env:
  RUST_VERSION: "1.70.0"

jobs:
  release:
    runs-on: ${{ matrix.os }}
    permissions:
      contents: write
    env:
      ASSET: ""
      CARGO: cargo
    strategy:
      matrix:
        build:
          - freebsd-x86_64
          - linux-arm64-gnu
          - linux-arm64-musl
          - linux-x86_64-gnu
          - linux-x86_64-musl
          - macos-arm64
          - macos-x86_64
          - windows-x86_64-msvc
        include:
          - build: freebsd-x86_64
            os: ubuntu-22.04
            target: x86_64-unknown-freebsd
          - build: linux-arm64-gnu
            os: ubuntu-22.04
            target: aarch64-unknown-linux-gnu
          - build: linux-arm64-musl
            os: ubuntu-22.04
            target: aarch64-unknown-linux-musl
          - build: linux-x86_64-gnu
            os: ubuntu-22.04
            target: x86_64-unknown-linux-gnu
          - build: linux-x86_64-musl
            os: ubuntu-22.04
            target: x86_64-unknown-linux-musl
          - build: macos-x86_64
            os: macos-12
            target: x86_64-apple-darwin
          - build: macos-arm64
            os: macos-12
            target: aarch64-apple-darwin
          - build: windows-x86_64-msvc
            os: windows-2022
            target: x86_64-pc-windows-msvc
    steps:
      - uses: actions/checkout@v3

      - name: Set up Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ env.RUST_VERSION }}
          target: ${{ matrix.target }}

      - name: Install cross
        if: ${{ matrix.os == 'ubuntu-22.04' }}
        run: |
          cargo install cross
          echo CARGO=cross >> $GITHUB_ENV

      - name: Rust cargo build
        run: ${{ env.CARGO }} build --release --locked --target ${{ matrix.target }}

      - name: Build archive
        if: ${{ matrix.os != 'windows-2022' }}
        shell: bash
        run: |
          staging="lines-${{ github.ref_name }}-${{ matrix.target }}"
          cp "target/${{ matrix.target }}/release/lines" lines
          tar czf "$staging.tar.gz" lines
          echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV

      - name: Build archive
        if: ${{ matrix.os == 'windows-2022' }}
        shell: bash
        run: |
          staging="lines-${{ github.ref_name }}-${{ matrix.target }}"
          cp "target/${{ matrix.target }}/release/lines.exe" lines.exe
          7z a "$staging.zip" lines.exe
          echo "ASSET=$staging.zip" >> $GITHUB_ENV

      - name: Upload release archive
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh release upload ${{ github.ref_name }} ${{ env.ASSET }}