1
1
name : Build
2
2
3
- on : push
4
-
3
+ on :
4
+ # Run automatically when pushing a commit or tag.
5
+ push :
6
+ # Support manually running the workflow.
7
+ workflow_dispatch :
8
+ # Configurable input properties when running manually.
9
+ inputs :
10
+ # Option to run go-releaser, by default publishing a (draft) release from latest tag.
11
+ release :
12
+ description : Run GoReleaser step
13
+ type : boolean
14
+ required : true
15
+ default : false
16
+ # Additional option, when option release is true, to run as snapshot build from
17
+ # latest commit instead of latest tag and without publishing as a release.
18
+ snapshot :
19
+ description : GoReleaser Snapshot mode (latest commit, no publishing)
20
+ type : boolean
21
+ required : true
22
+ default : false
5
23
jobs :
6
24
build :
7
25
name : Build
@@ -49,24 +67,38 @@ jobs:
49
67
name : Run govulncheck
50
68
run : govulncheck ./...
51
69
52
- # If pushing v* tag: Clean workspace to remove remnants from the linter.
53
- # This will remove "undefined/", which avoids goreleaser failing with:
70
+ # If pushing v* tag, or manual run with option release : Clean workspace to remove remnants from the linter.
71
+ # This will remove "undefined/", which avoids go-release failing with:
54
72
# git is currently in a dirty state
55
73
# Please check in your pipeline what can be changing the following files:
56
74
# ?? undefined/
57
75
- id : clean
58
- name : Prepare go release (if pushing v-tag)
59
- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
76
+ name : Prepare go release (if pushing v-tag or triggered manually )
77
+ if : github.event.inputs.release == 'true' || (github. event_name == 'push' && startsWith(github.ref, 'refs/tags/v') )
60
78
run : git clean -xdf
61
79
62
- # If pushing v* tag: Build and create release.
63
- - id : go-release
64
- name : Run go release (if pushing v-tag)
80
+ # If pushing v* tag, or manual run with option "release" but not "snapshot": Build and create release from latest tag.
81
+ # Note: If manual run it must be on the tag (same commit), or else go-releaser will fail with: "git tag <tag_name> was not made against commit <commit_hash>",
82
+ # and one must consider using the snapshot mode instead (see below).
83
+ - id : go-release-tag
84
+ name : Run go release tag (if pushing v-tag or triggered manually)
85
+ uses : goreleaser/goreleaser-action@v4
86
+ if : (github.event.inputs.release == 'true' && github.event.inputs.snapshot != 'true') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
87
+ with :
88
+ version : latest
89
+ args : release --clean
90
+ env :
91
+ GOVERSION : ${{ steps.go-setup.outputs.go-version }}
92
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
93
+
94
+ # If manual run with options "release" and "snapshot": Build latest commit without publishing a release.
95
+ - id : go-release-snapshot
96
+ name : Run go release snapshot (if triggered manually)
65
97
uses : goreleaser/goreleaser-action@v4
66
- if : github.event_name == 'push ' && startsWith( github.ref, 'refs/tags/v')
98
+ if : github.event.inputs.release == 'true ' && github.event.inputs.snapshot == 'true'
67
99
with :
68
100
version : latest
69
- args : release --rm-dist
101
+ args : release --clean --snapshot
70
102
env :
71
103
GOVERSION : ${{ steps.go-setup.outputs.go-version }}
72
104
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments