aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: ef5e2be69f11a7493ae26f26546ee235e238a9a8 (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
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/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - uses: actions-rs/cargo@v1
        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
          fi
          echo "::set-output name=bin::target/release/$BIN"
      - uses: actions/upload-artifact@v2
        with:
          name: artifact
          path: |
            target/release/cgit-simple-authentication_*
      - name: Release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: ${{ steps.rename.outputs.bin }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}