aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: ae8f4a0b2725c5966ca0ce1bd7aff9946e87e166 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Build binary

on:
  push:
    tags:
      - v**
  pull_request:

jobs:
  build:
    strategy:
      fail-fast: true
      matrix:
        job:
          - { os: macos-latest }
          - { os: ubuntu-latest }


    name: Build
    runs-on: ${{ matrix.job.os }}
    steps:
      - uses: actions/[email protected]
      - uses: actions-rs/[email protected]
        with:
          profile: minimal
          toolchain: stable
          override: true
      - uses: actions-rs/[email protected]
        with:
          command: build
          args: --release
      - name: Rename binary
        id: rename
        shell: bash
        run: |
          if [ "$RUNNER_OS" == "Linux" ]; then
            BIN='cgit-simple-authentication_linux_amd64'
            mv target/release/cgit-simple-authentication target/release/$BIN
          elif [ "$RUNNER_OS" == "macOS" ]; then
            BIN='cgit-simple-authentication_darwin_amd64'
            mv target/release/cgit-simple-authentication target/release/$BIN
          else
            BIN='cgit-simple-authentication_windows_amd64.exe'
            mv target/release/cgit-simple-authentication.exe target/release/$BIN
          fi
          echo "::set-output name=bin::target/release/$BIN"
      - uses: actions/[email protected]
        with:
          name: artifact
          path: |
            target/release/cgit-simple-authentication_*
      - name: Release
        uses: softprops/[email protected]
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: ${{ steps.rename.outputs.bin }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}