Skip to content

Commit 0108ce9

Browse files
authored
Merge pull request #93 from ShippingBytes/chore/release-markdown-cli-doc
Add cli doc and doc folder to release bundle
2 parents d9a0eee + fcf1680 commit 0108ce9

8 files changed

Lines changed: 88 additions & 9 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ dist/
44
/datumctl
55
# Nix stuff
66
/result
7+
.generated/

.goreleaser.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ before:
99
hooks:
1010
- go mod tidy
1111
- go generate ./...
12+
- ./scripts/generate-cli-docs.sh
13+
- ./scripts/package-docs.sh
1214

1315
builds:
1416
- env:
@@ -57,7 +59,12 @@ changelog:
5759
- "^test:"
5860
- "^chore:"
5961

60-
release: {}
62+
release:
63+
extra_files:
64+
- glob: .generated/datumctl-cli-docs.tar.gz
65+
name_template: "{{ .ProjectName }}-cli-docs_{{ .Version }}.tar.gz"
66+
- glob: .generated/datumctl-docs.tar.gz
67+
name_template: "{{ .ProjectName }}-docs_{{ .Version }}.tar.gz"
6168

6269
sboms:
6370
- artifacts: archive

docs/developer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ development of the `datumctl` CLI.
88
* [Overview](./overview.md)
99
* [Authentication Flow](./authentication_flow.md)
1010
* [Code Structure](./code_structure.md)
11+
* [Releases](./releases.md)

docs/developer/releases.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Releases
2+
3+
This guide explains how to cut a `datumctl` release locally with GoReleaser and
4+
how the GitHub Actions workflow publishes the official artifacts.
5+
6+
## Local workflow
7+
8+
1. **Prepare the repo**
9+
- Ensure `git status` is clean (GoReleaser refuses to run with dirty trees
10+
unless you explicitly use `--snapshot`).
11+
- Install the required tooling: supported Go version (see `go.mod`) and
12+
[GoReleaser v2](https://goreleaser.com/install/).
13+
2. **Dry-run the release**
14+
- Run `goreleaser release --snapshot --clean`.
15+
The `--snapshot` flag skips publishing and the `--clean` flag wipes `dist/`
16+
before starting.
17+
- The docs generation script (`scripts/generate-cli-docs.sh`) executes as part
18+
of the `before` hooks, producing `.generated/datumctl-cli-docs.tar.gz`. That
19+
tarball is registered as an extra release file, so the real release will
20+
upload it automatically.
21+
3. **Tag and release**
22+
- Create a semver tag (e.g. `git tag v0.10.0 && git push origin v0.10.0`).
23+
- Run `goreleaser release --clean` if you need to publish from your machine.
24+
Otherwise, let CI handle publishing after you push the tag.
25+
26+
## CI/CD pipeline
27+
28+
- The workflow at `.github/workflows/release.yaml` triggers on every pushed tag.
29+
- Steps executed on `ubuntu-latest`:
30+
1. Checkout the repository with full history.
31+
2. Install Syft (required for SBOMs) and set up the stable Go toolchain.
32+
3. Run `goreleaser release --clean` via `goreleaser/goreleaser-action@v6`.
33+
- GoReleaser runs the same hooks as your local invocation, so the generated CLI
34+
docs tarball, archives, packages, SBOMs, and checksums are all attached to the
35+
GitHub release. The action uses `secrets/TAP_TOKEN` for `GITHUB_TOKEN`.
36+
37+
## Tips and troubleshooting
38+
39+
- If GoReleaser fails immediately with `dist is not empty`, remove the folder or
40+
keep using `--clean`.
41+
- Network access is required for `go mod tidy` (first `before` hook); if you are
42+
offline use `--skip=before` for local experimentation, but re-run the full flow
43+
before tagging.
44+
- After the release completes you can inspect `.generated/cli-docs/` or
45+
`.generated/datumctl-cli-docs.tar.gz` to verify the CLI documentation bundle.

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
gotools
6767
go-task
6868
go-tools
69+
goreleaser
70+
syft
6971
git
7072
];
7173

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8u
200200
github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI=
201201
go.miloapis.com/activity v0.2.0 h1:/l5Ce713MSSlaPw3eS0aaVV+Btqo4TJ/evhD9SchPDQ=
202202
go.miloapis.com/activity v0.2.0/go.mod h1:sp04VDZnzqyj26+Cp10NkrA4YT3FXyN48wS8nw3zuRk=
203-
go.miloapis.com/milo v0.16.2 h1:MqrBQvTYWIWBlniJXqBe3ycO/sZxgkL2tYems4s1+LY=
204-
go.miloapis.com/milo v0.16.2/go.mod h1:xOFYvUsvSZV3z6eow5YdB5C/qRQf2s/5/arcfJs5XPg=
205-
go.miloapis.com/milo v0.17.1 h1:Qaulxmn+WZI4obYl9l0K4Ci4RYXoEGIzV787nonF490=
206-
go.miloapis.com/milo v0.17.1/go.mod h1:xOFYvUsvSZV3z6eow5YdB5C/qRQf2s/5/arcfJs5XPg=
207203
go.miloapis.com/milo v0.18.0 h1:+6HRLlRO2genWFnIw9803A1er9/vmRfP1EOC3ZlEF/U=
208204
go.miloapis.com/milo v0.18.0/go.mod h1:xOFYvUsvSZV3z6eow5YdB5C/qRQf2s/5/arcfJs5XPg=
209205
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
@@ -278,8 +274,6 @@ k8s.io/metrics v0.35.0 h1:xVFoqtAGm2dMNJAcB5TFZJPCen0uEqqNt52wW7ABbX8=
278274
k8s.io/metrics v0.35.0/go.mod h1:g2Up4dcBygZi2kQSEQVDByFs+VUwepJMzzQLJJLpq4M=
279275
k8s.io/utils v0.0.0-20260108192941-914a6e750570 h1:JT4W8lsdrGENg9W+YwwdLJxklIuKWdRm+BC+xt33FOY=
280276
k8s.io/utils v0.0.0-20260108192941-914a6e750570/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
281-
sigs.k8s.io/controller-runtime v0.23.0 h1:Ubi7klJWiwEWqDY+odSVZiFA0aDSevOCXpa38yCSYu8=
282-
sigs.k8s.io/controller-runtime v0.23.0/go.mod h1:DBOIr9NsprUqCZ1ZhsuJ0wAnQSIxY/C6VjZbmLgw0j0=
283277
sigs.k8s.io/controller-runtime v0.23.1 h1:TjJSM80Nf43Mg21+RCy3J70aj/W6KyvDtOlpKf+PupE=
284278
sigs.k8s.io/controller-runtime v0.23.1/go.mod h1:B6COOxKptp+YaUT5q4l6LqUJTRpizbgf9KSRNdQGns0=
285279
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
@@ -292,8 +286,6 @@ sigs.k8s.io/kustomize/kyaml v0.21.0 h1:7mQAf3dUwf0wBerWJd8rXhVcnkk5Tvn/q91cGkaP6
292286
sigs.k8s.io/kustomize/kyaml v0.21.0/go.mod h1:hmxADesM3yUN2vbA5z1/YTBnzLJ1dajdqpQonwBL1FQ=
293287
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
294288
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
295-
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 h1:JrhdFMqOd/+3ByqlP2I45kTOZmTRLBUm5pvRjeheg7E=
296-
sigs.k8s.io/structured-merge-diff/v6 v6.3.1/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
297289
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 h1:2WOzJpHUBVrrkDjU4KBT8n5LDcj824eX0I5UKcgeRUs=
298290
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
299291
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=

scripts/generate-cli-docs.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
OUTPUT_DIR="${CLI_DOCS_OUTPUT_DIR:-$ROOT_DIR/.generated/cli-docs}"
6+
ARCHIVE_PATH="${CLI_DOCS_ARCHIVE_PATH:-$ROOT_DIR/.generated/datumctl-cli-docs.tar.gz}"
7+
8+
rm -rf "${OUTPUT_DIR}"
9+
mkdir -p "${OUTPUT_DIR}"
10+
11+
pushd "${ROOT_DIR}" >/dev/null
12+
go run main.go docs generate-cli-docs --output-dir "${OUTPUT_DIR}"
13+
popd >/dev/null
14+
15+
mkdir -p "$(dirname "${ARCHIVE_PATH}")"
16+
tar -C "${OUTPUT_DIR}" -czf "${ARCHIVE_PATH}" .

scripts/package-docs.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
DOCS_DIR="${DOCS_SOURCE_DIR:-$ROOT_DIR/docs}"
6+
ARCHIVE_PATH="${DOCS_ARCHIVE_PATH:-$ROOT_DIR/.generated/datumctl-docs.tar.gz}"
7+
8+
if [ ! -d "${DOCS_DIR}" ]; then
9+
echo "Docs directory not found: ${DOCS_DIR}" >&2
10+
exit 1
11+
fi
12+
13+
mkdir -p "$(dirname "${ARCHIVE_PATH}")"
14+
rm -f "${ARCHIVE_PATH}"
15+
tar -C "${DOCS_DIR}" -czf "${ARCHIVE_PATH}" .

0 commit comments

Comments
 (0)