Skip to content

Commit b7214d2

Browse files
authored
Merge pull request #136 from bavarianbidi/enable_release_build
goreleaser based release build
2 parents 8cf9368 + cb5a758 commit b7214d2

File tree

7 files changed

+211
-4
lines changed

7 files changed

+211
-4
lines changed

.github/workflows/release.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-License-Identifier: MIT
2+
3+
name: release
4+
5+
on:
6+
push:
7+
# run only against tags
8+
tags:
9+
- 'v*'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
goreleaser:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
19+
with:
20+
fetch-depth: 0
21+
22+
- run: git fetch --force --tags
23+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
24+
with:
25+
go-version-file: go.mod
26+
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 #v6.0.0
29+
with:
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ vendor
1818
*.dylib
1919
coverage.html
2020
.glide/
21+
# goreleaser builds
22+
dist/

.goreleaser.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SPDX-License-Identifier: MIT
2+
version: 2
3+
project_name: auger
4+
before:
5+
hooks:
6+
- go mod tidy
7+
builds:
8+
- id: auger
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- darwin
14+
goarch:
15+
- amd64
16+
- arm64
17+
ldflags:
18+
- -s -w
19+
- -X github.com/etcd-id/auger/cmd.appVersion={{.Version}}
20+
- -X github.com/etcd-id/auger/cmd.buildDate={{.Date}}
21+
- -X github.com/etcd-id/auger/cmd.gitCommit={{.Commit}}
22+
main: ./main.go
23+
binary: auger
24+
- id: augerctl
25+
env:
26+
- CGO_ENABLED=0
27+
goos:
28+
- linux
29+
- darwin
30+
goarch:
31+
- amd64
32+
- arm64
33+
ldflags:
34+
- -s -w
35+
- -X github.com/etcd-id/auger/command.appVersion={{.Version}}
36+
- -X github.com/etcd-id/auger/command.buildDate={{.Date}}
37+
- -X github.com/etcd-id/auger/command.gitCommit={{.Commit}}
38+
main: ./augerctl/main.go
39+
binary: augerctl
40+
41+
archives:
42+
- builds:
43+
- auger
44+
- augerctl
45+
46+
checksum:
47+
name_template: "checksums.txt"
48+
changelog:
49+
sort: asc
50+
use: github
51+
groups:
52+
- title: "Features"
53+
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
54+
order: 0
55+
- title: "Bug fixes"
56+
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
57+
order: 1
58+
- title: "Documentation"
59+
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
60+
order: 2
61+
- title: "Others"
62+
order: 999
63+
filters:
64+
exclude:
65+
- "^test:"
66+
release:
67+
github:
68+
owner: etcd-io
69+
name: auger
70+
prerelease: auto

RELEASE.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
The Auger Project is released on an as-needed basis. The process is as follows:
44

5-
1. An issue is proposing a new release with a changelog since the last release
6-
1. A quorum of [OWNERS](OWNERS) must LGTM this release
7-
1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`
8-
1. The release issue is closed
5+
1. Create a new git tag with `git tag -s $VERSION`
6+
1. Push the tag with `git push $VERSION`
7+
1. Once pushed, the [github workflow](.github/workflows/release.yaml) will automatically create a new release with the tag and changelog.

augerctl/command/ctl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ func NewCtlCommand() *cobra.Command {
5555
cmd.AddCommand(
5656
newCtlGetCommand(flags),
5757
)
58+
cmd.AddCommand(versionCmd)
5859
return cmd
5960
}

augerctl/command/version.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package command
18+
19+
import (
20+
"fmt"
21+
"runtime"
22+
23+
"github.com/spf13/cobra"
24+
)
25+
26+
// Version information
27+
var (
28+
// AppVersion is the version of the application
29+
appVersion = "v0.0.0-dev"
30+
31+
// BuildTime is the time the application was built
32+
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format
33+
34+
// GitCommit is the commit hash of the build
35+
gitCommit string
36+
)
37+
38+
var versionCmd = &cobra.Command{
39+
Use: "version",
40+
Short: "print current version",
41+
Run: func(_ *cobra.Command, _ []string) {
42+
fmt.Printf("Version:\t%s\n", appVersion)
43+
fmt.Printf("BuildTime:\t%s\n", buildDate)
44+
fmt.Printf("GitCommit:\t%s\n", gitCommit)
45+
fmt.Printf("GoVersion:\t%s\n", runtime.Version())
46+
fmt.Printf("Compiler:\t%s\n", runtime.Compiler)
47+
fmt.Printf("OS/Arch:\t%s/%s\n", runtime.GOOS, runtime.GOARCH)
48+
},
49+
}

cmd/version.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package cmd
18+
19+
import (
20+
"fmt"
21+
"runtime"
22+
23+
"github.com/spf13/cobra"
24+
)
25+
26+
// Version information
27+
var (
28+
// AppVersion is the version of the application
29+
appVersion = "v0.0.0-dev"
30+
31+
// BuildTime is the time the application was built
32+
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format
33+
34+
// GitCommit is the commit hash of the build
35+
gitCommit string
36+
)
37+
38+
var versionCmd = &cobra.Command{
39+
Use: "version",
40+
Short: "print current version",
41+
Run: func(_ *cobra.Command, _ []string) {
42+
fmt.Printf("Version:\t%s\n", appVersion)
43+
fmt.Printf("BuildTime:\t%s\n", buildDate)
44+
fmt.Printf("GitCommit:\t%s\n", gitCommit)
45+
fmt.Printf("GoVersion:\t%s\n", runtime.Version())
46+
fmt.Printf("Compiler:\t%s\n", runtime.Compiler)
47+
fmt.Printf("OS/Arch:\t%s/%s\n", runtime.GOOS, runtime.GOARCH)
48+
},
49+
}
50+
51+
func init() {
52+
RootCmd.AddCommand(versionCmd)
53+
}

0 commit comments

Comments
 (0)