Repository navigation
226 lines (186 loc) · 7.96 KB
/
Copy pathrelease.yml
File metadata and controls
226 lines (186 loc) · 7.96 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
id-token: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
name: Build and release
# Darwin artifacts must be signed by Apple's codesign on macOS. macOS 26
# rejects the ad-hoc signature emitted by a Linux cross-build at launch.
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Resolve release
id: release
shell: bash
run: |
git fetch --force --tags
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
latest_tag="$(git tag --list 'v*.*.*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1 || true)"
if [[ -z "$latest_tag" ]]; then
version="0.1.0"
else
latest_version="${latest_tag#v}"
IFS=. read -r major minor _ <<< "$latest_version"
version="$major.$((minor + 1)).0"
fi
tag="v$version"
create_tag="true"
else
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
create_tag="false"
fi
if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Release tag must look like v0.1.0; got $tag" >&2
exit 1
fi
if [[ "$create_tag" == "true" ]]; then
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
echo "Release tag $tag already exists" >&2
exit 1
fi
elif ! git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
echo "Release tag $tag does not exist in this checkout" >&2
exit 1
fi
{
echo "tag=$tag"
echo "version=$version"
echo "create_tag=$create_tag"
echo "date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
} >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
- name: Set up Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Install Nix
uses: cachix/install-nix-action@bb0495a1086c46893eee56f32fd192dfe4a15bb9 # v32
- name: Test
run: go test ./...
- name: Build release archives
run: ./scripts/build-release.sh "${{ steps.release.outputs.tag }}" "${GITHUB_SHA::7}" "${{ steps.release.outputs.date }}"
- name: Generate and evaluate Nix release
shell: bash
run: |
set -euo pipefail
node scripts/update-nix-flake.mjs "${{ steps.release.outputs.tag }}" dist/checksums.txt
nix flake check --all-systems --no-build --print-build-logs
git diff --check -- flake.nix
- name: Generate release notes
run: ./scripts/release-notes.sh "${{ steps.release.outputs.tag }}" dist/release-notes.md
- name: Stamp npm package and skill version
run: node scripts/stamp-release-version.mjs "${{ steps.release.outputs.version }}"
- name: Pack npm installer
run: npm pack --dry-run
- name: Create release tag
if: steps.release.outputs.create_tag == 'true'
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.release.outputs.tag }}" -m "deptrust ${{ steps.release.outputs.tag }}"
git push origin "refs/tags/${{ steps.release.outputs.tag }}"
- name: Upload release artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: deptrust-${{ steps.release.outputs.tag }}
path: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
dist/release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4
with:
tag_name: ${{ steps.release.outputs.tag }}
name: deptrust ${{ steps.release.outputs.tag }}
body_path: dist/release-notes.md
files: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
fail_on_unmatched_files: true
- name: Publish npm package
run: npm publish --access public
- name: Update Homebrew tap
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
TAP_REPO: clidey/homebrew-tap
TAG: ${{ steps.release.outputs.tag }}
shell: bash
run: |
set -euo pipefail
if [[ -z "${HOMEBREW_TAP_TOKEN}" ]]; then
echo "HOMEBREW_TAP_TOKEN secret not set; skipping tap update"
exit 0
fi
# Render the formula from the release checksums.
./scripts/generate-homebrew-formula.sh "$TAG" dist/checksums.txt dist/deptrust.rb
tap_dir="$(mktemp -d)"
git clone --depth 1 "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/${TAP_REPO}.git" "$tap_dir"
mkdir -p "$tap_dir/Formula"
cp dist/deptrust.rb "$tap_dir/Formula/deptrust.rb"
git -C "$tap_dir" config user.name "github-actions[bot]"
git -C "$tap_dir" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git -C "$tap_dir" add Formula/deptrust.rb
if git -C "$tap_dir" diff --cached --quiet; then
echo "Formula already up to date for $TAG"
exit 0
fi
git -C "$tap_dir" commit -m "deptrust $TAG"
git -C "$tap_dir" push origin HEAD
- name: Commit release metadata and validated Nix flake
shell: bash
run: |
set -euo pipefail
default_branch="${{ github.event.repository.default_branch }}"
tmp_dir="$(mktemp -d)"
mkdir -p "$tmp_dir/skill"
cp package.json "$tmp_dir/package.json"
cp .agents/skills/deptrust-package-check/SKILL.md "$tmp_dir/skill/SKILL.md"
# The release build stamped these tracked files in the tag checkout.
# Restore them before switching to the latest default branch; the
# stamped copies above are applied again after the checkout.
git restore --source=HEAD --worktree package.json .agents/skills/deptrust-package-check/SKILL.md flake.nix
git fetch origin "$default_branch"
git checkout "$default_branch"
git pull --ff-only origin "$default_branch"
cp "$tmp_dir/package.json" package.json
cp "$tmp_dir/skill/SKILL.md" .agents/skills/deptrust-package-check/SKILL.md
node scripts/update-nix-flake.mjs "${{ steps.release.outputs.tag }}" dist/checksums.txt
nix flake check --all-systems --print-build-logs
nix build .#default --print-build-logs
actual="$(nix run .#default -- version | head -n 1)"
expected="deptrust ${{ steps.release.outputs.tag }}"
if [[ "$actual" != "$expected" ]]; then
echo "Version mismatch: got '$actual', expected '$expected'" >&2
exit 1
fi
git diff --check
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json .agents/skills/deptrust-package-check/SKILL.md flake.nix
if git diff --cached --quiet; then
echo "Source version files and Nix flake already match ${{ steps.release.outputs.tag }}"
exit 0
fi
git commit -m "chore: release ${{ steps.release.outputs.tag }} [skip ci]"
git push origin "HEAD:$default_branch"