Skip to content

Commit 0a98438

Browse files
authored
Add support for github releases (#277)
* Add build/signing/github release on tag push * Codesign the darwin and windows binaries to avoid annoying errors
1 parent 3d7b883 commit 0a98438

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
### This builds, packages, signs, performs AV and malware scanning, and
2+
### creates a new GitHub release for the newest version of go-getter.
3+
### The GitHub release step performs the actions outlined in
4+
### release.goreleaser.yml. A release is triggered when a new tag
5+
### is pushed in the format vX.X.X
6+
7+
name: Release
8+
9+
on:
10+
push:
11+
tags:
12+
- 'v[0-9]+.[0-9]+.[0-9]+*'
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
- name: Setup go
23+
uses: actions/setup-go@v2
24+
with:
25+
go-version: '^1.15'
26+
- name: Install hc-codesign
27+
id: codesign
28+
run: |
29+
docker login docker.pkg.github.com -u docker -p $GITHUB_TOKEN && \
30+
docker pull docker.pkg.github.com/hashicorp/hc-codesign/hc-codesign:$VERSION && \
31+
echo "::set-output name=image::docker.pkg.github.com/hashicorp/hc-codesign/hc-codesign:$VERSION"
32+
env:
33+
VERSION: v0
34+
GITHUB_TOKEN: ${{ secrets.CODESIGN_GITHUB_TOKEN }}
35+
- name: Install wget & clamAV antivirus scanner
36+
run : |
37+
sudo apt-get -qq install -y ca-certificates wget clamav
38+
wget --version
39+
- name: Install maldet malware scanner
40+
run: |
41+
wget --no-verbose -O maldet-$VERSION.tar.gz https://github.com/rfxn/linux-malware-detect/archive/$VERSION.tar.gz
42+
sha256sum -c - <<< "$SHA256SUM maldet-$VERSION.tar.gz"
43+
sudo mkdir -p maldet-$VERSION
44+
sudo tar -xzf maldet-$VERSION.tar.gz --strip-components=1 -C maldet-$VERSION
45+
cd maldet-$VERSION
46+
sudo ./install.sh
47+
sudo maldet -u
48+
env:
49+
VERSION: 1.6.4
50+
SHA256SUM: 3ad66eebd443d32dd6c811dcf2d264b78678c75ed1d40c15434180d4453e60d2
51+
- name: Import PGP key for archive signing
52+
run: echo -e $PGP_KEY | base64 -di | gpg --import --batch
53+
env:
54+
GPG_TTY: $(tty)
55+
PGP_KEY: ${{ secrets.PGP_SIGNING_KEY }}
56+
- name: GitHub Release
57+
uses: goreleaser/goreleaser-action@v1
58+
with:
59+
version: latest
60+
args: release --skip-validate --timeout "60m"
61+
env:
62+
PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }}
63+
CODESIGN_IMAGE: ${{ steps.codesign.outputs.image }}
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
66+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
67+
CIRCLE_TOKEN: ${{ secrets.CIRCLE_TOKEN }}
68+
- name: Run clamAV antivirus scanner
69+
run: sudo clamscan /home/runner/work/$REPO/$REPO/dist/
70+
env:
71+
REPO: ${{ github.event.repository.name }}
72+
- name: Run maldet malware scanner
73+
run: sudo maldet -a /home/runner/work/$REPO/$REPO/dist/
74+
env:
75+
REPO: ${{ github.event.repository.name }}
76+

.goreleaser.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
before:
2+
hooks:
3+
- go test ./...
4+
5+
builds:
6+
- id: signable
7+
mod_timestamp: '{{ .CommitTimestamp }}'
8+
targets:
9+
- darwin_amd64
10+
- windows_386
11+
- windows_amd64
12+
hooks:
13+
post: |
14+
docker run
15+
-e ARTIFACTORY_TOKEN={{ .Env.ARTIFACTORY_TOKEN }}
16+
-e ARTIFACTORY_USER={{ .Env.ARTIFACTORY_USER }}
17+
-e CIRCLE_TOKEN={{ .Env.CIRCLE_TOKEN }}
18+
-v {{ dir .Path }}:/workdir
19+
{{ .Env.CODESIGN_IMAGE }}
20+
sign -product-name={{ .ProjectName }} {{ .Name }}
21+
flags:
22+
- -trimpath
23+
ldflags:
24+
- -X main.GitCommit={{ .Commit }}
25+
- mod_timestamp: '{{ .CommitTimestamp }}'
26+
targets:
27+
- linux_386
28+
- linux_amd64
29+
flags:
30+
- -trimpath
31+
ldflags:
32+
- -X main.GitCommit={{ .Commit }}
33+
34+
archives:
35+
- format: zip
36+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
37+
files:
38+
- none*
39+
40+
checksum:
41+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
42+
algorithm: sha256
43+
44+
signs:
45+
- args: ["-u", "{{ .Env.PGP_KEY_ID }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
46+
artifacts: checksum
47+
48+
changelog:
49+
skip: true

0 commit comments

Comments
 (0)