|
1 | 1 | name: "Release" |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
2 | 7 | on: |
3 | 8 | push: |
4 | | - # take no actions on push to any branch... |
5 | | - branches-ignore: |
6 | | - - "**" |
7 | | - # ... only act on release tags |
| 9 | + branches: |
| 10 | + - "main" |
8 | 11 | tags: |
9 | 12 | - "v*" |
| 13 | + pull_request: |
10 | 14 |
|
11 | 15 | env: |
12 | | - GO_VERSION: "1.18.x" |
| 16 | + GO_VERSION: "1.18" |
13 | 17 |
|
14 | 18 | jobs: |
15 | | - quality-gate: |
16 | | - environment: release |
17 | | - runs-on: ubuntu-latest # This OS choice is arbitrary. None of the steps in this job are specific to either Linux or macOS. |
18 | | - steps: |
19 | | - - uses: actions/checkout@v2 |
20 | | - |
21 | | - # we don't want to release commits that have been pushed and tagged, but not necessarily merged onto main |
22 | | - - name: Ensure tagged commit is on main |
23 | | - run: | |
24 | | - echo "Tag: ${GITHUB_REF##*/}" |
25 | | - git fetch origin main |
26 | | - git merge-base --is-ancestor ${GITHUB_REF##*/} origin/main && echo "${GITHUB_REF##*/} is a commit on main!" |
27 | | -
|
28 | | - - name: Check static analysis results |
29 | | - uses: fountainhead/action-wait-for-check@v1.0.0 |
30 | | - id: static-analysis |
31 | | - with: |
32 | | - token: ${{ secrets.GITHUB_TOKEN }} |
33 | | - # This check name is defined as the github action job name (in .github/workflows/validations.yaml) |
34 | | - checkName: "Static analysis" |
35 | | - ref: ${{ github.event.pull_request.head.sha || github.sha }} |
36 | | - |
37 | | - - name: Check unit test results |
38 | | - uses: fountainhead/action-wait-for-check@v1.0.0 |
39 | | - id: unit |
40 | | - with: |
41 | | - token: ${{ secrets.GITHUB_TOKEN }} |
42 | | - # This check name is defined as the github action job name (in .github/workflows/validations.yaml) |
43 | | - checkName: "Unit tests" |
44 | | - ref: ${{ github.event.pull_request.head.sha || github.sha }} |
45 | | - |
46 | | - - name: Check acceptance test results (linux) |
47 | | - uses: fountainhead/action-wait-for-check@v1.0.0 |
48 | | - id: acceptance-linux |
49 | | - with: |
50 | | - token: ${{ secrets.GITHUB_TOKEN }} |
51 | | - # This check name is defined as the github action job name (in .github/workflows/validations.yaml) |
52 | | - checkName: "Acceptance tests (Linux)" |
53 | | - ref: ${{ github.event.pull_request.head.sha || github.sha }} |
54 | | - |
55 | | - - name: Check acceptance test results (mac) |
56 | | - uses: fountainhead/action-wait-for-check@v1.0.0 |
57 | | - id: acceptance-mac |
58 | | - with: |
59 | | - token: ${{ secrets.GITHUB_TOKEN }} |
60 | | - # This check name is defined as the github action job name (in .github/workflows/validations.yaml) |
61 | | - checkName: "Acceptance tests (Mac)" |
62 | | - ref: ${{ github.event.pull_request.head.sha || github.sha }} |
63 | | - |
64 | | - - name: Check cli test results (linux) |
65 | | - uses: fountainhead/action-wait-for-check@v1.0.0 |
66 | | - id: cli-linux |
67 | | - with: |
68 | | - token: ${{ secrets.GITHUB_TOKEN }} |
69 | | - # This check name is defined as the github action job name (in .github/workflows/testing.yaml) |
70 | | - checkName: "CLI tests (Linux)" |
71 | | - ref: ${{ github.event.pull_request.head.sha || github.sha }} |
72 | | - |
73 | | - - name: Quality gate |
74 | | - if: steps.static-analysis.outputs.conclusion != 'success' || steps.unit.outputs.conclusion != 'success' || steps.acceptance-linux.outputs.conclusion != 'success' || steps.acceptance-mac.outputs.conclusion != 'success' || steps.cli-linux.outputs.conclusion != 'success' |
75 | | - run: | |
76 | | - echo "Static Analysis Status: ${{ steps.static-analysis.conclusion }}" |
77 | | - echo "Unit Test Status: ${{ steps.unit.outputs.conclusion }}" |
78 | | - echo "Acceptance Test (Linux) Status: ${{ steps.acceptance-linux.outputs.conclusion }}" |
79 | | - echo "Acceptance Test (Mac) Status: ${{ steps.acceptance-mac.outputs.conclusion }}" |
80 | | - echo "CLI Test (Linux) Status: ${{ steps.cli-linux.outputs.conclusion }}" |
81 | | - false |
82 | | -
|
83 | 19 | release: |
84 | | - needs: [quality-gate] |
85 | 20 | runs-on: ubuntu-latest |
86 | 21 | steps: |
87 | | - |
88 | | - - uses: actions/setup-go@v2 |
89 | | - with: |
90 | | - go-version: ${{ env.GO_VERSION }} |
91 | | - |
92 | | - - uses: actions/checkout@v2 |
| 22 | + - uses: actions/checkout@v5 |
93 | 23 | with: |
94 | 24 | fetch-depth: 0 |
95 | 25 |
|
96 | | - - name: Restore tool cache |
97 | | - id: tool-cache |
98 | | - uses: actions/cache@v2.1.3 |
99 | | - with: |
100 | | - path: ${{ github.workspace }}/.tmp |
101 | | - key: ${{ runner.os }}-tool-${{ hashFiles('Makefile') }} |
102 | | - |
103 | | - - name: Restore go cache |
104 | | - id: go-cache |
105 | | - uses: actions/cache@v2.1.3 |
| 26 | + - uses: actions/setup-go@v5 |
106 | 27 | with: |
107 | | - path: ~/go/pkg/mod |
108 | | - key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum') }} |
109 | | - restore-keys: | |
110 | | - ${{ runner.os }}-go-${{ env.GO_VERSION }}- |
| 28 | + go-version: ${{ env.GO_VERSION }} |
111 | 29 |
|
112 | | - - name: (cache-miss) Bootstrap all project dependencies |
113 | | - if: steps.tool-cache.outputs.cache-hit != 'true' || steps.go-cache.outputs.cache-hit != 'true' |
| 30 | + - name: Bootstrap all project dependencies |
114 | 31 | run: make bootstrap |
115 | 32 |
|
116 | | - - name: Build & publish release artifacts |
117 | | - run: make release |
| 33 | + - name: Build |
| 34 | + run: | |
| 35 | + if [[ "${GITHUB_REF}" = refs/tags/v* ]]; then |
| 36 | + make release |
| 37 | + else |
| 38 | + make RELEASE_FLAGS="--snapshot" release |
| 39 | + fi |
118 | 40 | env: |
119 | 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
120 | 42 |
|
121 | | - - uses: anchore/sbom-action@v0 |
122 | | - continue-on-error: true |
123 | | - with: |
124 | | - artifact-name: sbom.spdx.json |
125 | | - |
126 | | - - uses: actions/upload-artifact@v2 |
| 43 | + - uses: actions/upload-artifact@v4 |
127 | 44 | with: |
128 | 45 | name: artifacts |
129 | 46 | path: dist/**/* |
0 commit comments