vpn-kill-switch 0.8.1

VPN kill switch for macOS
Documentation
---
name: Deploy

on:
  push:
    tags:
      - '*'
  workflow_dispatch:

permissions:
  contents: write

jobs:
  test:
    uses: ./.github/workflows/test.yml
    with:
      branch: main

  build:
    name: Build and release
    runs-on: macos-latest
    needs: test

    strategy:
      matrix:
        include:
          - build: macos-x86_64
            target: x86_64-apple-darwin

          - build: macos-aarch64
            target: aarch64-apple-darwin

    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Get the release version from the tag
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Build
        run: cargo build --release --locked --target ${{ matrix.target }}

      - name: Build archive
        shell: bash
        run: |
          binary_name="killswitch"
          dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
          mkdir "$dirname"
          mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
          tar -czf "$dirname.tar.gz" "$dirname"
          echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV

      - name: Release
        if: startsWith(github.ref, 'refs/tags/')
        uses: softprops/action-gh-release@v2
        with:
          files: |-
            ${{ env.ASSET }}

  publish:
    name: Publish
    runs-on: macos-latest
    needs:
      - build
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - run: cargo publish --token ${CRATES_TOKEN}
        env:
          CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

  homebrew:
    name: Bump Homebrew formula
    runs-on: ubuntu-latest
    needs:
      - build
    steps:
      - name: bump-homebrew-formula
        uses: mislav/bump-homebrew-formula-action@v3.1
        with:
          formula-name: killswitch
        env:
          COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}