forked from projectachilles/ProjectAchilles
-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (175 loc) · 6.26 KB
/
Copy pathrelease-agent.yml
File metadata and controls
209 lines (175 loc) · 6.26 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
name: Release Agent
on:
push:
tags: ['agent-v[0-9]+.[0-9]+.[0-9]+']
permissions:
contents: write
concurrency:
group: release-agent
cancel-in-progress: false
jobs:
verify-tag:
name: Verify tag is on main
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Ensure tag commit is on main
env:
TAG_REF: ${{ github.ref }}
run: |
TAG_COMMIT=$(git rev-list -n 1 "$TAG_REF")
if ! git merge-base --is-ancestor "$TAG_COMMIT" origin/main; then
echo "::error::Tag does not point to a commit on main"
exit 1
fi
test:
name: Test Agent
needs: verify-tag
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
working-directory: agent
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-go@v6
with:
go-version-file: agent/go.mod
cache-dependency-path: agent/go.sum
- run: go test ./...
- run: go vet ./...
build:
name: Build Agent Binaries
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/setup-go@v6
with:
go-version-file: agent/go.mod
cache-dependency-path: agent/go.sum
- name: Extract version from tag
id: version
env:
TAG_NAME: ${{ github.ref_name }}
run: echo "version=${TAG_NAME#agent-v}" >> "$GITHUB_OUTPUT"
- name: Build all platforms
working-directory: agent
env:
BUILD_VERSION: ${{ steps.version.outputs.version }}
run: make build-all VERSION="$BUILD_VERSION"
- name: Sign Windows binary
working-directory: agent
env:
WINDOWS_CERT_PFX: ${{ secrets.WINDOWS_CERT_PFX }}
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
run: |
if [ -z "$WINDOWS_CERT_PFX" ]; then
echo "No Windows certificate configured, skipping signing"
exit 0
fi
sudo apt-get update -qq && sudo apt-get install -y -qq osslsigncode > /dev/null
echo "$WINDOWS_CERT_PFX" | base64 -d > /tmp/cert.pfx
osslsigncode sign \
-pkcs12 /tmp/cert.pfx \
-pass "$WINDOWS_CERT_PASSWORD" \
-n "Achilles Agent" \
-t http://timestamp.digicert.com \
-in dist/achilles-agent-windows-amd64.exe \
-out dist/achilles-agent-windows-amd64-signed.exe
mv dist/achilles-agent-windows-amd64-signed.exe \
dist/achilles-agent-windows-amd64.exe
rm -f /tmp/cert.pfx
- name: Sign macOS binaries (ad-hoc)
run: |
# Install rcodesign from pre-built GitHub release
RCODESIGN_VERSION="0.27.0"
curl -fsSL "https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F${RCODESIGN_VERSION}/apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
| tar xz -C /tmp
RCODESIGN="/tmp/apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl/rcodesign"
chmod +x "$RCODESIGN"
# Signing without a certificate produces an ad-hoc signature
"$RCODESIGN" sign agent/dist/achilles-agent-darwin-amd64
"$RCODESIGN" sign agent/dist/achilles-agent-darwin-arm64
- name: Regenerate checksums after signing
working-directory: agent
run: make checksum
- name: Upload build artifacts
uses: actions/upload-artifact@v7.0.1
with:
name: agent-binaries
path: agent/dist/
retention-days: 5
release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: agent-binaries
path: dist/
- name: Extract version
id: version
env:
TAG_NAME: ${{ github.ref_name }}
run: echo "version=${TAG_NAME#agent-v}" >> "$GITHUB_OUTPUT"
- name: Build release notes
env:
AGENT_VERSION: ${{ steps.version.outputs.version }}
run: |
# Look for ## Agent [X.Y.Z] section in changelog
NOTES=$(awk -v ver="$AGENT_VERSION" '
/^## Agent \[/ {
if (found) exit
if ($0 ~ "\\[" ver "\\]") { found=1; next }
}
found && /^## / { exit }
found { print }
' docs/CHANGELOG.md)
if [ -z "$NOTES" ]; then
NOTES="Agent release ${AGENT_VERSION}. See [CHANGELOG.md](docs/CHANGELOG.md) for details."
fi
# Write release notes with installation header
cat > /tmp/release-notes.md << 'HEADER'
## Installation
Download the binary for your platform and enroll:
```bash
# Linux
chmod +x achilles-agent-linux-amd64
sudo ./achilles-agent-linux-amd64 --enroll TOKEN --server https://your-server.example.com --install
# macOS (Apple Silicon)
chmod +x achilles-agent-darwin-arm64
sudo ./achilles-agent-darwin-arm64 --enroll TOKEN --server https://your-server.example.com --install
# Windows (PowerShell as Administrator)
.\achilles-agent-windows-amd64.exe --enroll TOKEN --server https://your-server.example.com --install
```
## Verify checksums
```bash
sha256sum -c SHA256SUMS
```
---
HEADER
echo "$NOTES" >> /tmp/release-notes.md
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
AGENT_VERSION: ${{ steps.version.outputs.version }}
run: |
gh release create "$TAG_NAME" \
--title "Achilles Agent $AGENT_VERSION" \
--notes-file /tmp/release-notes.md \
--latest=false \
dist/*