Skip to content

Commit a2b91e3

Browse files
LukasKnuthcmoran
andcommitted
Added just recipes to sync plugin and server versions.
Three things must be synchronized: - compatible dependency versions to the main server - the same go version as the server - the same go toolchain as the server This was done multiple times by PR contributors recently. Automating this as much as possible should help make these PRs much simpler. Co-authored-by: cmoran <cgmoran@gmail.com>
1 parent 0748835 commit a2b91e3

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

build.Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

justfile

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,33 @@ make:
1111
lint:
1212
golangci-lint run --fix
1313

14-
server-mod := "gotify-server.mod"
15-
docker-image := "gotify-build-arm64"
16-
server-go-version := "1.22.4"
17-
plugin-name := "gotify-slack-webhook"
14+
[group('local')]
15+
run release:
16+
docker run --rm -v "$PWD/_build:/app/data/plugins" -p 8080:80 gotify/server:{{release}}
1817

19-
[group('gotify')]
20-
build-image:
21-
# This is here because the official gotify/builder images are AMD64 only and I'm on a M1 Mac Book
22-
docker build . -f build.Dockerfile -t {{docker-image}} --build-arg GO_VERSION={{server-go-version}}
18+
[group('local')]
19+
e2e release: (sync-versions "v" + release) (build "arm64") (run release)
2320

24-
[group('gotify')]
25-
_build arch:
21+
plugin-name := "gotify-slack-webhook"
22+
[group('CI')]
23+
build arch:
24+
#!/usr/bin/env bash
25+
set -euxo pipefail
2626
mkdir -p _build
27-
docker run --rm -v "$PWD/.:/build" -w /build {{docker-image}} go build -mod=readonly -a -installsuffix cgo -ldflags="-w -s" -buildmode=plugin -o _build/{{plugin-name}}-{{arch}}.so
28-
29-
[group('gotify')]
30-
build: (_build "linux-arm64")
27+
# NOTE: Drop 2 characs because toolchain is "go1.2.3" and image is tagged with just version
28+
version=$(go mod edit -json | jq -r '.Toolchain[2:]')
29+
docker run --rm -v "$PWD/.:/mnt" -w /mnt gotify/build:${version}-linux-{{arch}} go build -mod=readonly -a -installsuffix cgo -ldflags="-w -s" -buildmode=plugin -o "_build/{{plugin-name}}-linux-{{arch}}.so"
3130

32-
[group('gotify')]
33-
run:
34-
docker run --rm -v "$PWD/_build:/app/data/plugins" -p 8080:80 gotify/server-arm64
35-
36-
[group('gotify')]
37-
download-gotify-server-mod:
38-
wget -LO {{server-mod}} https://raw.githubusercontent.com/gotify/server/master/go.mod
39-
echo "Also note that the Go version must match with Gotiy server (set via ASDF)"
31+
server-mod := "gotify-server.mod"
32+
[group('CI')]
33+
sync-versions release:
34+
# Downloads the target server versions dependency lockfile to sync it to the local one
35+
wget -LO {{server-mod}} https://raw.githubusercontent.com/gotify/server/{{release}}/go.mod
36+
echo "{{release}}" > SERVER_VERSION.txt
37+
# Syncs the downloaded server lockfile with the local one to make plugin binary compatible
38+
go run github.com/gotify/plugin-api/cmd/gomod-cap -from {{server-mod}} -to go.mod
39+
# Sync Toolchain and Go language versions as well
40+
go mod edit -go $(go mod edit -json gotify-server.mod | jq -r '.Go')
41+
go mod edit -toolchain $(go mod edit -json gotify-server.mod | jq -r '.Toolchain')
42+
go mod tidy
4043

41-
[group('gotify')]
42-
verify-versions: download-gotify-server-mod
43-
go run github.com/gotify/plugin-api/cmd/gomod-cap -from {{server-mod}} -to go.mod
44-
go mod tidy

0 commit comments

Comments
 (0)