Skip to content

Commit 5a6ee6f

Browse files
committed
feat(release): docker image build
1 parent 35adc98 commit 5a6ee6f

File tree

3 files changed

+104
-26
lines changed

3 files changed

+104
-26
lines changed

.github/workflows/release.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
1919
- name: Set up Go
20-
uses: actions/setup-go@v2
20+
uses: actions/setup-go@v3
2121
with:
2222
go-version: 1.19
2323
- name: Generate token
@@ -27,6 +27,14 @@ jobs:
2727
app_id: ${{ secrets.APP_ID }}
2828
private_key: ${{ secrets.PRIVATE_KEY }}
2929
repository: sunggun-yu/homebrew-tap
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v2
32+
- name: Docker Login
33+
uses: docker/login-action@v2
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
3038
- name: Run GoReleaser
3139
uses: goreleaser/goreleaser-action@v2
3240
with:

.goreleaser.yaml

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
3-
41
project_name: gh-app-access-token
5-
2+
env:
3+
- DOCKER_REGISTRY=ghcr.io/sunggun-yu
4+
- DESCRIPTION=Semantic Version Utility
5+
- HOME_PAGE=https://github.com/sunggun-yu/{{ .ProjectName }}
66
before:
77
hooks:
88
- go mod tidy
@@ -17,44 +17,111 @@ builds:
1717
goarch:
1818
- amd64
1919
- arm64
20-
goarm:
21-
- "6"
22-
- "7"
23-
ignore:
24-
- goos: windows
25-
goarch: arm64
20+
mod_timestamp: '{{ .CommitTimestamp }}'
21+
22+
universal_binaries:
23+
- replace: true
24+
2625
archives:
27-
- format: tar.gz
26+
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
2827
wrap_in_directory: "true"
2928
format_overrides:
3029
- goos: windows
3130
format: zip
31+
3232
checksum:
3333
name_template: 'checksums.txt'
3434
algorithm: sha256
35+
3536
snapshot:
3637
name_template: "{{ incpatch .Version }}-next"
38+
3739
changelog:
3840
sort: asc
41+
use: github
3942
filters:
4043
exclude:
41-
- '^docs:'
42-
- '^test:'
43-
- "README"
44-
- "Merge pull request"
45-
- "Merge branch"
44+
- '^docs:'
45+
- '^test:'
46+
- '^chore'
47+
- 'merge conflict'
48+
- "README"
49+
- Merge pull request
50+
- Merge remote-tracking branch
51+
- Merge branch
52+
- go mod tidy
53+
groups:
54+
- title: Dependency updates
55+
regexp: "^.*feat\\(deps\\)*:+.*$"
56+
order: 300
57+
- title: 'New Features'
58+
regexp: "^.*feat[(\\w)]*:+.*$"
59+
order: 100
60+
- title: 'Bug fixes'
61+
regexp: "^.*fix[(\\w)]*:+.*$"
62+
order: 200
63+
- title: 'Documentation updates'
64+
regexp: "^.*docs[(\\w)]*:+.*$"
65+
order: 400
66+
- title: Other work
67+
order: 9999
4668

4769
brews:
70+
# https://goreleaser.com/customization/homebrew/
4871
- name: "gh-app-access-token"
4972
tap:
5073
owner: sunggun-yu
5174
name: homebrew-tap
52-
branch: main
53-
description: "Cli wrapper to set profile based environment variables for your command line execution"
54-
homepage: https://github.com/sunggun-yu/gh-app-access-token
5575
folder: Formula
56-
download_strategy: CurlDownloadStrategy
57-
install: |
58-
bin.install "{{ .ProjectName }}"
59-
test: |
60-
system "#{bin}/{{ .ProjectName }} -v"
76+
homepage: '{{ .Env.HOME_PAGE }}'
77+
description: '{{ .Env.DESCRIPTION }}'
78+
79+
nfpms:
80+
# https://goreleaser.com/customization/nfpm/
81+
- homepage: '{{ .Env.HOME_PAGE }}'
82+
description: '{{ .Env.DESCRIPTION }}'
83+
maintainer: Sunggun Yu <[email protected]>
84+
license: MIT
85+
vendor: Sunggun Yu
86+
formats:
87+
- apk
88+
- deb
89+
- rpm
90+
91+
dockers:
92+
# https://goreleaser.com/customization/docker/
93+
- use: buildx
94+
goos: linux
95+
goarch: amd64
96+
dockerfile: Dockerfile
97+
image_templates:
98+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-amd64"
99+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:latest-amd64"
100+
build_flag_templates:
101+
- "--platform=linux/amd64"
102+
- "--label=org.opencontainers.image.created={{.Date}}"
103+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
104+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
105+
- "--label=org.opencontainers.image.version={{.Version}}"
106+
- use: buildx
107+
goos: linux
108+
goarch: arm64
109+
image_templates:
110+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-arm64v8"
111+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:latest-arm64v8"
112+
build_flag_templates:
113+
- "--platform=linux/arm64/v8"
114+
- "--label=org.opencontainers.image.created={{.Date}}"
115+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
116+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
117+
- "--label=org.opencontainers.image.version={{.Version}}"
118+
docker_manifests:
119+
# https://goreleaser.com/customization/docker_manifest/
120+
- name_template: "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:{{ .Version }}"
121+
image_templates:
122+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-amd64"
123+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:{{ .Version }}-arm64v8"
124+
- name_template: "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:latest"
125+
image_templates:
126+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:latest-amd64"
127+
- "{{ .Env.DOCKER_REGISTRY }}/{{ .ProjectName }}:latest-arm64v8"

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine
2+
COPY gh-app-access-token /usr/local/bin/gh-app-access-token
3+
ENTRYPOINT ["/usr/local/bin/gh-app-access-token"]

0 commit comments

Comments
 (0)