| 1 |
name: Release |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
tags: |
| 6 |
- '[0-9]*.[0-9]*.[0-9]*' |
| 7 |
|
| 8 |
concurrency: |
| 9 |
group: release |
| 10 |
cancel-in-progress: false |
| 11 |
|
| 12 |
permissions: |
| 13 |
contents: write |
| 14 |
actions: read |
| 15 |
id-token: write |
| 16 |
attestations: write |
| 17 |
|
| 18 |
jobs: |
| 19 |
ci-preflight: |
| 20 |
runs-on: ubuntu-latest |
| 21 |
steps: |
| 22 |
- uses: actions/checkout@v5 |
| 23 |
|
| 24 |
- name: Require latest main checks success |
| 25 |
env: |
| 26 |
GH_TOKEN: ${{ github.token }} |
| 27 |
run: ./scripts/release-require-green-main.sh |
| 28 |
|
| 29 |
live-evaluations: |
| 30 |
uses: ./.github/workflows/eval-live.yml |
| 31 |
secrets: inherit |
| 32 |
|
| 33 |
debian-amd64: |
| 34 |
needs: [ci-preflight, live-evaluations] |
| 35 |
runs-on: ubuntu-latest |
| 36 |
steps: |
| 37 |
- uses: actions/checkout@v5 |
| 38 |
with: |
| 39 |
fetch-depth: 0 |
| 40 |
|
| 41 |
- uses: actions/setup-go@v6 |
| 42 |
with: |
| 43 |
go-version-file: go.mod |
| 44 |
|
| 45 |
- name: Install Debian tooling |
| 46 |
env: |
| 47 |
DEBIAN_FRONTEND: noninteractive |
| 48 |
run: sudo apt-get update && sudo apt-get install -y debhelper dpkg-dev lintian bash-completion pandoc |
| 49 |
|
| 50 |
- name: Configure git and dch environment |
| 51 |
run: | |
| 52 |
git config user.name "github-actions[bot]" |
| 53 |
git config user.email "github-actions[bot]@users.noreply.github.com" |
| 54 |
echo 'DEBFULLNAME=Brian Cosgrove' >> "$GITHUB_ENV" |
| 55 |
echo '[email protected]' >> "$GITHUB_ENV" |
| 56 |
|
| 57 |
- name: Merge main into debian/main |
| 58 |
run: | |
| 59 |
git checkout debian/main |
| 60 |
git merge --no-edit "${{ github.sha }}" |
| 61 |
|
| 62 |
- name: Generate changelog |
| 63 |
run: | |
| 64 |
VERSION="${GITHUB_REF_NAME}" |
| 65 |
DATE="$(date -R)" |
| 66 |
cat > debian/changelog <<EOF |
| 67 |
clnkr (${VERSION}-1) unstable; urgency=medium |
| 68 |
|
| 69 |
* Release ${VERSION}. |
| 70 |
|
| 71 |
-- Brian Cosgrove <[email protected]> ${DATE} |
| 72 |
EOF |
| 73 |
|
| 74 |
- name: Generate orig tarball |
| 75 |
run: | |
| 76 |
VERSION="${GITHUB_REF_NAME}" |
| 77 |
git archive --format=tar.gz --prefix="clnkr-${VERSION}/" \ |
| 78 |
HEAD -- . ':(exclude)debian' > "../clnkr_${VERSION}.orig.tar.gz" |
| 79 |
|
| 80 |
- name: Build amd64 package |
| 81 |
# -d skips Build-Depends check: golang-go comes from actions/setup-go, not apt |
| 82 |
run: dpkg-buildpackage -us -uc -d |
| 83 |
|
| 84 |
- name: Run lintian |
| 85 |
run: | |
| 86 |
lintian --profile debian \ |
| 87 |
--suppress-tags latest-debian-changelog-entry-reuses-existing-version \ |
| 88 |
--fail-on error ../*.changes |
| 89 |
|
| 90 |
- name: Collect build output |
| 91 |
run: | |
| 92 |
cp ../clnkr_*.deb . |
| 93 |
cp debian/changelog debian-changelog |
| 94 |
|
| 95 |
- name: Upload deb |
| 96 |
uses: actions/upload-artifact@v4 |
| 97 |
with: |
| 98 |
name: deb-amd64 |
| 99 |
path: clnkr_*.deb |
| 100 |
|
| 101 |
- name: Upload changelog |
| 102 |
uses: actions/upload-artifact@v4 |
| 103 |
with: |
| 104 |
name: debian-changelog |
| 105 |
path: debian-changelog |
| 106 |
|
| 107 |
debian-arm64: |
| 108 |
needs: [ci-preflight, live-evaluations] |
| 109 |
runs-on: ubuntu-24.04-arm |
| 110 |
steps: |
| 111 |
- uses: actions/checkout@v5 |
| 112 |
with: |
| 113 |
fetch-depth: 0 |
| 114 |
|
| 115 |
- uses: actions/setup-go@v6 |
| 116 |
with: |
| 117 |
go-version-file: go.mod |
| 118 |
|
| 119 |
- name: Install Debian tooling |
| 120 |
env: |
| 121 |
DEBIAN_FRONTEND: noninteractive |
| 122 |
run: sudo apt-get update && sudo apt-get install -y debhelper dpkg-dev lintian bash-completion pandoc |
| 123 |
|
| 124 |
- name: Configure git and dch environment |
| 125 |
run: | |
| 126 |
git config user.name "github-actions[bot]" |
| 127 |
git config user.email "github-actions[bot]@users.noreply.github.com" |
| 128 |
echo 'DEBFULLNAME=Brian Cosgrove' >> "$GITHUB_ENV" |
| 129 |
echo '[email protected]' >> "$GITHUB_ENV" |
| 130 |
|
| 131 |
- name: Merge main into debian/main |
| 132 |
run: | |
| 133 |
git checkout debian/main |
| 134 |
git merge --no-edit "${{ github.sha }}" |
| 135 |
|
| 136 |
- name: Generate changelog |
| 137 |
run: | |
| 138 |
VERSION="${GITHUB_REF_NAME}" |
| 139 |
DATE="$(date -R)" |
| 140 |
cat > debian/changelog <<EOF |
| 141 |
clnkr (${VERSION}-1) unstable; urgency=medium |
| 142 |
|
| 143 |
* Release ${VERSION}. |
| 144 |
|
| 145 |
-- Brian Cosgrove <[email protected]> ${DATE} |
| 146 |
EOF |
| 147 |
|
| 148 |
- name: Generate orig tarball |
| 149 |
run: | |
| 150 |
VERSION="${GITHUB_REF_NAME}" |
| 151 |
git archive --format=tar.gz --prefix="clnkr-${VERSION}/" \ |
| 152 |
HEAD -- . ':(exclude)debian' > "../clnkr_${VERSION}.orig.tar.gz" |
| 153 |
|
| 154 |
- name: Build arm64 package |
| 155 |
# -d skips Build-Depends check: golang-go comes from actions/setup-go, not apt |
| 156 |
run: dpkg-buildpackage -us -uc -d |
| 157 |
|
| 158 |
- name: Run lintian |
| 159 |
run: | |
| 160 |
lintian --profile debian \ |
| 161 |
--suppress-tags latest-debian-changelog-entry-reuses-existing-version \ |
| 162 |
--fail-on error ../*.changes |
| 163 |
|
| 164 |
- name: Collect build output |
| 165 |
run: cp ../clnkr_*.deb . |
| 166 |
|
| 167 |
- name: Upload deb |
| 168 |
uses: actions/upload-artifact@v4 |
| 169 |
with: |
| 170 |
name: deb-arm64 |
| 171 |
path: clnkr_*.deb |
| 172 |
|
| 173 |
binaries: |
| 174 |
needs: [ci-preflight, live-evaluations] |
| 175 |
runs-on: ubuntu-latest |
| 176 |
steps: |
| 177 |
- uses: actions/checkout@v5 |
| 178 |
|
| 179 |
- uses: actions/setup-go@v6 |
| 180 |
with: |
| 181 |
go-version-file: go.mod |
| 182 |
|
| 183 |
- name: Test |
| 184 |
run: go test -race ./... |
| 185 |
|
| 186 |
- name: Cross-compile binaries |
| 187 |
run: | |
| 188 |
VERSION="${GITHUB_REF_NAME}" |
| 189 |
for GOOS in linux darwin; do |
| 190 |
for GOARCH in amd64 arm64; do |
| 191 |
for CMD in clnkr clnkrd; do |
| 192 |
env CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ |
| 193 |
go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" \ |
| 194 |
-o "${CMD}-${GOOS}-${GOARCH}" "./cmd/${CMD}/" |
| 195 |
done |
| 196 |
done |
| 197 |
done |
| 198 |
|
| 199 |
- name: Upload binaries |
| 200 |
uses: actions/upload-artifact@v4 |
| 201 |
with: |
| 202 |
name: binaries |
| 203 |
path: | |
| 204 |
clnkr-* |
| 205 |
clnkrd-* |
| 206 |
|
| 207 |
release: |
| 208 |
needs: [debian-amd64, debian-arm64, binaries] |
| 209 |
runs-on: ubuntu-latest |
| 210 |
steps: |
| 211 |
- uses: actions/checkout@v5 |
| 212 |
with: |
| 213 |
fetch-depth: 0 |
| 214 |
|
| 215 |
- name: Install dpkg-dev |
| 216 |
run: sudo apt-get update && sudo apt-get install -y dpkg-dev |
| 217 |
|
| 218 |
- name: Configure git |
| 219 |
run: | |
| 220 |
git config user.name "github-actions[bot]" |
| 221 |
git config user.email "github-actions[bot]@users.noreply.github.com" |
| 222 |
|
| 223 |
- name: Download all artifacts |
| 224 |
uses: actions/download-artifact@v4 |
| 225 |
with: |
| 226 |
path: artifacts |
| 227 |
|
| 228 |
- name: Push debian/main |
| 229 |
run: | |
| 230 |
VERSION="${GITHUB_REF_NAME}" |
| 231 |
git checkout debian/main |
| 232 |
git merge --no-edit "${{ github.sha }}" |
| 233 |
cp artifacts/debian-changelog/debian-changelog debian/changelog |
| 234 |
git add debian/changelog |
| 235 |
git commit --allow-empty -m "Update changelog for ${VERSION}-1" |
| 236 |
git push origin debian/main |
| 237 |
|
| 238 |
- name: Generate CHANGELOG.md |
| 239 |
run: | |
| 240 |
git checkout main |
| 241 |
VERSION="${GITHUB_REF_NAME}" |
| 242 |
DATE=$(git log -1 --format=%cs "$GITHUB_REF_NAME") |
| 243 |
{ |
| 244 |
echo "# Changelog" |
| 245 |
echo "" |
| 246 |
echo "## ${VERSION} (${DATE})" |
| 247 |
echo "" |
| 248 |
echo "- Restart release history for the clnkr CLI." |
| 249 |
echo "" |
| 250 |
} > CHANGELOG.md |
| 251 |
git add CHANGELOG.md |
| 252 |
git diff --cached --quiet || { |
| 253 |
git commit -m "Update CHANGELOG.md for ${GITHUB_REF_NAME}" |
| 254 |
git push origin main |
| 255 |
} |
| 256 |
|
| 257 |
- name: Collect assets |
| 258 |
run: | |
| 259 |
mkdir -p release |
| 260 |
cp artifacts/deb-amd64/*.deb release/ |
| 261 |
cp artifacts/deb-arm64/*.deb release/ |
| 262 |
cp artifacts/binaries/clnkr-* artifacts/binaries/clnkrd-* release/ |
| 263 |
|
| 264 |
- name: Generate source tarball |
| 265 |
run: | |
| 266 |
VERSION="${GITHUB_REF_NAME}" |
| 267 |
git archive --format=tar.gz --prefix="clnkr-${VERSION}/" \ |
| 268 |
-o "release/clnkr_${VERSION}.orig.tar.gz" "${{ github.sha }}" |
| 269 |
|
| 270 |
- name: Generate checksums |
| 271 |
run: | |
| 272 |
cd release |
| 273 |
sha256sum ./* > SHA256SUMS |
| 274 |
|
| 275 |
- name: Attest release artifacts |
| 276 |
uses: actions/attest-build-provenance@v2 |
| 277 |
with: |
| 278 |
subject-path: release/* |
| 279 |
|
| 280 |
- name: Extract release notes |
| 281 |
run: | |
| 282 |
dpkg-parsechangelog -l artifacts/debian-changelog/debian-changelog \ |
| 283 |
--show-field Changes > release-notes.txt |
| 284 |
|
| 285 |
- name: Create GitHub release |
| 286 |
env: |
| 287 |
GH_TOKEN: ${{ github.token }} |
| 288 |
run: | |
| 289 |
VERSION="${GITHUB_REF_NAME}" |
| 290 |
# Delete any existing release from a failed run |
| 291 |
gh release delete "${GITHUB_REF_NAME}" --yes 2>/dev/null || true |
| 292 |
gh release create "${GITHUB_REF_NAME}" \ |
| 293 |
--title "clnkr ${VERSION}" \ |
| 294 |
--notes-file release-notes.txt \ |
| 295 |
release/* |
| 296 |
|
| 297 |
- name: Update Homebrew tap |
| 298 |
env: |
| 299 |
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 300 |
run: | |
| 301 |
VERSION="${GITHUB_REF_NAME}" |
| 302 |
SHA=$(curl -sL "https://github.com/clnkr-ai/clnkr/archive/refs/tags/${VERSION}.tar.gz" | sha256sum | awk '{print $1}') |
| 303 |
git clone "https://x-access-token:${GH_TOKEN}@github.com/clnkr-ai/homebrew-tap.git" /tmp/tap |
| 304 |
cd /tmp/tap |
| 305 |
sed -i "s|url \".*\"|url \"https://github.com/clnkr-ai/clnkr/archive/refs/tags/${VERSION}.tar.gz\"|" Formula/clnkr.rb |
| 306 |
sed -i "s|sha256 \".*\"|sha256 \"${SHA}\"|" Formula/clnkr.rb |
| 307 |
git config user.name "github-actions[bot]" |
| 308 |
git config user.email "github-actions[bot]@users.noreply.github.com" |
| 309 |
git add Formula/clnkr.rb |
| 310 |
git diff --cached --quiet || { |
| 311 |
git commit -m "Update clnkr to ${VERSION}" |
| 312 |
git push |
| 313 |
} |