Skip to content

Commit d65b1f3

Browse files
Merge pull request #11 from RohitRavindra-dev/feat/v2/cicd
Feat: added release workflow using goreleaser
2 parents 1c79141 + 55ef9be commit d65b1f3

4 files changed

Lines changed: 79 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
persist-credentials: false
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v6
29+
with:
30+
distribution: goreleaser
31+
version: "~> v2"
32+
args: release --clean
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: 2
2+
3+
project_name: devlocal
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
9+
builds:
10+
- id: devlocal
11+
binary: devlocal
12+
main: .
13+
env:
14+
- CGO_ENABLED=0
15+
16+
goos:
17+
- windows
18+
- linux
19+
- darwin
20+
21+
goarch:
22+
- amd64
23+
- arm64
24+
25+
ldflags:
26+
- >-
27+
-s -w
28+
-X github.com/RohitRavindra-dev/devlocal/internal/config.Version={{ .Version }}
29+
-X github.com/RohitRavindra-dev/devlocal/internal/config.Commit={{ .Commit }}
30+
-X github.com/RohitRavindra-dev/devlocal/internal/config.Date={{ .Date }}
31+
32+
archives:
33+
- formats: [zip]
34+
name_template: >-
35+
{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}
36+
37+
checksum:
38+
name_template: checksums.txt
39+
40+
release:
41+
draft: false
42+
prerelease: auto

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var versionCmd = &cobra.Command{
1111
Use: "version",
1212
Short: "Print version information",
1313
Run: func(cmd *cobra.Command, args []string) {
14-
fmt.Println("devlocal", config.Version)
14+
fmt.Println("[devlocal]", config.Version, config.Commit)
1515
},
1616
}
1717

internal/config/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ const (
99

1010
var (
1111
Version = "dev"
12+
Commit = "none"
13+
Date = "unknown"
1214
)

0 commit comments

Comments
 (0)