diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6da55ae --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..2a99759 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,42 @@ +version: 2 + +project_name: devlocal + +before: + hooks: + - go mod tidy + +builds: + - id: devlocal + binary: devlocal + main: . + env: + - CGO_ENABLED=0 + + goos: + - windows + - linux + - darwin + + goarch: + - amd64 + - arm64 + + ldflags: + - >- + -s -w + -X github.com/RohitRavindra-dev/devlocal/internal/config.Version={{ .Version }} + -X github.com/RohitRavindra-dev/devlocal/internal/config.Commit={{ .Commit }} + -X github.com/RohitRavindra-dev/devlocal/internal/config.Date={{ .Date }} + +archives: + - formats: [zip] + name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} + +checksum: + name_template: checksums.txt + +release: + draft: false + prerelease: auto \ No newline at end of file diff --git a/cmd/version.go b/cmd/version.go index b758501..ca9603c 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -11,7 +11,7 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "Print version information", Run: func(cmd *cobra.Command, args []string) { - fmt.Println("devlocal", config.Version) + fmt.Println("[devlocal]", config.Version, config.Commit) }, } diff --git a/internal/config/constants.go b/internal/config/constants.go index 05c74c3..dc9e5b5 100644 --- a/internal/config/constants.go +++ b/internal/config/constants.go @@ -9,4 +9,6 @@ const ( var ( Version = "dev" + Commit = "none" + Date = "unknown" )