diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dc2dafe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +# https://goreleaser.com/ci/actions/#workflow +name: "goreleaser" + +on: + workflow_dispatch: + push: + tags: [ "v*" ] + +permissions: + contents: "write" + +jobs: + goreleaser: + runs-on: "ubuntu-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + with: + fetch-depth: 0 + + - name: "Set up Go" + uses: "actions/setup-go@v5" + with: + go-version-file: 'go.mod' + + - name: "Run GoReleaser" + uses: "goreleaser/goreleaser-action@v5" + with: + version: "latest" + args: "release --clean" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8d6cd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.env.local +/dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..96a77fd --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,37 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +before: + hooks: + - "go mod tidy" + +builds: + - env: + - "CGO_ENABLED=0" + goos: + - "freebsd" + - "linux" + goarch: + - "amd64" + - "arm64" + +archives: + - format: "tar.gz" + # use zip for windows archives + format_overrides: + - goos: "windows" + format: "zip" + +changelog: + sort: "asc" + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/cmd/root.go b/cmd/root.go index 8378330..66158c4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,7 +27,8 @@ func init() { rootCmd.AddCommand(&transferCmd) } -func Execute() { +func Execute(version string) { + rootCmd.Version = version if err := rootCmd.Execute(); err != nil { os.Exit(1) } diff --git a/main.go b/main.go index d33a729..2533118 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,9 @@ package main -import ( - "github.com/dsh2dsh/check_wg/cmd" -) +import "github.com/dsh2dsh/check_wg/cmd" + +var version string func main() { - cmd.Execute() + cmd.Execute(version) }