Skip to content

Commit

Permalink
Add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
mheap committed Jan 5, 2023
1 parent 831ed33 commit 4d55c49
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: release

on:
push:
tags:
- "v*.*"

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure git to use a PAT when cloning
run: |
git config --global url."https://api:${{ secrets.PAT }}@github.com/".insteadOf "https://github.com/"
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*
24 changes: 24 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
universal_binaries:
- replace: true
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
- freebsd
goarch:
- amd64
- arm64
ignore:
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm64
flags:
- -trimpath
ldflags:
- -s -w -X github.com/kong/deck/cmd.VERSION={{ .Tag }} -X github.com/kong/deck/cmd.COMMIT={{ .ShortCommit }}
snapshot:
name_template: "{{ .Tag }}"
29 changes: 29 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// VERSION is the current version of decK.
// This should be substituted by git tag during the build process.
var VERSION = "dev"

// COMMIT is the short hash of the source tree.
// This should be substituted by Git commit hash during the build process.
var COMMIT = "unknown"

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the kceD version",
Long: `The version command prints the version of kceD along with a Git short
commit hash of the source tree.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("kceD %s (%s) \n", VERSION, COMMIT)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}

0 comments on commit 4d55c49

Please sign in to comment.