Repository navigation
178 lines (156 loc) · 5.22 KB
/
Copy pathrelease-please.yml
File metadata and controls
178 lines (156 loc) · 5.22 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Release
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types: [completed]
permissions:
contents: write
pull-requests: write
issues: write
actions: write
statuses: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release-please:
name: Release Please
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
pr_head_sha: ${{ steps.pr-sha.outputs.sha }}
steps:
- name: Release Please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR head SHA
id: pr-sha
if: ${{ !steps.release.outputs.release_created }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
SHA=$(gh pr list --repo "$GH_REPO" --head release-please--branches--main --state open --json headRefOid --jq '.[0].headRefOid')
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
test-release-pr:
name: Test (Release PR)
needs: release-please
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
runs-on: ubuntu-latest
steps:
- name: Set pending status
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=pending -f context="Test" -f description="Running tests..."
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.pr_head_sha }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.1'
- name: Run tests
run: go test -race -coverprofile=coverage.out ./...
- name: Build
run: go build -o /dev/null ./cmd/solactl
- name: Report success
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=success -f context="Test" -f description="Tests passed"
- name: Report failure
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=failure -f context="Test" -f description="Tests failed"
lint-release-pr:
name: Lint (Release PR)
needs: release-please
if: ${{ !needs.release-please.outputs.release_created && needs.release-please.outputs.pr_head_sha != '' }}
runs-on: ubuntu-latest
steps:
- name: Set pending status
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=pending -f context="Lint" -f description="Running lint..."
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.pr_head_sha }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.1'
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11
- name: Report success
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=success -f context="Lint" -f description="Lint passed"
- name: Report failure
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHA: ${{ needs.release-please.outputs.pr_head_sha }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/statuses/$SHA" \
-f state=failure -f context="Lint" -f description="Lint failed"
goreleaser:
name: Release Binaries
needs: release-please
if: ${{ needs.release-please.outputs.release_created == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ needs.release-please.outputs.tag_name }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26.1'
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}