Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/bintray.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: bintray

on:
push:
branches:
- master

jobs:

macos:
name: release --platforms darwin
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.15'
- uses: jfrog/setup-jfrog-cli@v1
- id: gobuild
run: go run scripts/build/main.go
- run: echo ${{steps.gobuild.outputs.version}}
- run: zip -X -j sqlc-devel-darwin-amd64.zip ./sqlc
- run: tar -zcvf sqlc-devel-darwin-amd64.tar.gz ./sqlc
- run: jfrog bt upload --user kyleconroy --key "$BINTRAY_API_KEY" --publish --override "sqlc-devel-darwin-amd64.*" sqlc/devel/sqlc/${{steps.gobuild.outputs.version}} ${{steps.gobuild.outputs.version}}/

env:
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}

linux:
name: release --platforms linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.15'
- uses: jfrog/setup-jfrog-cli@v1
- id: gobuild
run: go run scripts/build/main.go
- run: echo ${{steps.gobuild.outputs.version}}
- run: zip -X -j sqlc-devel-linux-amd64.zip ./sqlc
- run: tar -zcvf sqlc-devel-linux-amd64.tar.gz ./sqlc
- run: jfrog bt upload --user kyleconroy --key "$BINTRAY_API_KEY" --publish --override "sqlc-devel-linux-amd64.*" sqlc/devel/sqlc/${{steps.gobuild.outputs.version}} ${{steps.gobuild.outputs.version}}/
env:
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
45 changes: 45 additions & 0 deletions scripts/build/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import (
"fmt"
"log"
"os"
"os/exec"
"strings"
)

func main() {
version := os.Getenv("VERSION")
sha := os.Getenv("GITHUB_SHA")

if version == "" {
cmd := exec.Command("git", "show", "--no-patch", "--no-notes", "--pretty=%ci", sha)
out, err := cmd.CombinedOutput()
if err != nil {
log.Println(strings.TrimSpace(string(out)))
log.Fatal(err)
}
var date string
parts := strings.Split(string(out), " ")
date = strings.Replace(parts[0]+parts[1], "-", "", -1)
date = strings.Replace(date, ":", "", -1)
version = fmt.Sprintf("v0.0.0-%s-%s", date, sha[:12])
}

fmt.Printf("::set-output name=version::%s\n", version)

x := "-X github.com/kyleconroy/sqlc/internal/cmd.version=" + version
args := []string{
"build",
"-ldflags", x,
"-o", "./sqlc",
"./cmd/sqlc",
}
cmd := exec.Command("go", args...)
cmd.Env = os.Environ()
out, err := cmd.CombinedOutput()
if err != nil {
log.Println(strings.TrimSpace(string(out)))
log.Fatal(err)
}
}