Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
release:
types: [created]

permissions:
contents: write

jobs:
goreleaser:
name: GoReleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v6
with:
go-version: 1.25.x

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 39 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: 2

builds:
- id: saferwall-cli
binary: saferwall-cli
main: ./cli.go
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- arm64
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}}

archives:
- id: saferwall-cli
formats:
- tar.gz
format_overrides:
- goos: windows
formats:
- zip
name_template: >-
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}

checksum:
name_template: "checksums.txt"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^ci:"
7 changes: 7 additions & 0 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
"github.com/saferwall/cli/cmd"
)

var (
version = "dev"
commit = "none"
date = "unknown"
)

func main() {
cmd.SetVersionInfo(version, commit, date)
cmd.Execute()
}
21 changes: 18 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,30 @@ import (
"github.com/spf13/cobra"
)

const (
version = "0.5.0"
var (
version = "dev"
commit = "none"
date = "unknown"
)

// SetVersionInfo sets the build-time version information.
func SetVersionInfo(v, c, d string) {
if v != "" {
version = v
}
if c != "" {
commit = c
}
if d != "" {
date = d
}
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number",
Long: "Print the version number",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("You are using version %s\n", version)
fmt.Printf("You are using version %s (commit: %s, built: %s)\n", version, commit, date)
},
}