Repository navigation
feat(release): add release automation with goreleaser and release-please #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,3 +52,29 @@ jobs: | |
|
|
||
| - name: Build | ||
| run: go build -o blob . | ||
|
|
||
| release-dry-run: | ||
| name: Release (Dry Run) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Disable caching in setup-go to prevent cache poisoning attacks in release pipelines. Recommended Code Changes: |
||
| with: | ||
| go-version: "1.25" | ||
| cache: false | ||
|
|
||
| - name: Install Syft | ||
| uses: anchore/sbom-action/download-syft@0b82b0b1a22399a1c542d4d656f70cd903571b5c # v0.21.1 | ||
|
|
||
| - name: Run GoReleaser (snapshot) | ||
| uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 | ||
| with: | ||
| distribution: goreleaser | ||
| version: "~> v2" | ||
| args: release --snapshot --clean --skip=sign | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Release Please | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| release-please: | ||
| name: Release Please | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4 | ||
| with: | ||
| token: ${{ secrets.RELEASE_PAT }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "Tag to release (e.g., v1.0.0)" | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| id-token: write # Required for keyless Cosign signing | ||
|
|
||
| jobs: | ||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Add persist-credentials: false to the checkout action to prevent credentials from being accessible to subsequent workflow steps. Recommended Code Changes: |
||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ inputs.tag || github.ref }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Disable caching in setup-go to prevent cache poisoning attacks in release pipelines where artifacts are published. Recommended Code Changes: |
||
| uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0 | ||
| with: | ||
| go-version: "1.25" | ||
| cache: false | ||
|
|
||
| - name: Install Syft | ||
| uses: anchore/sbom-action/download-syft@0b82b0b1a22399a1c542d4d656f70cd903571b5c # v0.21.1 | ||
|
|
||
| - name: Install Cosign | ||
| uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0 | ||
|
|
||
| - name: Initialize Cosign cache | ||
| run: cosign initialize | ||
|
|
||
| - name: Run GoReleaser | ||
| uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0 | ||
| with: | ||
| distribution: goreleaser | ||
| version: "~> v2" | ||
| args: release --clean | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} | ||
| SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
| version: 2 | ||
|
|
||
| project_name: blob | ||
|
|
||
| before: | ||
| hooks: | ||
| - go mod tidy | ||
|
|
||
| builds: | ||
| - id: blob | ||
| main: . | ||
| binary: blob | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| - darwin | ||
| - windows | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| ignore: | ||
| - goos: windows | ||
| goarch: arm64 | ||
| ldflags: | ||
| - -s -w | ||
| - -X github.com/meigma/blob-cli/cmd.version={{.Version}} | ||
| - -X github.com/meigma/blob-cli/cmd.commit={{.ShortCommit}} | ||
| - -X github.com/meigma/blob-cli/cmd.date={{.Date}} | ||
|
|
||
| archives: | ||
| - id: default | ||
| formats: | ||
| - tar.gz | ||
| format_overrides: | ||
| - goos: windows | ||
| formats: | ||
| - zip | ||
| name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" | ||
| files: | ||
| - LICENSE* | ||
| - README* | ||
|
|
||
| checksum: | ||
| name_template: "checksums.txt" | ||
| algorithm: sha256 | ||
|
|
||
| sboms: | ||
| - artifacts: archive | ||
| documents: | ||
| - "${artifact}.sbom.spdx.json" | ||
| cmd: syft | ||
| args: | ||
| - "${artifact}" | ||
| - "--output" | ||
| - "spdx-json=${document}" | ||
|
|
||
| signs: | ||
| - id: checksum | ||
| cmd: flock | ||
| signature: "${artifact}.bundle" | ||
| args: | ||
| - "--exclusive" | ||
| - "/tmp/cosign.lock" | ||
| - "cosign" | ||
| - "sign-blob" | ||
| - "--bundle=${signature}" | ||
| - "${artifact}" | ||
| - "--yes" | ||
| artifacts: checksum | ||
|
|
||
| - id: sbom | ||
| cmd: flock | ||
| signature: "${artifact}.bundle" | ||
| args: | ||
| - "--exclusive" | ||
| - "/tmp/cosign.lock" | ||
| - "cosign" | ||
| - "sign-blob" | ||
| - "--bundle=${signature}" | ||
| - "${artifact}" | ||
| - "--yes" | ||
| artifacts: sbom | ||
|
|
||
| # Changelog is managed by release-please | ||
| changelog: | ||
| disable: true | ||
|
|
||
| brews: | ||
| - repository: | ||
| owner: meigma | ||
| name: homebrew-tap | ||
| token: "{{ .Env.HOMEBREW_TAP_TOKEN }}" | ||
| directory: Formula | ||
| homepage: "https://github.com/meigma/blob-cli" | ||
| description: "A CLI for working with blob archives in OCI registries" | ||
| license: "MIT" | ||
| skip_upload: auto | ||
| commit_msg_template: "brew: update {{ .ProjectName }} to {{ .Tag }}" | ||
| test: | | ||
| system "#{bin}/blob", "version" | ||
| install: | | ||
| bin.install "blob" | ||
|
|
||
| scoops: | ||
| - repository: | ||
| owner: meigma | ||
| name: scoop-bucket | ||
| token: "{{ .Env.SCOOP_BUCKET_TOKEN }}" | ||
| homepage: "https://github.com/meigma/blob-cli" | ||
| description: "A CLI for working with blob archives in OCI registries" | ||
| license: "MIT" | ||
| skip_upload: auto | ||
| commit_msg_template: "scoop: update {{ .ProjectName }} to {{ .Tag }}" | ||
|
|
||
| release: | ||
| github: | ||
| owner: meigma | ||
| name: blob-cli | ||
| # Append to the release created by release-please | ||
| mode: append | ||
| draft: false | ||
| prerelease: auto | ||
| name_template: "v{{.Version}}" | ||
| footer: | | ||
| ## Verification | ||
|
|
||
| Verify the checksums signature: | ||
| ```bash | ||
| cosign verify-blob \ | ||
| --bundle checksums.txt.bundle \ | ||
| --certificate-identity-regexp="https://github.com/meigma/blob-cli" \ | ||
| --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ | ||
| checksums.txt | ||
| ``` | ||
|
|
||
| Verify an SBOM signature: | ||
| ```bash | ||
| cosign verify-blob \ | ||
| --bundle blob_{{ .Version }}_linux_amd64.tar.gz.sbom.spdx.json.bundle \ | ||
| --certificate-identity-regexp="https://github.com/meigma/blob-cli" \ | ||
| --certificate-oidc-issuer="https://token.actions.githubusercontent.com" \ | ||
| blob_{{ .Version }}_linux_amd64.tar.gz.sbom.spdx.json | ||
| ``` | ||
|
|
||
| Verify artifact integrity: | ||
| ```bash | ||
| sha256sum -c checksums.txt --ignore-missing | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {".":"0.0.0"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Changelog |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // Build information set via ldflags. | ||
| var ( | ||
| version = "dev" | ||
| commit = "none" | ||
| date = "unknown" | ||
| ) | ||
|
|
||
| func init() { | ||
| rootCmd.AddCommand(versionCmd) | ||
| } | ||
|
|
||
| var versionCmd = &cobra.Command{ | ||
| Use: "version", | ||
| Short: "Print version information", | ||
| Run: func(_ *cobra.Command, _ []string) { | ||
| fmt.Printf("blob %s\n", version) | ||
| fmt.Printf(" commit: %s\n", commit) | ||
| fmt.Printf(" built: %s\n", date) | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", | ||
| "release-type": "go", | ||
| "include-v-in-tag": true, | ||
| "include-component-in-tag": false, | ||
| "bump-minor-pre-major": true, | ||
| "bump-patch-for-minor-pre-major": true, | ||
| "changelog-sections": [ | ||
| { "type": "feat", "section": "Features" }, | ||
| { "type": "fix", "section": "Bug Fixes" }, | ||
| { "type": "perf", "section": "Performance" }, | ||
| { "type": "refactor", "section": "Code Refactoring" }, | ||
| { "type": "docs", "section": "Documentation", "hidden": true }, | ||
| { "type": "style", "section": "Styles", "hidden": true }, | ||
| { "type": "chore", "section": "Miscellaneous", "hidden": true }, | ||
| { "type": "test", "section": "Tests", "hidden": true }, | ||
| { "type": "build", "section": "Build System", "hidden": true }, | ||
| { "type": "ci", "section": "Continuous Integration", "hidden": true } | ||
| ], | ||
| "packages": { | ||
| ".": { | ||
| "package-name": "blob" | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Add persist-credentials: false to the checkout action to prevent credentials from being accessible to subsequent workflow steps.
Recommended Code Changes: