Skip to content

Commit a8bbc85

Browse files
committed
feat: add homebrew, scoop and docker releases
Signed-off-by: peefy <xpf6677@163.com>
1 parent e3e3541 commit a8bbc85

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ jobs:
1919
uses: actions/setup-go@v2
2020
with:
2121
go-version: 1.19
22+
23+
# <--- Login, build and push image to Docker Hub --->
24+
- name: Login to Docker Hub
25+
uses: docker/login-action@v2
26+
with:
27+
username: ${{ secrets.DOCKER_USERNAME }}
28+
password: ${{ secrets.DOCKER_PASSWORD }}
29+
2230
- name: Run GoReleaser
2331
uses: goreleaser/goreleaser-action@v4
2432
with:

.goreleaser.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,65 @@ archives:
3030
format_overrides:
3131
- goos: windows
3232
format: zip
33+
34+
dockers:
35+
- use: buildx
36+
goos: linux
37+
goarch: amd64
38+
dockerfile: Dockerfile
39+
image_templates:
40+
- kcllang/kclcli:{{ .Tag }}
41+
build_flag_templates:
42+
- "--target=goreleaser"
43+
- "--pull"
44+
- "--label=org.opencontainers.image.created={{.Date}}"
45+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
46+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
47+
- "--label=org.opencontainers.image.version={{.Version}}"
48+
- "--label=org.opencontainers.image.source={{.GitURL}}"
49+
- "--platform=linux/amd64"
50+
51+
docker_manifests:
52+
- use: docker
53+
name_template: kcllang/kcl:{{ .Tag }}
54+
image_templates:
55+
- kcllang/kcl:{{ .Tag }}-amd64
56+
- use: docker
57+
name_template: kcllang/kcl:latest
58+
image_templates:
59+
- kcllang/kcl:{{ .Tag }}-amd64
60+
61+
brews:
62+
- tap:
63+
owner: kcl-lang
64+
name: homebrew-tap
65+
url_template: "https://github.com/kcl-lang/cli/releases/download/{{ .Tag }}/kcl-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
66+
download_strategy: CurlDownloadStrategy
67+
# Git author used to commit to the repository.
68+
# Defaults are shown.
69+
commit_author:
70+
name: GoReleaser Bot
71+
email: goreleaser@carlosbecker.com
72+
folder: HomebrewFormula
73+
homepage: "https://github.com/kcl-lang/kcl"
74+
description: "KCL Command Line Interface"
75+
license: "Apache License"
76+
skip_upload: false
77+
test: |
78+
system "#{bin}/kcl version"
79+
80+
scoop:
81+
url_template: "https://github.com/kcl-lang/cli/releases/download/{{ .Tag }}/kcl-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
82+
bucket:
83+
owner: kcl-lang
84+
name: scoop-bucket
85+
branch: main
86+
token: "{{ .Env.GITHUB_TOKEN }}"
87+
folder: Scoops
88+
commit_author:
89+
name: goreleaserbot
90+
email: bot@goreleaser.com
91+
commit_msg_template: "Scoop update for kcl version {{ .Tag }}"
92+
homepage: "http://github.com/kcl-lang/kcl"
93+
description: "KCL Command Line Interface"
94+
license: Apache License 2.0

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM golang:1.19 AS build
2+
COPY / /src
3+
WORKDIR /src
4+
RUN --mount=type=cache,target=/go/pkg --mount=type=cache,target=/root/.cache/go-build make build
5+
6+
FROM ubuntu:22.04 AS base
7+
ENV LANG=en_US.utf8
8+
9+
FROM base
10+
COPY --from=build /src/bin/kcl /usr/local/bin/kcl
11+
RUN /usr/local/bin/kcl

pkg/version/version.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
package version
44

5+
import (
6+
"fmt"
7+
"runtime"
8+
)
9+
510
// version will be set by build flags.
611
var version string
712

@@ -19,7 +24,11 @@ type VersionType string
1924

2025
// String() will transform VersionType to string.
2126
func (kvt VersionType) String() string {
22-
return string(kvt)
27+
return getVersion(string(kvt))
28+
}
29+
30+
func getVersion(version string) string {
31+
return fmt.Sprintf("%s-%s-%s", version, runtime.GOOS, runtime.GOARCH)
2332
}
2433

2534
// All the kpm versions.

0 commit comments

Comments
 (0)