Skip to content

Commit c7da51e

Browse files
authored
Ci/release binary action (#37)
* update gitignore file * ci: binary release
1 parent 1a8cc77 commit c7da51e

File tree

3 files changed

+141
-0
lines changed

3 files changed

+141
-0
lines changed

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Reference from:
2+
# https://goreleaser.com/ci/actions/
3+
name: Release
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
permissions:
9+
contents: write
10+
jobs:
11+
Test:
12+
name: Unit tests with coverage
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Go 1.18
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.18
23+
- run: go version
24+
- run: go env
25+
- run: go test ./...
26+
- run: go build
27+
- name: Running go tests with coverage
28+
env:
29+
GO111MODULE: on
30+
run: make cover
31+
- name: Send coverage
32+
uses: shogo82148/actions-goveralls@v1
33+
with:
34+
path-to-profile: coverage.out
35+
Publish: # Pack and publish image to Docker Hub and Github Release
36+
runs-on: ubuntu-latest
37+
needs: [Test]
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v2
41+
with:
42+
fetch-depth: 0
43+
- name: Set up Go
44+
uses: actions/setup-go@v2
45+
with:
46+
go-version: 1.18
47+
# <--- Login, build and push image to Docker Hub --->
48+
- name: Login to Docker Hub
49+
uses: docker/login-action@v2
50+
with:
51+
username: ${{ secrets.DOCKERHUB_USERNAME }}
52+
password: ${{ secrets.DOCKERHUB_TOKEN }}
53+
# <--- End --->
54+
- name: Run GoReleaser
55+
uses: goreleaser/goreleaser-action@v4
56+
with:
57+
distribution: goreleaser
58+
version: latest
59+
args: release --rm-dist
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.KUSIONSTACK_BOT_TOKEN }}
62+
RELEASE_VERSION: ${{ github.ref }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# ide
55
.idea/
66
*.iml
7+
.vscode/
78

89
# build
910
_build

.goreleaser.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This is an example .goreleaser.yml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
builds:
8+
- id: default
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
goarch:
16+
- amd64
17+
- arm64
18+
# 使用 ldflags="-s -w" 去掉符号表和调试信息,以减少发布包的大小
19+
ldflags:
20+
- -s
21+
- -w
22+
ignore:
23+
- goos: linux
24+
goarch: arm64
25+
- goos: windows
26+
goarch: arm64
27+
main: .
28+
archives:
29+
- id: default
30+
builds:
31+
- default
32+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
33+
format_overrides:
34+
- goos: windows
35+
format: zip
36+
checksum:
37+
name_template: 'checksums.txt'
38+
changelog:
39+
use: github
40+
sort: asc
41+
filters:
42+
exclude:
43+
- '^docs:'
44+
- '^test:'
45+
release:
46+
github:
47+
owner: KusionStack
48+
name: kcl-openapi
49+
draft: false
50+
footer: |
51+
## Docker Images
52+
* `kusionstack/kcl-openapi:{{ .Env.RELEASE_VERSION }}`
53+
dockers:
54+
- use: buildx
55+
goos: linux
56+
goarch: amd64
57+
dockerfile: Dockerfile
58+
image_templates:
59+
- kusionstack/{{ .ProjectName }}:{{ .Tag }}-amd64
60+
build_flag_templates:
61+
- "--target=goreleaser"
62+
- "--pull"
63+
- "--label=org.opencontainers.image.created={{.Date}}"
64+
- "--label=org.opencontainers.image.name={{.ProjectName}}"
65+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
66+
- "--label=org.opencontainers.image.version={{.Version}}"
67+
- "--label=org.opencontainers.image.source={{.GitURL}}"
68+
- "--platform=linux/amd64"
69+
70+
docker_manifests:
71+
- use: docker
72+
name_template: kusionstack/{{ .ProjectName }}:{{ .Tag }}
73+
image_templates:
74+
- kusionstack/{{ .ProjectName }}:{{ .Tag }}-amd64
75+
- use: docker
76+
name_template: kusionstack/{{ .ProjectName }}:latest
77+
image_templates:
78+
- kusionstack/{{ .ProjectName }}:{{ .Tag }}-amd64

0 commit comments

Comments
 (0)