Skip to content

Commit 4492c46

Browse files
authored
feat: add cli release workflow (#43)
* feat: add cli release step * doc: add release step doc
1 parent a468304 commit 4492c46

3 files changed

Lines changed: 157 additions & 1 deletion

File tree

.github/workflows/cli-release.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release CLI
2+
3+
on:
4+
push:
5+
tags:
6+
- "cli/v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version-file: cli/go.mod
25+
cache-dependency-path: cli/go.sum
26+
27+
- name: Extract version from tag
28+
id: version
29+
run: |
30+
# Strip the "cli/" prefix from the tag to get the semver (e.g. cli/v1.2.3 -> v1.2.3)
31+
TAG="${GITHUB_REF#refs/tags/}"
32+
VERSION="${TAG#cli/}"
33+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
34+
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
35+
36+
- name: Install GoReleaser
37+
uses: goreleaser/goreleaser-action@v6
38+
with:
39+
install-only: true
40+
version: "~> v2"
41+
42+
- name: Run GoReleaser
43+
working-directory: cli
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.version }}
47+
run: goreleaser release --clean

cli/.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ changelog:
5050
- "^test:"
5151

5252
release:
53-
disable: true
53+
name_template: "CLI {{ .Version }}"

docs/dev/release.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Release Guide
2+
3+
This document covers how to create releases for each component in the repository.
4+
5+
## Tag Convention
6+
7+
Each component uses a prefixed tag to trigger its release workflow:
8+
9+
| Component | Tag pattern | Example | Workflow |
10+
|-----------|------------|---------|----------|
11+
| CLI | `cli/v<semver>` | `cli/v1.2.3` | `.github/workflows/cli-release.yaml` |
12+
| Karpenter | `karpenter/v<semver>` | `karpenter/v0.5.0` | `.github/workflows/karpenter-publish.yaml` |
13+
14+
All tags must follow [Semantic Versioning](https://semver.org/).
15+
16+
---
17+
18+
## CLI Release
19+
20+
The CLI release workflow builds cross-platform binaries with [GoReleaser](https://goreleaser.com/) and publishes them as a GitHub Release.
21+
22+
### Artifacts
23+
24+
Each release includes:
25+
26+
- `aks-flex-cli_<version>_linux_amd64.tar.gz`
27+
- `aks-flex-cli_<version>_linux_arm64.tar.gz`
28+
- `aks-flex-cli_<version>_darwin_arm64.tar.gz`
29+
- `checksums.txt`
30+
- Auto-generated changelog
31+
32+
### Steps
33+
34+
1. Make sure all changes are merged to `main`.
35+
36+
2. Decide on a version number following semver (e.g. `v1.0.0`).
37+
38+
3. Create and push the tag:
39+
40+
```bash
41+
git tag cli/v1.0.0
42+
git push origin cli/v1.0.0
43+
```
44+
45+
4. The [Release CLI](.../../.github/workflows/cli-release.yaml) workflow runs automatically. Monitor it in the **Actions** tab.
46+
47+
5. Once complete, the GitHub Release appears under **Releases** with all binary archives attached.
48+
49+
### Local Snapshot Build
50+
51+
To build binaries locally without publishing:
52+
53+
```bash
54+
cd cli
55+
make build # binaries only
56+
make build-archives # binaries + tar.gz archives
57+
```
58+
59+
Snapshot builds append a `-snapshot-<commit>` suffix to the version.
60+
61+
---
62+
63+
## Karpenter Release
64+
65+
The Karpenter workflow builds a multi-platform Docker image and pushes it to GHCR.
66+
67+
### Image
68+
69+
```
70+
ghcr.io/<owner>/aks-flex/karpenter:<tag>
71+
```
72+
73+
### Triggers
74+
75+
The workflow runs on:
76+
77+
- Push to `main` when files under `karpenter/` or `plugin/` change (tagged as `main` and `sha-<short>`).
78+
- A `karpenter/v*` tag push (tagged with the semver and `latest`).
79+
- Manual `workflow_dispatch`.
80+
81+
### Steps
82+
83+
1. Make sure all changes are merged to `main`.
84+
85+
2. Decide on a version number (e.g. `v0.5.0`).
86+
87+
3. Create and push the tag:
88+
89+
```bash
90+
git tag karpenter/v0.5.0
91+
git push origin karpenter/v0.5.0
92+
```
93+
94+
4. The [Publish Karpenter Image](../../.github/workflows/karpenter-publish.yaml) workflow runs automatically.
95+
96+
5. Once complete, the image is available at:
97+
98+
```
99+
ghcr.io/<owner>/aks-flex/karpenter:0.5.0
100+
ghcr.io/<owner>/aks-flex/karpenter:latest
101+
```
102+
103+
---
104+
105+
## Troubleshooting
106+
107+
- **Workflow did not trigger** -- Verify the tag matches the expected pattern exactly (`cli/v*` or `karpenter/v*`). Tags like `CLI/v1.0.0` or `v1.0.0` without a prefix will not trigger the workflows.
108+
- **GoReleaser fails with "tag is not a semver"** -- Ensure the portion after the prefix is valid semver (e.g. `v1.2.3`, not `v1.2`).
109+
- **Permission denied on release** -- The workflow requires `contents: write` permission. This is configured in the workflow file but may need to be allowed in the repository settings if the default token permissions are restricted.

0 commit comments

Comments
 (0)