Add CI workflows to generate GitHub Releases and binaries on new tag push (#277)

pull/256/merge
Michael Fridman 2021-10-13 09:06:10 -04:00 committed by GitHub
parent f24b19cca8
commit 97eae0915c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 2 deletions

30
.github/workflows/goreleaser.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: goreleaser
on:
push:
tags:
- "*"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

51
.goreleaser.yml Normal file
View File

@ -0,0 +1,51 @@
# Documentation at https://goreleaser.com
project_name: goose
gomod:
proxy: true
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/goose
binary: goose
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
# Custom ldflags templates.
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser`.
ldflags:
- -s -w
# You can disable this pipe in order to not upload any artifacts.
# Defaults to false.
release:
disable: false
archives:
- replacements:
386: i386
amd64: x86_64
name_template: "{{ tolower .Binary }}_{{ tolower .Os }}_{{ tolower .Arch }}"
format: binary
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
use: github
sort: asc
# Commit messages matching the regexp listed here will be removed from
# the changelog.
filters:
exclude:
- "^docs:"
- "^test:"
# TODO(mf): add docker support?

View File

@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"runtime/debug"
"github.com/pressly/goose/v3"
)
@ -20,12 +21,19 @@ var (
sequential = flags.Bool("s", false, "use sequential numbering for new migrations")
)
var (
gooseVersion = ""
)
func main() {
flags.Usage = usage
flags.Parse(os.Args[1:])
if *version {
fmt.Println(goose.VERSION)
if buildInfo, ok := debug.ReadBuildInfo(); ok && buildInfo != nil && gooseVersion == "" {
gooseVersion = buildInfo.Main.Version
}
fmt.Printf("goose version:%s\n", gooseVersion)
return
}
if *verbose {

View File

@ -7,7 +7,8 @@ import (
"strconv"
)
const VERSION = "v3.0.0"
// Deprecated: VERSION will no longer be supported in v4.
const VERSION = "v3.2.0"
var (
minVersion = int64(0)