Skip to content

Commit 0004158

Browse files
authored
Add support for signing releases with GoReleaser (#78)
1 parent 4701c36 commit 0004158

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: CI
22

33
on:
4+
push:
5+
branches:
6+
- '**'
47
pull_request:
58
branches: [ main ]
69

.github/workflows/deploy.yml

+21-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: Deploy
22

33
on:
44
push:
5+
branches:
6+
- '**'
57
tags:
6-
- v*
8+
- 'v*'
79
pull_request:
810
branches: [ main ]
911

@@ -17,21 +19,27 @@ jobs:
1719
with:
1820
fetch-depth: 0
1921

22+
- name: Import GPG Key
23+
id: import_gpg
24+
uses: crazy-max/ghaction-import-gpg@v3
25+
with:
26+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
28+
2029
- name: Install Go
2130
uses: actions/setup-go@v2
2231
with:
2332
go-version: 1.15
2433

2534
- name: Create release
2635
run: |
27-
SNAPSHOT="--snapshot"
2836
if [[ $GITHUB_REF == refs/tags/* ]]; then
29-
SNAPSHOT=""
37+
export GORELEASER_ARGS="--rm-dist"
3038
fi
31-
GORELEASER_ARGS="--rm-dist ${SNAPSHOT}" make release
39+
make release
3240
env:
3341
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
42+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
3543

3644
docker:
3745
name: Docker
@@ -52,6 +60,13 @@ jobs:
5260
MAJOR_MINOR=${TAG%.*}
5361
echo ::set-output name=tags::${IMG}:${TAG},${IMG}:${MAJOR_MINOR}
5462
63+
elif [[ $GITHUB_REF == refs/heads/* ]]; then
64+
TAG=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
65+
if [ "${{ github.event.repository.default_branch }}" = "$TAG" ]; then
66+
TAG=edge
67+
fi
68+
echo ::set-output name=tags::${IMG}:${TAG}
69+
5570
elif [[ $GITHUB_REF == refs/pull/* ]]; then
5671
TAG=pr-${{ github.event.number }}
5772
echo ::set-output name=tags::${IMG}:${TAG}
@@ -73,5 +88,5 @@ jobs:
7388
with:
7489
context: .
7590
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
76-
push: ${{ github.event_name != 'pull_request' }}
91+
push: ${{ (github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/')) }}
7792
tags: ${{ steps.prep.outputs.tags }}

.goreleaser.yml

+4
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ archives:
4545

4646
checksum:
4747
name_template: "checksums.txt"
48+
49+
signs:
50+
- artifacts: checksum
51+
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]

0 commit comments

Comments
 (0)