-
Notifications
You must be signed in to change notification settings - Fork 4
59 lines (56 loc) · 1.92 KB
/
go-build-and-release.yml
File metadata and controls
59 lines (56 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Go build placeholder
on:
workflow_call:
inputs:
release_version:
description: Condition based on release branch build
required: false
type: string
secrets:
token:
description: 'Secret token from caller workflow to access private packages'
required: true
gpg_key:
description: 'GPG Private Key'
required: true
gpg_pass:
description: 'GPG Passphrase'
required: true
jobs:
run-goreleaser:
runs-on: ubuntu-latest
steps:
- uses: keyfactor/checkout@v4
with:
# Allow goreleaser to access older tag information.
fetch-depth: 0
- uses: keyfactor/setup-go@v5.0.1
with:
go-version-file: 'go.mod'
cache: true
- name: get-is-release
run: |
if [[ ("${{ github.event_name }}" == "pull_request") && "${{ inputs.release_version }}" != "" ]]; then
echo "GO_ARGS=release --clean" | tee -a "$GITHUB_ENV"
echo "VERSION=${{ inputs.release_version }}" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_STEP_SUMMARY"
else
echo "GO_ARGS=build --snapshot" | tee -a "$GITHUB_ENV"
echo "VERSION=0.0.0" | tee -a "$GITHUB_ENV" | tee -a "$GITHUB_STEP_SUMMARY"
fi
- name: Import GPG key
uses: keyfactor/ghaction-import-gpg@v6.1.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.gpg_key }}
passphrase: ${{ secrets.gpg_pass }}
- name: Run GoReleaser
uses: keyfactor/goreleaser-action@v6.0.0
with:
args: ${{ env.GO_ARGS }}
env:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_TTY: $(tty)
Version: ${{ env.VERSION }}