Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Add CI workflows to generate GitHub Releases and binaries on new tag …
Browse files Browse the repository at this point in the history
…push (pressly#277)
  • Loading branch information
mfridman authored Oct 13, 2021
1 parent f24b19c commit 97eae09
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 51 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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?
10 changes: 9 additions & 1 deletion cmd/goose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"runtime/debug"

"github.com/pressly/goose/v3"
)
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion goose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 97eae09

Please sign in to comment.