Skip to content

Commit 668ee94

Browse files
committed
ci: Switching to go releaser
Signed-off-by: Vincent Boutour <[email protected]>
1 parent 413150f commit 668ee94

File tree

5 files changed

+112
-45
lines changed

5 files changed

+112
-45
lines changed

.github/workflows/release.yaml

+18-21
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ permissions:
1414
security-events: none
1515

1616
on:
17-
release:
18-
types:
19-
- released
20-
21-
env:
22-
SCRIPTS_NO_INTERACTIVE: "true"
17+
push:
18+
tags:
19+
- "*"
2320

2421
defaults:
2522
run:
@@ -30,37 +27,37 @@ jobs:
3027
name: Release
3128
runs-on: ubuntu-latest
3229
env:
30+
docker_user: ${{ secrets.DOCKER_USER }}
3331
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
3432
steps:
3533
- name: Checkout
3634
uses: actions/checkout@v3
35+
with:
36+
fetch-depth: 0
3737
- name: Setup Golang
3838
uses: actions/setup-go@v3
3939
with:
4040
go-version: "^1.20"
4141
cache: true
42-
- name: Build
43-
run: make init
4442
- name: GPG
4543
id: import_gpg
4644
if: ${{ env.gpg_private_key != '' }}
4745
uses: crazy-max/ghaction-import-gpg@v5
4846
with:
4947
gpg_private_key: ${{ env.gpg_private_key }}
5048
passphrase: ${{ secrets.GPG_PASSPHRASE }}
51-
- name: Assets
49+
- name: Docker Hub
50+
if: ${{ env.docker_user != '' }}
51+
uses: docker/login-action@v2
52+
with:
53+
username: ${{ env.DOCKER_USER }}
54+
password: ${{ secrets.DOCKER_PASS }}
55+
- name: GoReleaser
56+
uses: goreleaser/goreleaser-action@v4
57+
with:
58+
distribution: goreleaser
59+
version: latest
60+
args: release --clean
5261
env:
5362
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5463
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
55-
run: |
56-
curl --disable --silent --show-error --location --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/main/bootstrap" | bash -s -- "-c" "release"
57-
export GIT_TAG="$(basename ${{ github.ref }})"
58-
scripts/release build assets clean
59-
- name: Docker
60-
if: ${{ env.docker_user != '' }}
61-
env:
62-
DOCKER_USER: ${{ env.docker_user }}
63-
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
64-
run: |
65-
curl --disable --silent --show-error --location --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/main/bootstrap" | bash -s -- "-c" "docker_promote"
66-
scripts/docker_promote "${{ env.DOCKER_USER }}/$(make name)" "$(make version-date)" "$(basename ${{ github.ref }})"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ scripts/
44
# Golang
55
.env
66
bin/
7+
dist/
78
release/
89
coverage.*
910
profile.out

.goreleaser.yaml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
before:
3+
hooks:
4+
- docker run -v "$(pwd):/tmp/" --rm "alpine" /bin/sh -c 'apk --update add tzdata ca-certificates zip && cd /usr/share/zoneinfo/ && zip -q -r -0 /tmp/zoneinfo.zip . && cp /etc/ssl/certs/ca-certificates.crt /tmp/ca-certificates.crt'
5+
6+
builds:
7+
- id: main
8+
binary: goweb
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
goarch:
16+
- amd64
17+
- arm64
18+
- arm
19+
goarm:
20+
- 7
21+
ignore:
22+
- goos: windows
23+
goarch: arm
24+
- goos: darwin
25+
goarch: arm
26+
ldflags:
27+
- -s -w
28+
main: ./cmd/goweb
29+
30+
signs:
31+
- artifacts: checksum
32+
args:
33+
- "--batch"
34+
- "-u"
35+
- "{{ .Env.GPG_FINGERPRINT }}"
36+
- "--output"
37+
- "${signature}"
38+
- "--detach-sign"
39+
- "${artifact}"
40+
41+
dockers:
42+
- image_templates:
43+
- "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}-amd64"
44+
use: buildx
45+
dockerfile: Dockerfile
46+
goos: linux
47+
goarch: amd64
48+
build_flag_templates:
49+
- "--platform=linux/amd64"
50+
- image_templates:
51+
- "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}-arm64"
52+
use: buildx
53+
dockerfile: Dockerfile
54+
goos: linux
55+
goarch: arm64
56+
build_flag_templates:
57+
- "--platform=linux/arm64"
58+
- image_templates:
59+
- "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}-arm"
60+
use: buildx
61+
dockerfile: Dockerfile
62+
goos: linux
63+
goarch: arm
64+
goarm: 7
65+
build_flag_templates:
66+
- "--platform=linux/arm/v7"
67+
68+
docker_manifests:
69+
- id: image
70+
name_template: "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}"
71+
image_templates:
72+
- "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}-amd64"
73+
- "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}-arm64"
74+
- "{{ .Env.DOCKER_USER }}/goweb:{{ .Version }}-arm"
75+
76+
release:
77+
github:
78+
owner: ViBiOh
79+
name: goweb
80+
81+
changelog:
82+
use: github
83+
sort: asc
84+
groups:
85+
- title: Features
86+
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
87+
order: 0
88+
- title: "Bug fixes"
89+
regexp: '^.*?bug(\([[:word:]]+\))??!?:.+$'
90+
order: 1
91+
- title: Others
92+
order: 999

Dockerfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ ENTRYPOINT [ "/goweb" ]
1313
ARG VERSION
1414
ENV VERSION=${VERSION}
1515

16-
ARG TARGETOS
17-
ARG TARGETARCH
18-
19-
COPY release/goweb_${TARGETOS}_${TARGETARCH} /goweb
16+
COPY goweb /goweb

docker-compose.yaml

-20
This file was deleted.

0 commit comments

Comments
 (0)