Skip to content

Commit

Permalink
Create release for tags (#346)
Browse files Browse the repository at this point in the history
* release: Push release to stable branch on tag

* actions: Release new versions on tag creation
  • Loading branch information
kyleconroy committed Feb 18, 2020
1 parent 03fb99e commit 2471b6d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/equinox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- master
tags:
- '*'

jobs:

Expand All @@ -21,7 +23,7 @@ jobs:
env:
EQUINOX_API_TOKEN: ${{ secrets.EQUINOX_API_TOKEN }}
EQUINOX_SIGNING_KEY: ${{ secrets.EQUINOX_SIGNING_KEY }}
run: go run scripts/release.go -draft devel darwin_amd64
run: go run scripts/release.go -draft darwin_amd64

linux:
name: Build on Linux
Expand All @@ -39,6 +41,6 @@ jobs:
env:
EQUINOX_API_TOKEN: ${{ secrets.EQUINOX_API_TOKEN }}
EQUINOX_SIGNING_KEY: ${{ secrets.EQUINOX_SIGNING_KEY }}
run: go run scripts/release.go devel linux_amd64
run: go run scripts/release.go linux_amd64


21 changes: 16 additions & 5 deletions scripts/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ func main() {
draft := flag.Bool("draft", false, "create a draft release")
flag.Parse()

arch := flag.Arg(0)
if arch == "" {
log.Fatalf("missing platform_arch argument")
}

sha := os.Getenv("GITHUB_SHA")
ref := os.Getenv("GITHUB_REF")
cmd := exec.Command("git", "show", "--no-patch", "--no-notes", "--pretty=%ci", sha)
out, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -26,31 +32,36 @@ func main() {
date = strings.Replace(date, ":", "", -1)
version := fmt.Sprintf("v0.0.0-%s-%s", date, sha[:12])

x := "-X github.com/kyleconroy/sqlc/internal/cmd.version=" + version
log.Printf("Releasing %s on channel %s", flag.Arg(1), flag.Arg(0))

xname := "./equinox"
if _, err := os.Stat("./equinox"); os.IsNotExist(err) {
xname = "equinox"
}

channel := "devel"
if strings.HasPrefix(ref, "refs/tags/") {
channel = "stable"
version = strings.TrimPrefix(ref, "refs/tags/")
}

args := []string{"release",
"--channel", flag.Arg(0),
"--channel", channel,
"--version", version,
}

if *draft {
args = append(args, "--draft")
}

x := "-X github.com/kyleconroy/sqlc/internal/cmd.version=" + version
args = append(args, []string{
"--platforms", flag.Arg(1),
"--platforms", flag.Arg(0),
"--app", "app_i4iCp1SuYfZ",
"--token", os.Getenv("EQUINOX_API_TOKEN"),
"--",
"-ldflags", x, "./cmd/sqlc",
}...)

log.Printf("Releasing %s on channel %s", flag.Arg(0), channel)
cmd = exec.Command(xname, args...)
cmd.Env = os.Environ()
out, err = cmd.CombinedOutput()
Expand Down

0 comments on commit 2471b6d

Please sign in to comment.