diff --git a/.github/workflows/ci-kotlin.yml b/.github/workflows/ci-kotlin.yml index f864c2fc7e..d383d5477f 100644 --- a/.github/workflows/ci-kotlin.yml +++ b/.github/workflows/ci-kotlin.yml @@ -1,9 +1,9 @@ -name: sqlc kotlin test suite +name: gradle on: [push, pull_request] jobs: build: - name: Build And Test + name: test runs-on: ubuntu-latest services: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 190f72991d..bc9a83c277 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,9 @@ -name: sqlc test suite +name: go on: [push, pull_request] jobs: build: - name: Build + name: test runs-on: ubuntu-latest services: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..64e2da2a84 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,22 @@ +name: docker + +on: + push: + branches: + - master + +jobs: + + docker: + name: push kjconroy/sqlc:devel + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: docker/build-push-action@v1 + with: + username: kjconroy + password: ${{ secrets.DOCKER_PASSWORD }} + build_args: github_ref=${{ github.ref }},github_sha=${{ github.sha }} + repository: kjconroy/sqlc + add_git_labels: true + tags: devel diff --git a/.github/workflows/equinox.yml b/.github/workflows/equinox.yml index 68ccbb0fe6..32bf0dcb2c 100644 --- a/.github/workflows/equinox.yml +++ b/.github/workflows/equinox.yml @@ -1,4 +1,4 @@ -name: Publish to Equinox +name: equinox on: push: @@ -10,7 +10,7 @@ on: jobs: macos: - name: Build on macOS + name: release --platforms darwin runs-on: macos-latest steps: - uses: actions/checkout@master @@ -26,7 +26,7 @@ jobs: run: go run scripts/release.go -draft darwin_amd64 linux: - name: Build on Linux + name: release --platforms linux runs-on: ubuntu-latest needs: [macos] steps: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..f68007344c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# STEP 1: Build sqlc +FROM golang:1.13 AS builder + +COPY . /workspace +WORKDIR /workspace + +ARG github_ref +ARG github_sha +ENV GITHUB_REF=$github_ref +ENV GITHUB_SHA=$github_sha +RUN go run scripts/release.go -docker + +# STEP 2: Build a tiny image +FROM scratch + +COPY --from=builder /workspace/sqlc /workspace/sqlc +ENTRYPOINT ["/workspace/sqlc"] diff --git a/scripts/release.go b/scripts/release.go index b6cd1c077a..701de76d08 100755 --- a/scripts/release.go +++ b/scripts/release.go @@ -11,18 +11,15 @@ import ( func main() { draft := flag.Bool("draft", false, "create a draft release") + docker := flag.Bool("docker", false, "create a docker 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 { + log.Println(strings.TrimSpace(string(out))) log.Fatal(err) } @@ -32,6 +29,30 @@ func main() { date = strings.Replace(date, ":", "", -1) version := fmt.Sprintf("v0.0.0-%s-%s", date, sha[:12]) + if *docker { + x := "-extldflags \"-static\" -X github.com/kyleconroy/sqlc/internal/cmd.version=" + version + args := []string{ + "build", + "-a", + "-ldflags", x, + "-o", "/workspace/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) + } + return + } + + arch := flag.Arg(0) + if arch == "" { + log.Fatalf("missing platform_arch argument") + } + xname := "./equinox" if _, err := os.Stat("./equinox"); os.IsNotExist(err) { xname = "equinox" @@ -65,8 +86,8 @@ func main() { cmd = exec.Command(xname, args...) cmd.Env = os.Environ() out, err = cmd.CombinedOutput() - log.Println(strings.TrimSpace(string(out))) if err != nil { + log.Println(strings.TrimSpace(string(out))) log.Fatal(err) } }