Skip to content

Commit bb8df49

Browse files
committed
GoReleaser improvements
1 parent cb772fa commit bb8df49

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
name: Build
22

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
523
jobs:
624
build:
725
name: Build
@@ -49,24 +67,38 @@ jobs:
4967
name: Run govulncheck
5068
run: govulncheck ./...
5169

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:
5472
# git is currently in a dirty state
5573
# Please check in your pipeline what can be changing the following files:
5674
# ?? undefined/
5775
- 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'))
6078
run: git clean -xdf
6179

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)
6597
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'
6799
with:
68100
version: latest
69-
args: release --rm-dist
101+
args: release --clean --snapshot
70102
env:
71103
GOVERSION: ${{ steps.go-setup.outputs.go-version }}
72104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ release:
7272
<summary>Checksums</summary>
7373
<p></p>
7474
75-
Below are the SHA-256 checksums of release assets, the same that you can find in text file asset `npiperelay_checksums.txt`. Note that the .zip asset for the amd64 (x64, 64-bit) and 386 (x86, 32-bit) architectures both contain a single executable with name `npiperelay.exe`, and it is identical to the .exe asset with same name as the .zip asset, i.e. `npiperelay_windows_386.exe` and `npiperelay_windows_amd64.exe`, and should therefore have same checksums.
75+
The SHA-256 checksums of the binary release assets are published as text file asset `npiperelay_checksums.txt`. Note that the .zip asset for the amd64 (x64/64-bit) and 386 (x86/32-bit) architectures both contain a single executable with name `npiperelay.exe`, and it is identical to the .exe asset with same name as the .zip asset, i.e. `npiperelay_windows_386.exe` and `npiperelay_windows_amd64.exe`, and should therefore have the same checksum.
7676
<!--
77+
78+
These are the SHA-256 checksums of all binary release assets, as published in `npiperelay_checksums.txt`:
7779
```
7880
*** TODO: Copy content of npiperelay_checksums.txt here! ***
7981
```
@@ -86,7 +88,8 @@ release:
8688
8789
If your local antivirus treats the downloaded archive or executable as suspicious or malicious, you should try to report it as a false positive, e.g. to Symantec on [symsubmit.symantec.com](https://symsubmit.symantec.com) (select "Clean software incorrectly detected"). At the time of the release, no security vendors on [VirusTotal](https://www.virustotal.com) flagged the asset download urls as malicious, but some very few (well below 10%) did flag the zip archive and executable files themselves (see report for each of the assets in expandable section below). The implementation is less than 300 lines of go code, plus a single, commonly used, third party dependency. The source code is automatically run through a vulnerability analysis, using [govulncheck](https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck), and a long list of code quality checks (linters), using [golangci-lint](https://golangci-lint.run/) (see [.golangci.yml](https://github.com/albertony/npiperelay/blob/fork/.golangci.yml) for the complete list). If you do worry, you are free to analyse the code yourself, and you can also [build](https://github.com/albertony/npiperelay#building) the executable locally from source.
8890
<!--
89-
*** TODO: Analyse asset urls and files and update report links below! ***
91+
92+
*** TODO: Analyze asset urls and files, and update report links below! ***
9093
[VirusTotal](https://www.virustotal.com/) scan reports for release assets:
9194
- Asset download URLs:
9295
- npiperelay_windows_386.zip: [Report](https://www.virustotal.com/gui/url/??)

0 commit comments

Comments
 (0)