From 3f6886081606fa070b9df922f82a6ff968d60c8a Mon Sep 17 00:00:00 2001 From: thaodangspace Date: Wed, 5 Aug 2026 19:37:47 +0700 Subject: [PATCH 1/2] Add CI and tagged release workflows --- .github/workflows/ci.yml | 90 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 81 +++++++++++++++++++++++++++++++ .goreleaser.yaml | 3 ++ Makefile | 2 +- 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9af147a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,90 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + go: + name: Go checks + runs-on: macos-latest + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Check formatting + shell: bash + run: | + go fmt ./... + if ! git diff --quiet -- '*.go'; then + echo 'Go formatting changed tracked files:' + git diff -- '*.go' + exit 1 + fi + + - name: Vet + run: go vet ./... + + - name: Test + run: go test ./... + + - name: Test with race detector + run: go test -race ./... + + - name: Build CLI + run: go build -trimpath ./cmd/things-cli + + - name: Build release architectures + shell: bash + run: | + mkdir -p "$RUNNER_TEMP/things-cli-build" + GOOS=darwin GOARCH=amd64 go build -trimpath \ + -o "$RUNNER_TEMP/things-cli-build/things-cli-darwin-amd64" \ + ./cmd/things-cli + GOOS=darwin GOARCH=arm64 go build -trimpath \ + -o "$RUNNER_TEMP/things-cli-build/things-cli-darwin-arm64" \ + ./cmd/things-cli + + docs: + name: Documentation build + runs-on: ubuntu-latest + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: docs/package-lock.json + + - name: Install documentation dependencies + run: npm --prefix docs ci + + - name: Build documentation + run: npm --prefix docs run build + + - name: Upload documentation artifact + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: things-cli-docs-${{ github.run_id }} + path: docs/dist + if-no-files-found: error + retention-days: 3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6ea7ddd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,81 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: read + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + release: + name: Publish release + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + attestations: write + steps: + - name: Check out source and tag history + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Validate release tag + shell: bash + run: | + tag_commit="$(git rev-list -n 1 "$GITHUB_REF")" + if [[ -z "$tag_commit" || "$tag_commit" != "$GITHUB_SHA" ]]; then + echo "::error::${GITHUB_REF} does not resolve to the workflow commit ($GITHUB_SHA)." + exit 1 + fi + + git fetch origin main --no-tags + if ! git merge-base --is-ancestor "$tag_commit" origin/main; then + echo "::error::Release tags must point at a commit reachable from main." + exit 1 + fi + + - name: Vet + run: go vet ./... + + - name: Test + run: go test ./... + + - name: Verify Homebrew token + env: + HAS_TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN != '' }} + run: | + if [[ "$HAS_TAP_GITHUB_TOKEN" != "true" ]]; then + echo '::error::TAP_GITHUB_TOKEN is required to publish the Homebrew formula.' + exit 1 + fi + + - name: Install Syft for SBOM generation + uses: anchore/sbom-action/download-syft@v0.24.0 + + - name: Release with GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: v2.17.1 + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} + + - name: Attest release artifacts + uses: actions/attest-build-provenance@v2 + with: + subject-path: 'dist/*' diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8c17e89..554b505 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -29,6 +29,9 @@ archives: checksum: name_template: "checksums.txt" +sboms: + - artifacts: archive + changelog: use: github sort: asc diff --git a/Makefile b/Makefile index 42dbe7e..c646c4d 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ vet: ## Run go vet tidy: ## Tidy Go modules go mod tidy -check: fmt tidy vet test ## Format, tidy, vet, and test +check: fmt tidy vet test build ## Format, tidy, vet, test, and build docs-install: ## Install documentation site dependencies npm --prefix docs ci From 9fca35b3977d38d57bd5642ad6266a6ca6e2d9d1 Mon Sep 17 00:00:00 2001 From: thaodangspace Date: Wed, 5 Aug 2026 20:18:23 +0700 Subject: [PATCH 2/2] Validate GoReleaser in CI --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 2 +- .goreleaser.yaml | 10 ++++------ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9af147a..e49caa8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,36 @@ jobs: -o "$RUNNER_TEMP/things-cli-build/things-cli-darwin-arm64" \ ./cmd/things-cli + release-config: + name: GoReleaser validation + runs-on: ubuntu-latest + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Install Syft for SBOM generation + uses: anchore/sbom-action/download-syft@v0.24.0 + + - name: Check GoReleaser configuration + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: v2.17.1 + args: check + + - name: Validate snapshot release + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: v2.17.1 + args: release --snapshot --clean + docs: name: Documentation build runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ea7ddd..995ad05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,7 +58,7 @@ jobs: HAS_TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN != '' }} run: | if [[ "$HAS_TAP_GITHUB_TOKEN" != "true" ]]; then - echo '::error::TAP_GITHUB_TOKEN is required to publish the Homebrew formula.' + echo '::error::TAP_GITHUB_TOKEN is required to publish the Homebrew cask.' exit 1 fi diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 554b505..cc3adab 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -41,7 +41,7 @@ changelog: - "^test:" - "^chore:" -brews: +homebrew_casks: - name: things-cli repository: owner: thaodangspace @@ -50,8 +50,6 @@ brews: homepage: "https://github.com/thaodangspace/things-cli" description: "Things 3 CLI for agents and humans (JSON output by default)" license: "MIT" - directory: Formula - install: | - bin.install "things-cli" - test: | - system "#{bin}/things-cli", "--version" + directory: Casks + binaries: + - things-cli