Repository navigation
176 lines (151 loc) · 4.72 KB
/
Copy pathrelease.yml
File metadata and controls
176 lines (151 loc) · 4.72 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
name: Release
on:
push:
tags:
- 'v*'
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions: {}
jobs:
security:
name: Security
uses: ./.github/workflows/security.yml
permissions:
contents: read
security-events: write
pull-requests: read
test:
name: Test gate
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
# zizmor: ignore[cache-poisoning] -- cache is branch-isolated; fork PRs cannot write to this cache
with:
go-version-file: go.mod
- name: Install golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: v2.9.0
install-only: true
- name: Check formatting
run: test -z "$(gofmt -l .)" || (echo "Run 'gofmt -w .' to fix formatting" && gofmt -l . && exit 1)
- name: Vet
run: go vet ./...
- name: Lint
run: golangci-lint run
- name: Check go.mod tidiness
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Test
run: go test -v ./...
- name: Test (race detector)
run: go test -race -count=1 ./...
- name: Govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
- name: Verify tag is on main
env:
COMMIT_SHA: ${{ github.sha }}
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$COMMIT_SHA" origin/main; then
echo "Error: tag is not on the main branch"
exit 1
fi
publish:
name: Publish
runs-on: ubuntu-latest
needs: [test, security]
environment: release
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Verify tag is on main
env:
COMMIT_SHA: ${{ github.sha }}
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$COMMIT_SHA" origin/main; then
echo "Error: tag is not on the main branch"
exit 1
fi
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
NOTES="### Install
\`\`\`
go get github.com/basecamp/cli@${TAG}
\`\`\`"
if [[ "$TAG" == *"-"* ]]; then
PRERELEASE="--prerelease"
else
PRERELEASE=""
fi
gh release create "$TAG" \
--title "v${TAG#v}" \
--notes "$NOTES" \
--generate-notes \
$PRERELEASE
sync-skills:
name: Sync skills
runs-on: ubuntu-latest
needs: [publish]
if: vars.SKILLS_APP_ID != ''
continue-on-error: true
timeout-minutes: 5
environment: release
concurrency:
group: sync-skills
cancel-in-progress: false
permissions:
contents: read
env:
HAS_SKILLS_KEY: ${{ secrets.SKILLS_APP_PRIVATE_KEY && 'true' || '' }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check prerequisites
id: check
run: |
if [ -z "$HAS_SKILLS_KEY" ]; then
echo "::warning::SKILLS_APP_PRIVATE_KEY secret is not set — skipping skills sync"
echo "ready=false" >> "$GITHUB_OUTPUT"
elif ! ls skills/*/SKILL.md >/dev/null 2>&1; then
echo "No skill files found — skipping sync"
echo "ready=false" >> "$GITHUB_OUTPUT"
else
echo "ready=true" >> "$GITHUB_OUTPUT"
fi
- name: Generate token
if: steps.check.outputs.ready == 'true'
id: skills-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ vars.SKILLS_APP_ID }}
private-key: ${{ secrets.SKILLS_APP_PRIVATE_KEY }}
owner: basecamp
repositories: skills
permission-contents: write
- name: Sync skills
if: steps.check.outputs.ready == 'true'
env:
SKILLS_TOKEN: ${{ steps.skills-token.outputs.token }}
RELEASE_TAG: ${{ github.ref_name }}
SOURCE_SHA: ${{ github.sha }}
run: scripts/sync-skills.sh