Skip to content

Commit

Permalink
Add goreleaser and CLI publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskuehl committed Aug 30, 2024
1 parent 650b556 commit 339baaf
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 7 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/publish-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish Release CLI

on:
push:
tags:
- cli/v*
release:
types:
- published

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
- name: Set VERSION
run: |
TAG="${{ github.event.inputs.version || github.ref_name }}"
# Get rid of the tag since the cli/ prefix confuses goreleaser.
git tag -d $TAG
echo VERSION=${TAG#cli/v} >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean --snapshot --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: release
path: dist/*
30 changes: 30 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
snapshot:
name_template: '{{.Env.VERSION}}'
builds:
- id: cli
main: ./cli
no_unique_dist_dir: true
binary: fput-{{.Os}}-{{.Arch}}
archives:
- format: binary
nfpms:
- id: cli
package_name: fluffy
builds:
- cli
homepage: 'https://github.com/chriskuehl/fluffy'
maintainer: 'Chris Kuehl <[email protected]>'
description: 'command-line tools for uploading to fluffy servers'
license: Apache-2.0
formats:
- deb
- rpm
- archlinux
contents:
- src: /usr/bin/fput-{{.Os}}-{{.Arch}}
dst: /usr/bin/fpb
type: symlink
- src: /usr/bin/fput-{{.Os}}-{{.Arch}}
dst: /usr/bin/fput
type: symlink
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export FLUFFY_SETTINGS := $(CURDIR)/settings.py
.PHONY: minimal
minimal: $(VENV) assets settings.py install-hooks

cli/cli: cli/main.go cli/go.mod
cli/cli: cli/main.go go.mod
cd cli && go build -o cli

$(VENV): setup.py requirements.txt requirements-dev.txt cli/cli
Expand Down
12 changes: 6 additions & 6 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,19 +412,19 @@ func (v *regexpValue) Type() string {
var regex = regexpValue{}

// This will be set by the linker for release builds.
var Version string
var version string

func init() {
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
panic("could not read build info")
}
if Version == "" {
Version = buildInfo.Main.Version
if version == "" {
version = buildInfo.Main.Version
}
version := fmt.Sprintf("%s/%s", Version, buildInfo.GoVersion)
fpbCommand.Version = version
fputCommand.Version = version
versionString := fmt.Sprintf("%s/%s", version, buildInfo.GoVersion)
fpbCommand.Version = versionString
fputCommand.Version = versionString

settings, err := getSettings()
if err != nil {
Expand Down

0 comments on commit 339baaf

Please sign in to comment.