|
1 |
| -name: Go |
2 |
| -on: |
3 |
| - push: |
4 |
| - paths-ignore: |
5 |
| - - 'README.md' |
6 |
| - - 'sq.json' |
7 |
| - branches: |
8 |
| - - master |
9 |
| - |
10 |
| - pull_request: |
11 |
| - paths-ignore: |
12 |
| - - 'README.md' |
13 |
| - - 'sq.json' |
14 |
| - branches: |
15 |
| - - master |
| 1 | +name: Main pipeline |
| 2 | +on: push |
| 3 | + |
| 4 | +env: |
| 5 | + GO_VERSION: 1.19.3 |
| 6 | + GORELEASER_VERSION: 1.12.3 |
16 | 7 |
|
17 | 8 | jobs:
|
18 |
| - build: |
| 9 | + go-test: |
19 | 10 | strategy:
|
20 | 11 | matrix:
|
21 |
| - os: [ macos-latest, ubuntu-latest, windows-latest] |
| 12 | + os: [ macos-12, ubuntu-22.04, windows-2022] |
22 | 13 |
|
23 | 14 | runs-on: ${{ matrix.os }}
|
24 | 15 |
|
25 | 16 | steps:
|
26 |
| - - name: Set up Go 1.19 |
27 |
| - uses: actions/setup-go@v1 |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v3 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Set up Go |
| 23 | + uses: actions/setup-go@v3 |
28 | 24 | with:
|
29 |
| - go-version: 1.19 |
30 |
| - id: go |
| 25 | + go-version: ${{ env.GO_VERSION }} |
| 26 | + |
| 27 | + - name: Build |
| 28 | + run: go build -v ./... |
31 | 29 |
|
32 |
| - - name: Check out code into the Go module directory |
33 |
| - uses: actions/checkout@v2 |
| 30 | + - name: Test |
| 31 | + run: go test -v ./... |
| 32 | + |
| 33 | + goreleaser-gate: |
| 34 | + needs: go-test |
| 35 | + runs-on: ubuntu-22.04 |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Gate |
| 39 | + run: echo "GoReleaser gate" |
| 40 | + |
| 41 | + build-binaries-darwin: |
| 42 | + needs: goreleaser-gate |
| 43 | + runs-on: macos-12 |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v3 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + |
| 51 | + - name: Set up Go |
| 52 | + uses: actions/setup-go@v3 |
| 53 | + with: |
| 54 | + go-version: ${{ env.GO_VERSION }} |
| 55 | + |
| 56 | + - name: GoReleaser (build darwin binaries) |
| 57 | + uses: goreleaser/goreleaser-action@v3 |
| 58 | + with: |
| 59 | + distribution: goreleaser-pro |
| 60 | + version: ${{ env.GORELEASER_VERSION }} |
| 61 | + args: build --skip-validate --rm-dist -f .goreleaser-darwin.yml |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} |
| 64 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
| 65 | + |
| 66 | + - name: Upload assets (darwin) |
| 67 | + uses: actions/upload-artifact@v3 |
| 68 | + with: |
| 69 | + name: dist-darwin |
| 70 | + path: dist-darwin |
| 71 | + |
| 72 | + build-binaries-linux-amd64: |
| 73 | + needs: goreleaser-gate |
| 74 | + runs-on: ubuntu-22.04 |
| 75 | + |
| 76 | + steps: |
| 77 | + - name: Checkout |
| 78 | + uses: actions/checkout@v3 |
| 79 | + with: |
| 80 | + fetch-depth: 0 |
| 81 | + |
| 82 | + - name: Set up Go |
| 83 | + uses: actions/setup-go@v3 |
| 84 | + with: |
| 85 | + go-version: ${{ env.GO_VERSION }} |
| 86 | + |
| 87 | + - name: GoReleaser (build linux-amd64 binaries) |
| 88 | + uses: goreleaser/goreleaser-action@v3 |
| 89 | + with: |
| 90 | + distribution: goreleaser-pro |
| 91 | + version: ${{ env.GORELEASER_VERSION }} |
| 92 | + args: build --skip-validate --rm-dist -f .goreleaser-linux-amd64.yml |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} |
| 95 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
| 96 | + |
| 97 | + - name: Upload assets (linux-amd64) |
| 98 | + uses: actions/upload-artifact@v3 |
| 99 | + with: |
| 100 | + name: dist-linux-amd64 |
| 101 | + path: dist-linux |
| 102 | + |
| 103 | + build-binaries-linux-arm64: |
| 104 | + needs: goreleaser-gate |
| 105 | + runs-on: ubuntu-22.04 |
| 106 | + |
| 107 | + steps: |
| 108 | + - name: Checkout |
| 109 | + uses: actions/checkout@v3 |
| 110 | + with: |
| 111 | + fetch-depth: 0 |
34 | 112 |
|
35 |
| - - name: Cache Go dependencies |
36 |
| - uses: actions/cache@v2 |
| 113 | + - name: Set up Go |
| 114 | + uses: actions/setup-go@v3 |
37 | 115 | with:
|
38 |
| - path: ~/go/pkg/mod |
39 |
| - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
40 |
| - restore-keys: | |
41 |
| - ${{ runner.os }}-go- |
| 116 | + go-version: ${{ env.GO_VERSION }} |
42 | 117 |
|
43 |
| - - name: Get dependencies |
| 118 | + - name: Install toolchain dependencies |
44 | 119 | run: |
|
45 |
| - go get -v -t -d ./... |
| 120 | + sudo apt update |
| 121 | + sudo apt install -y gcc-aarch64-linux-gnu |
46 | 122 |
|
47 |
| - - name: Build |
48 |
| - run: go build -v . |
| 123 | + - name: GoReleaser (build linux-arm64 binaries) |
| 124 | + uses: goreleaser/goreleaser-action@v3 |
| 125 | + with: |
| 126 | + distribution: goreleaser-pro |
| 127 | + version: ${{ env.GORELEASER_VERSION }} |
| 128 | + args: build --skip-validate --rm-dist -f .goreleaser-linux-arm64.yml |
| 129 | + env: |
| 130 | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} |
| 131 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
49 | 132 |
|
50 |
| - - name: Test |
51 |
| - run: go test -short -v ./... |
| 133 | + - name: Upload assets (linux-arm64) |
| 134 | + uses: actions/upload-artifact@v3 |
| 135 | + with: |
| 136 | + name: dist-linux-arm64 |
| 137 | + path: dist-linux |
| 138 | + |
| 139 | + |
| 140 | + build-binaries-windows: |
| 141 | + needs: goreleaser-gate |
| 142 | + runs-on: windows-2022 |
| 143 | + |
| 144 | + steps: |
| 145 | + - name: Checkout |
| 146 | + uses: actions/checkout@v3 |
| 147 | + with: |
| 148 | + fetch-depth: 0 |
| 149 | + |
| 150 | + - name: Set up Go |
| 151 | + uses: actions/setup-go@v3 |
| 152 | + with: |
| 153 | + go-version: ${{ env.GO_VERSION }} |
| 154 | + |
| 155 | + - name: GoReleaser (build windows binaries) |
| 156 | + uses: goreleaser/goreleaser-action@v3 |
| 157 | + with: |
| 158 | + distribution: goreleaser-pro |
| 159 | + version: ${{ env.GORELEASER_VERSION }} |
| 160 | + args: build --skip-validate --rm-dist -f .goreleaser-windows.yml |
| 161 | + env: |
| 162 | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} |
| 163 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
| 164 | + |
| 165 | + |
| 166 | + - name: Upload assets (windows) |
| 167 | + uses: actions/upload-artifact@v3 |
| 168 | + with: |
| 169 | + name: dist-windows |
| 170 | + path: dist-windows |
| 171 | + |
| 172 | + publish: |
| 173 | + if: startsWith(github.ref, 'refs/tags/v') # Only run this if it's a tag, e.g. v1.0.1 |
| 174 | + needs: [ build-binaries-darwin, build-binaries-linux-amd64, build-binaries-linux-arm64, build-binaries-windows ] |
| 175 | + runs-on: ubuntu-22.04 |
| 176 | + |
| 177 | + steps: |
| 178 | + - name: Checkout |
| 179 | + uses: actions/checkout@v3 |
| 180 | + with: |
| 181 | + fetch-depth: 0 |
| 182 | + |
| 183 | + - name: Set up Go |
| 184 | + uses: actions/setup-go@v3 |
| 185 | + with: |
| 186 | + go-version: ${{ env.GO_VERSION }} |
| 187 | + |
| 188 | + - name: Download darwin artifacts |
| 189 | + uses: actions/download-artifact@v3 |
| 190 | + with: |
| 191 | + name: dist-darwin |
| 192 | + path: dist-darwin |
| 193 | + |
| 194 | + - name: Download linux-amd64 artifacts |
| 195 | + uses: actions/download-artifact@v3 |
| 196 | + with: |
| 197 | + name: dist-linux-amd64 |
| 198 | + path: dist-linux |
| 199 | + |
| 200 | + - name: Download linux-arm64 artifacts |
| 201 | + uses: actions/download-artifact@v3 |
| 202 | + with: |
| 203 | + name: dist-linux-arm64 |
| 204 | + path: dist-linux |
| 205 | + |
| 206 | + - name: Download windows artifacts |
| 207 | + uses: actions/download-artifact@v3 |
| 208 | + with: |
| 209 | + name: dist-windows |
| 210 | + path: dist-windows |
| 211 | + |
| 212 | + - name: GoReleaser (publish) |
| 213 | + uses: goreleaser/goreleaser-action@v3 |
| 214 | + with: |
| 215 | + distribution: goreleaser-pro |
| 216 | + version: ${{ env.GORELEASER_VERSION }} |
| 217 | + args: release -f .goreleaser.yml |
| 218 | + env: |
| 219 | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} |
| 220 | + GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} |
| 221 | + FURY_TOKEN: ${{ secrets.FURY_TOKEN }} |
0 commit comments