diff --git a/.github/workflows/runtime-release.yml b/.github/workflows/runtime-release.yml new file mode 100644 index 00000000000..47fae4bd0ab --- /dev/null +++ b/.github/workflows/runtime-release.yml @@ -0,0 +1,81 @@ +name: Release runtime binaries +on: + push: + branches: ["main"] + paths: + - ".github/workflows/runtime-release.yml" + - "runtime/**" +jobs: + release: + strategy: + matrix: + include: + - os: linux + arch: amd64 + name: linux-amd64 + ext: "" + - os: windows + arch: amd64 + name: windows-amd64 + ext: ".exe" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: "1.19" + - name: Setup Zig + uses: goto-bus-stop/setup-zig@v1 + with: + version: "0.9.1" + - name: Authenticate GCS + uses: google-github-actions/auth@v0 + with: + credentials_json: "${{ secrets.RILL_RUNTIME_SA }}" + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v0" + - name: Build and upload ${{ matrix.name }} + shell: bash + run: | + cd runtime + make release/${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} + mv release/${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} release/runtime${{ matrix.ext }} + zip -j release/runtime-${{ matrix.name }}.zip release/runtime${{ matrix.ext }} + RUNTIME_VERSION=$(cat version.txt | tr -d "[:space:]") + gsutil cp release/runtime-${{ matrix.name }}.zip gs://pkg.rilldata.com/runtime/releases/v$RUNTIME_VERSION/ + release_macos: + # NOTE: Currently, darwin builds must run on macOS. See Makefile for details. + strategy: + matrix: + include: + - os: darwin + arch: amd64 + name: macos-amd64 + ext: "" + - os: darwin + arch: arm64 + name: macos-arm64 + ext: "" + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: "1.19" + - name: Authenticate GCS + uses: google-github-actions/auth@v0 + with: + credentials_json: "${{ secrets.RILL_SQL_SA }}" + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v0" + - name: Build and upload ${{ matrix.name }} + shell: bash + run: | + cd runtime + make release/${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} + mv release/${{ matrix.os }}-${{ matrix.arch }}${{ matrix.ext }} release/runtime${{ matrix.ext }} + zip -j release/runtime-${{ matrix.name }}.zip release/runtime${{ matrix.ext }} + RUNTIME_VERSION=$(cat version.txt | tr -d "[:space:]") + gsutil cp release/runtime-${{ matrix.name }}.zip gs://pkg.rilldata.com/runtime/releases/v$RUNTIME_VERSION/ diff --git a/runtime/.gitignore b/runtime/.gitignore index 1c0af3979fa..2cc78604f8a 100644 --- a/runtime/.gitignore +++ b/runtime/.gitignore @@ -1 +1,2 @@ sql/deps +release diff --git a/runtime/Makefile b/runtime/Makefile index 13b49b5e307..e5b2953bd23 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -1,3 +1,5 @@ +RUNTIME_VERSION = $(shell cat version.txt | tr -d "[:space:]") + .PHONY: build build: ./scripts/setup_sql.sh -f @@ -16,3 +18,37 @@ test: .PHONY: clean clean: rm -rf sql/deps + rm -f main + rm -rf release + +release/linux-amd64: + mkdir -p release + GOOS=linux GOARCH=amd64 ./scripts/setup_sql.sh -f + CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \ + CC="zig cc -target x86_64-linux-musl" \ + CXX="zig c++ -target x86_64-linux-musl" \ + go build -ldflags "-X 'github.com/rilldata/rill/runtime.Version=${RUNTIME_VERSION}'" -trimpath -o release/linux-amd64 ./cmd + +release/windows-amd64.exe: + mkdir -p release + GOOS=windows GOARCH=amd64 ./scripts/setup_sql.sh -f + CGO_ENABLED=1 GOOS=windows GOARCH=amd64 \ + CC="zig cc -target x86_64-windows-gnu" \ + CXX="zig c++ -target x86_64-windows-gnu" \ + go build -ldflags "-X 'github.com/rilldata/rill/runtime.Version=${RUNTIME_VERSION}'" -trimpath -o release/windows-amd64.exe ./cmd + +# NOTE: Move darwin builds to to Zig (for fully cross-platform builds) when the issues mentioned here have been solved: https://github.com/rilldata/rill-developer/pull/846 + +release/darwin-arm64: + if [ "$(shell uname -s | tr '[:upper:]' '[:lower:]')" != "darwin" ]; then echo "Error: must run build on darwin"; false; fi + mkdir -p release + GOOS=darwin GOARCH=arm64 ./scripts/setup_sql.sh -f + CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 \ + go build -ldflags "-X 'github.com/rilldata/rill/runtime.Version=${RUNTIME_VERSION}'" -trimpath -o release/darwin-arm64 ./cmd + +release/darwin-amd64: + if [ "$(shell uname -s | tr '[:upper:]' '[:lower:]')" != "darwin" ]; then echo "Error: must run build on darwin"; false; fi + mkdir -p release + GOOS=darwin GOARCH=amd64 ./scripts/setup_sql.sh -f + CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 \ + go build -ldflags "-X 'github.com/rilldata/rill/runtime.Version=${RUNTIME_VERSION}'" -trimpath -o release/darwin-amd64 ./cmd diff --git a/runtime/cmd/main.go b/runtime/cmd/main.go index 09d40166182..91199e8c399 100644 --- a/runtime/cmd/main.go +++ b/runtime/cmd/main.go @@ -13,6 +13,7 @@ import ( "github.com/rilldata/rill/runtime" "github.com/rilldata/rill/runtime/metadata" "github.com/rilldata/rill/runtime/pkg/graceful" + _ "github.com/rilldata/rill/runtime/sql" _ "github.com/rilldata/rill/runtime/infra/duckdb" _ "github.com/rilldata/rill/runtime/metadata/sqlite"