diff --git a/.github/workflows/publish-cli.yaml b/.github/workflows/publish-cli.yaml new file mode 100644 index 0000000..bde8ba1 --- /dev/null +++ b/.github/workflows/publish-cli.yaml @@ -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/* diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..a1d7239 --- /dev/null +++ b/.goreleaser.yaml @@ -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 ' + 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 diff --git a/cli/main.go b/cli/main.go index 7e060b3..aa83799 100644 --- a/cli/main.go +++ b/cli/main.go @@ -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 {