Skip to content

Commit 9ddc70c

Browse files
committed
Add goreleaser and CLI publish workflow
1 parent 650b556 commit 9ddc70c

File tree

3 files changed

+77
-6
lines changed

3 files changed

+77
-6
lines changed

.github/workflows/publish-cli.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Release CLI
2+
3+
on:
4+
push:
5+
tags:
6+
- cli/v*
7+
release:
8+
types:
9+
- published
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
goreleaser:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
- name: Set VERSION
23+
run: |
24+
TAG="${{ github.event.inputs.version || github.ref_name }}"
25+
# Get rid of the tag since the cli/ prefix confuses goreleaser.
26+
git tag -d $TAG
27+
echo "VERSION=${TAG#cli/v}" >> $GITHUB_ENV
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@v6
30+
with:
31+
distribution: goreleaser
32+
version: '~> v2'
33+
args: release --clean --snapshot --verbose
34+
env:
35+
VERSION: ${{ github.event.ref }}
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
- name: Upload assets
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: release
41+
path: dist/*

.goreleaser.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
snapshot:
3+
name_template: '{{.Env.VERSION}}'
4+
builds:
5+
- id: cli
6+
main: ./cli
7+
no_unique_dist_dir: true
8+
binary: fput-{{.Os}}-{{.Arch}}
9+
archives:
10+
- format: binary
11+
nfpms:
12+
- id: cli
13+
package_name: fluffy
14+
builds:
15+
- cli
16+
homepage: 'https://github.com/chriskuehl/fluffy'
17+
maintainer: 'Chris Kuehl <[email protected]>'
18+
description: 'command-line tools for uploading to fluffy servers'
19+
license: Apache-2.0
20+
formats:
21+
- deb
22+
- rpm
23+
- archlinux
24+
contents:
25+
- src: /usr/bin/fput-{{.Os}}-{{.Arch}}
26+
dst: /usr/bin/fpb
27+
type: symlink
28+
- src: /usr/bin/fput-{{.Os}}-{{.Arch}}
29+
dst: /usr/bin/fput
30+
type: symlink

cli/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,19 @@ func (v *regexpValue) Type() string {
412412
var regex = regexpValue{}
413413

414414
// This will be set by the linker for release builds.
415-
var Version string
415+
var version string
416416

417417
func init() {
418418
buildInfo, ok := debug.ReadBuildInfo()
419419
if !ok {
420420
panic("could not read build info")
421421
}
422-
if Version == "" {
423-
Version = buildInfo.Main.Version
422+
if version == "" {
423+
version = buildInfo.Main.Version
424424
}
425-
version := fmt.Sprintf("%s/%s", Version, buildInfo.GoVersion)
426-
fpbCommand.Version = version
427-
fputCommand.Version = version
425+
versionString := fmt.Sprintf("%s/%s", version, buildInfo.GoVersion)
426+
fpbCommand.Version = versionString
427+
fputCommand.Version = versionString
428428

429429
settings, err := getSettings()
430430
if err != nil {

0 commit comments

Comments
 (0)