|
1 | 1 | name: Build Binaries |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_run: |
5 | | - workflows: ["build"] |
6 | | - types: [completed] |
7 | | - branches: [main, develop] |
8 | | - workflow_dispatch: |
| 4 | + workflow_run: |
| 5 | + workflows: ["build"] |
| 6 | + types: [completed] |
| 7 | + branches: [main, develop] |
| 8 | + workflow_dispatch: |
9 | 9 |
|
10 | 10 | permissions: |
11 | 11 | contents: read |
12 | 12 | actions: read |
13 | 13 | checks: read |
14 | 14 |
|
15 | 15 | env: |
16 | | - GO_VERSION: "1.25.1" |
| 16 | + GO_VERSION: "1.25.1" |
17 | 17 |
|
18 | 18 | jobs: |
19 | | - build-binaries: |
20 | | - name: Build Multi-Platform Binaries |
21 | | - runs-on: ubuntu-latest |
22 | | - if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch')) }} |
23 | | - strategy: |
24 | | - matrix: |
25 | | - include: |
26 | | - - os: linux |
27 | | - arch: amd64 |
28 | | - output: github-repo-linux-amd64 |
29 | | - - os: linux |
30 | | - arch: arm64 |
31 | | - output: github-repo-linux-arm64 |
32 | | - - os: darwin |
33 | | - arch: amd64 |
34 | | - output: github-repo-darwin-amd64 |
35 | | - - os: darwin |
36 | | - arch: arm64 |
37 | | - output: github-repo-darwin-arm64 |
38 | | - - os: windows |
39 | | - arch: amd64 |
40 | | - output: github-repo-windows-amd64.exe |
41 | | - steps: |
42 | | - - name: Check if lint workflow passed |
43 | | - if: github.event_name == 'workflow_run' |
44 | | - uses: actions/github-script@v7 |
45 | | - with: |
46 | | - script: | |
47 | | - const { data: runs } = await github.rest.actions.listWorkflowRuns({ |
48 | | - owner: context.repo.owner, |
49 | | - repo: context.repo.repo, |
50 | | - workflow_id: 'lint.yaml', |
51 | | - head_sha: '${{ github.event.workflow_run.head_sha }}', |
52 | | - per_page: 1 |
53 | | - }); |
54 | | - if (runs.workflow_runs.length > 0 && runs.workflow_runs[0].conclusion !== 'success') { |
55 | | - core.setFailed('Lint workflow did not pass'); |
56 | | - } |
57 | | - - name: Checkout code |
58 | | - uses: actions/checkout@v5 |
59 | | - with: |
60 | | - persist-credentials: false |
| 19 | + build-binaries: |
| 20 | + name: Build Multi-Platform Binaries |
| 21 | + runs-on: ubuntu-latest |
| 22 | + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch')) }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - os: linux |
| 27 | + arch: amd64 |
| 28 | + output: github-repo-linux-amd64 |
| 29 | + - os: linux |
| 30 | + arch: arm64 |
| 31 | + output: github-repo-linux-arm64 |
| 32 | + - os: darwin |
| 33 | + arch: amd64 |
| 34 | + output: github-repo-darwin-amd64 |
| 35 | + - os: darwin |
| 36 | + arch: arm64 |
| 37 | + output: github-repo-darwin-arm64 |
| 38 | + - os: windows |
| 39 | + arch: amd64 |
| 40 | + output: github-repo-windows-amd64.exe |
| 41 | + steps: |
| 42 | + - name: Check if lint workflow passed |
| 43 | + if: github.event_name == 'workflow_run' |
| 44 | + uses: actions/github-script@v7 |
| 45 | + with: |
| 46 | + script: | |
| 47 | + const { data: runs } = await github.rest.actions.listWorkflowRuns({ |
| 48 | + owner: context.repo.owner, |
| 49 | + repo: context.repo.repo, |
| 50 | + workflow_id: 'lint.yaml', |
| 51 | + head_sha: '${{ github.event.workflow_run.head_sha }}', |
| 52 | + per_page: 1 |
| 53 | + }); |
| 54 | + if (runs.workflow_runs.length > 0 && runs.workflow_runs[0].conclusion !== 'success') { |
| 55 | + core.setFailed('Lint workflow did not pass'); |
| 56 | + } |
| 57 | + - name: Checkout code |
| 58 | + uses: actions/checkout@v5 |
| 59 | + with: |
| 60 | + persist-credentials: false |
61 | 61 |
|
62 | | - - name: Set up Go |
63 | | - uses: actions/setup-go@v5 |
64 | | - with: |
65 | | - go-version: ${{ env.GO_VERSION }} |
| 62 | + - name: Set up Go |
| 63 | + uses: actions/setup-go@v5 |
| 64 | + with: |
| 65 | + go-version: ${{ env.GO_VERSION }} |
66 | 66 |
|
67 | | - - name: Build binary for ${{ matrix.os }}/${{ matrix.arch }} |
68 | | - env: |
69 | | - GOOS: ${{ matrix.os }} |
70 | | - GOARCH: ${{ matrix.arch }} |
71 | | - CGO_ENABLED: 0 |
72 | | - VERSION: ${{ github.event_name == 'workflow_dispatch' && github.ref_name || github.event.workflow_run.head_branch || 'unknown' }} |
73 | | - COMMIT_HASH: ${{ github.event_name == 'workflow_dispatch' && github.sha || github.event.workflow_run.head_sha || github.sha }} |
74 | | - OUTPUT_NAME: ${{ matrix.output }} |
75 | | - run: | |
76 | | - go build -ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.GitCommitHash=${COMMIT_HASH}' -X 'main.BuiltAt=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" -o "${OUTPUT_NAME}" |
| 67 | + - name: Build binary for ${{ matrix.os }}/${{ matrix.arch }} |
| 68 | + env: |
| 69 | + GOOS: ${{ matrix.os }} |
| 70 | + GOARCH: ${{ matrix.arch }} |
| 71 | + CGO_ENABLED: 0 |
| 72 | + VERSION: ${{ github.event_name == 'workflow_dispatch' && github.ref_name || github.event.workflow_run.head_branch || 'unknown' }} |
| 73 | + COMMIT_HASH: ${{ github.event_name == 'workflow_dispatch' && github.sha || github.event.workflow_run.head_sha || github.sha }} |
| 74 | + OUTPUT_NAME: ${{ matrix.output }} |
| 75 | + run: | |
| 76 | + go build -ldflags="-s -w -X 'main.Version=${VERSION}' -X 'main.GitCommitHash=${COMMIT_HASH}' -X 'main.BuiltAt=$(date -u +%Y-%m-%dT%H:%M:%SZ)'" -o "${OUTPUT_NAME}" |
77 | 77 |
|
78 | | - - name: Upload binary artifact |
79 | | - uses: actions/upload-artifact@v4 |
80 | | - with: |
81 | | - name: ${{ matrix.output }} |
82 | | - path: ${{ matrix.output }} |
83 | | - retention-days: 30 |
| 78 | + - name: Upload binary artifact |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: ${{ matrix.output }} |
| 82 | + path: ${{ matrix.output }} |
| 83 | + retention-days: 30 |
0 commit comments