diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f2a43a0..e952b57 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_call: jobs: ci: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index ffd0173..29a3db5 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_call: jobs: lint: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..bec3301 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: Release + +on: + workflow_call: + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v7 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tag-release.yaml b/.github/workflows/tag-release.yaml new file mode 100644 index 0000000..39c17f7 --- /dev/null +++ b/.github/workflows/tag-release.yaml @@ -0,0 +1,17 @@ +name: Tag Release + +on: + push: + tags: + - "v*" + +jobs: + ci: + uses: ./.github/workflows/ci.yaml + + lint: + uses: ./.github/workflows/lint.yaml + + release: + needs: [ci, lint] + uses: ./.github/workflows/release.yaml diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..ae07ca6 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,40 @@ +version: 2 + +builds: + - main: ./cmd/dcm + binary: dcm + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + ldflags: + - -s -w + - -X github.com/dcm-project/cli/internal/version.Version={{.Version}} + - -X github.com/dcm-project/cli/internal/version.Commit={{.Commit}} + - -X github.com/dcm-project/cli/internal/version.BuildTime={{.Date}} + +archives: + - format: tar.gz + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" + files: + - LICENSE + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: "checksums.txt" + +changelog: + use: github + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + - "^ci:" diff --git a/README.md b/README.md index 0bf4858..0da92f0 100644 --- a/README.md +++ b/README.md @@ -693,7 +693,12 @@ dcm-cli/ │ └── e2e_suite_test.go ├── .github/ │ └── workflows/ -│ └── ci.yaml +│ ├── ci.yaml +│ ├── lint.yaml +│ ├── check-clean-commits.yaml +│ ├── release.yaml +│ └── tag-release.yaml +├── .goreleaser.yaml ├── CLAUDE.md ├── Containerfile ├── go.mod @@ -918,7 +923,23 @@ build: go build -ldflags "$(LDFLAGS)" -o bin/dcm ./cmd/dcm ``` -### 10.3 Containerfile +### 10.3 Release + +Releases are automated via GoReleaser and GitHub Actions. When a `v*` tag is pushed, the `tag-release` workflow runs CI tests and linting, then triggers the `release` workflow which uses GoReleaser to: + +- Build `dcm` binaries for linux, darwin, and windows (amd64 and arm64) +- Inject version, commit, and build time via ldflags +- Create a GitHub release with archives and checksums +- Include the LICENSE in each archive + +To create a release: + +```bash +git tag v0.1.0 +git push origin v0.1.0 +``` + +### 10.4 Containerfile Multi-stage UBI9 build matching other DCM services: @@ -938,7 +959,7 @@ USER 1001 ENTRYPOINT ["dcm"] ``` -### 10.4 Go Module +### 10.5 Go Module ``` module github.com/dcm-project/dcm-cli @@ -946,7 +967,7 @@ module github.com/dcm-project/dcm-cli go 1.25.5 ``` -### 10.5 Dependencies +### 10.6 Dependencies | Dependency | Purpose | |------------|---------| @@ -958,7 +979,7 @@ go 1.25.5 | `github.com/onsi/ginkgo/v2` | Test framework (test dependency) | | `github.com/onsi/gomega` | Test matchers (test dependency) | -### 10.6 tools.go +### 10.7 tools.go ```go //go:build tools