Skip to content

Commit

Permalink
Merge pull request #6 from Peefy/add-brew-and-scoop-template
Browse files Browse the repository at this point in the history
feat: add homebrew, scoop and docker releases
  • Loading branch information
Peefy authored Nov 1, 2023
2 parents e3e3541 + a8bbc85 commit e93f8f8
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: 1.19

# <--- Login, build and push image to Docker Hub --->
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
62 changes: 62 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,65 @@ archives:
format_overrides:
- goos: windows
format: zip

dockers:
- use: buildx
goos: linux
goarch: amd64
dockerfile: Dockerfile
image_templates:
- kcllang/kclcli:{{ .Tag }}
build_flag_templates:
- "--target=goreleaser"
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"

docker_manifests:
- use: docker
name_template: kcllang/kcl:{{ .Tag }}
image_templates:
- kcllang/kcl:{{ .Tag }}-amd64
- use: docker
name_template: kcllang/kcl:latest
image_templates:
- kcllang/kcl:{{ .Tag }}-amd64

brews:
- tap:
owner: kcl-lang
name: homebrew-tap
url_template: "https://github.com/kcl-lang/cli/releases/download/{{ .Tag }}/kcl-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
download_strategy: CurlDownloadStrategy
# Git author used to commit to the repository.
# Defaults are shown.
commit_author:
name: GoReleaser Bot
email: [email protected]
folder: HomebrewFormula
homepage: "https://github.com/kcl-lang/kcl"
description: "KCL Command Line Interface"
license: "Apache License"
skip_upload: false
test: |
system "#{bin}/kcl version"
scoop:
url_template: "https://github.com/kcl-lang/cli/releases/download/{{ .Tag }}/kcl-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
bucket:
owner: kcl-lang
name: scoop-bucket
branch: main
token: "{{ .Env.GITHUB_TOKEN }}"
folder: Scoops
commit_author:
name: goreleaserbot
email: [email protected]
commit_msg_template: "Scoop update for kcl version {{ .Tag }}"
homepage: "http://github.com/kcl-lang/kcl"
description: "KCL Command Line Interface"
license: Apache License 2.0
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.19 AS build
COPY / /src
WORKDIR /src
RUN --mount=type=cache,target=/go/pkg --mount=type=cache,target=/root/.cache/go-build make build

FROM ubuntu:22.04 AS base
ENV LANG=en_US.utf8

FROM base
COPY --from=build /src/bin/kcl /usr/local/bin/kcl
RUN /usr/local/bin/kcl
11 changes: 10 additions & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

package version

import (
"fmt"
"runtime"
)

// version will be set by build flags.
var version string

Expand All @@ -19,7 +24,11 @@ type VersionType string

// String() will transform VersionType to string.
func (kvt VersionType) String() string {
return string(kvt)
return getVersion(string(kvt))
}

func getVersion(version string) string {
return fmt.Sprintf("%s-%s-%s", version, runtime.GOOS, runtime.GOARCH)
}

// All the kpm versions.
Expand Down

0 comments on commit e93f8f8

Please sign in to comment.