From 0a845942321a999c782466a550b5fb26f8645af4 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Wed, 20 Sep 2023 16:24:48 +1000 Subject: [PATCH] fix: release Go binaries This is primarily to trigger a GitHub release, rather than just a tag. --- .github/workflows/release.yml | 13 ++++-- .gitignore | 2 + .goreleaser.yaml | 79 +++++++++++++++++++++++++++++++++++ Dockerfile.controller | 2 + bin/.goreleaser-1.20.0.pkg | 1 + bin/goreleaser | 1 + cmd/ftl-initdb/main.go | 2 +- 7 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 .goreleaser.yaml create mode 120000 bin/.goreleaser-1.20.0.pkg create mode 120000 bin/goreleaser diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 91b532db5e..f5ee92dd93 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ on: push: tags: - - 'v[0-9]+.[0-9]+.[0-9]+' + - "v[0-9]+.[0-9]+.[0-9]+" name: Release jobs: build-runner: @@ -52,6 +52,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Init Hermit uses: cashapp/activate-hermit@v1 - name: Retrieve Runner Docker image @@ -86,12 +88,15 @@ jobs: # Ideally we'd use Hermit's JDK, but this action creates the correct settings.xml for us. - uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'temurin' + java-version: "11" + distribution: "temurin" - name: Publish JARs run: | mvn --batch-mode versions:set -DnewVersion=$(git describe --tags --abbrev=0 | cut -c2-) -DprocessAllModules -DgenerateBackupPoms=false mvn --batch-mode deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - name: Publish Go Binaries + run: goreleaser release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index d527a7b3a6..61e379347d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ reflex.conf node_modules *.tsbuildinfo generated_ftl_module.go + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000000..764bddeef5 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,79 @@ +builds: + - id: ftl-controller + main: ./cmd/ftl-controller + binary: ftl-controller + env: + - CGO_ENABLED=0 + goarch: + - amd64 + - arm64 + goos: + - linux + - darwin + flags: -trimpath + ldflags: -s -w -buildid= -X main.version={{.Version}} -X main.timestamp={{ .CommitTimestamp }} + tags: [release] + - id: ftl-runner + main: ./cmd/ftl-runner + binary: ftl-runner + env: + - CGO_ENABLED=0 + goarch: + - amd64 + - arm64 + goos: + - linux + - darwin + flags: -trimpath + ldflags: -s -w -buildid= -X main.version={{.Version}} -X main.timestamp={{ .CommitTimestamp }} + tags: [release] + - id: ftl + main: ./cmd/ftl + binary: ftl + env: + - CGO_ENABLED=0 + goarch: + - amd64 + - arm64 + goos: + - linux + - darwin + flags: -trimpath + ldflags: -s -w -buildid= -X main.version={{.Version}} -X main.timestamp={{ .CommitTimestamp }} + tags: [release] + - id: ftl-initdb + main: ./cmd/ftl-initdb + binary: ftl-initdb + env: + - CGO_ENABLED=0 + goarch: + - amd64 + - arm64 + goos: + - linux + - darwin + flags: -trimpath + ldflags: -s -w -buildid= -X main.version={{.Version}} -X main.timestamp={{ .CommitTimestamp }} + tags: [release] + +archives: + - format: tar.gz + name_template: "{{ .ProjectName }}-{{ .Version }}.{{- .Os }}-{{ .Arch }}" + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# The lines beneath this are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/Dockerfile.controller b/Dockerfile.controller index 75b5f9cb98..3aefe8c5e3 100644 --- a/Dockerfile.controller +++ b/Dockerfile.controller @@ -19,6 +19,7 @@ RUN go mod download -x # Build COPY . /src/ RUN make build/release/ftl-controller +RUN make build/release/ftl-initdb RUN make build/release/ftl # Finally create the runtime image. @@ -27,6 +28,7 @@ FROM ubuntu:22.04 WORKDIR /root/ COPY --from=builder /src/build/release/ftl-controller . +COPY --from=builder /src/build/release/ftl-initdb . COPY --from=builder /src/build/release/ftl . RUN mkdir deployments diff --git a/bin/.goreleaser-1.20.0.pkg b/bin/.goreleaser-1.20.0.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/bin/.goreleaser-1.20.0.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/bin/goreleaser b/bin/goreleaser new file mode 120000 index 0000000000..01642ac3ca --- /dev/null +++ b/bin/goreleaser @@ -0,0 +1 @@ +.goreleaser-1.20.0.pkg \ No newline at end of file diff --git a/cmd/ftl-initdb/main.go b/cmd/ftl-initdb/main.go index 2288150d28..948f1c4c88 100644 --- a/cmd/ftl-initdb/main.go +++ b/cmd/ftl-initdb/main.go @@ -13,7 +13,7 @@ import ( var cli struct { log.Config Recreate bool `help:"Drop and recreate the database."` - DSN string `help:"Postgres DSN." default:"postgres://localhost/ftl?sslmode=disable&user=postgres&password=secret" env:"FTL_DSN"` + DSN string `help:"Postgres DSN." default:"postgres://localhost/ftl?sslmode=disable&user=postgres&password=secret" env:"FTL_CONTROLLER_DSN"` } func main() {