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 2bf6bc6
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/publish-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 }}"
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@v3
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
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 2bf6bc6

Please sign in to comment.