Skip to content

Commit df30bbf

Browse files
authored
Upload binaries to Bintray (#861)
1 parent a905a74 commit df30bbf

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

.github/workflows/bintray.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: bintray
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
10+
macos:
11+
name: release --platforms darwin
12+
runs-on: macos-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: '1.15'
19+
- uses: jfrog/setup-jfrog-cli@v1
20+
- id: gobuild
21+
run: go run scripts/build/main.go
22+
- run: echo ${{steps.gobuild.outputs.version}}
23+
- run: zip -X -j sqlc-devel-darwin-amd64.zip ./sqlc
24+
- run: tar -zcvf sqlc-devel-darwin-amd64.tar.gz ./sqlc
25+
- 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}}/
26+
27+
env:
28+
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
29+
30+
linux:
31+
name: release --platforms linux
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v2
35+
- name: Set up Go
36+
uses: actions/setup-go@v2
37+
with:
38+
go-version: '1.15'
39+
- uses: jfrog/setup-jfrog-cli@v1
40+
- id: gobuild
41+
run: go run scripts/build/main.go
42+
- run: echo ${{steps.gobuild.outputs.version}}
43+
- run: zip -X -j sqlc-devel-linux-amd64.zip ./sqlc
44+
- run: tar -zcvf sqlc-devel-linux-amd64.tar.gz ./sqlc
45+
- 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}}/
46+
env:
47+
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}

scripts/build/main.go

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
"os/exec"
8+
"strings"
9+
)
10+
11+
func main() {
12+
version := os.Getenv("VERSION")
13+
sha := os.Getenv("GITHUB_SHA")
14+
15+
if version == "" {
16+
cmd := exec.Command("git", "show", "--no-patch", "--no-notes", "--pretty=%ci", sha)
17+
out, err := cmd.CombinedOutput()
18+
if err != nil {
19+
log.Println(strings.TrimSpace(string(out)))
20+
log.Fatal(err)
21+
}
22+
var date string
23+
parts := strings.Split(string(out), " ")
24+
date = strings.Replace(parts[0]+parts[1], "-", "", -1)
25+
date = strings.Replace(date, ":", "", -1)
26+
version = fmt.Sprintf("v0.0.0-%s-%s", date, sha[:12])
27+
}
28+
29+
fmt.Printf("::set-output name=version::%s\n", version)
30+
31+
x := "-X github.com/kyleconroy/sqlc/internal/cmd.version=" + version
32+
args := []string{
33+
"build",
34+
"-ldflags", x,
35+
"-o", "./sqlc",
36+
"./cmd/sqlc",
37+
}
38+
cmd := exec.Command("go", args...)
39+
cmd.Env = os.Environ()
40+
out, err := cmd.CombinedOutput()
41+
if err != nil {
42+
log.Println(strings.TrimSpace(string(out)))
43+
log.Fatal(err)
44+
}
45+
}

0 commit comments

Comments
 (0)