Skip to content

Commit c9ebf50

Browse files
committed
ci: use docker build instead
1 parent 882bafb commit c9ebf50

File tree

2 files changed

+55
-21
lines changed

2 files changed

+55
-21
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,62 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
go-version: [1.22.x]
1918
os: [ubuntu-latest]
19+
gotify-version: ["2.5.0", "2.6.1"]
2020

2121
steps:
2222
- name: Checkout source code
2323
uses: actions/checkout@v4
2424

25-
- name: Set up Go
26-
uses: actions/setup-go@v5
27-
with:
28-
go-version: ${{ matrix.go-version }}
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
2927

30-
- name: Install required tools
31-
run: |
32-
go install github.com/gotify/plugin-api/cmd/gomod-cap@latest
33-
34-
- name: Build the plugin
28+
- name: Build Plugin
29+
env:
30+
GOTIFY_VERSION: "${{ matrix.gotify-version }}"
3531
run: |
32+
make download-tools
3633
make build
3734
3835
- name: Upload build artifacts
3936
uses: actions/upload-artifact@v4
4037
with:
41-
name: telegram-plugin
38+
name: build-${{ matrix.gotify-version }}
4239
path: build/*.so
40+
release:
41+
name: Release Plugin
42+
runs-on: ubuntu-latest
43+
needs: build
44+
steps:
45+
- name: Checkout Code
46+
uses: actions/checkout@v4
47+
48+
- name: Download Build Artifacts
49+
uses: actions/download-artifact@v4
50+
with:
51+
path: build
52+
pattern: build-*
53+
merge-multiple: true
54+
55+
- run: ls -la build
56+
57+
- name: Tag the repository
58+
id: tag
59+
run: |
60+
# See https://docs.github.com/en/get-started/using-git/dealing-with-special-characters-in-branch-and-tag-names
61+
TAG=v$(date -Iseconds | sed 's/[T:\+]/-/g')
62+
TIME=$(date '+%Y/%m/%d %H:%M')
63+
echo "$TAG"
64+
echo "tag=$TAG" >> $GITHUB_OUTPUT
65+
echo "time=$TIME" >> $GITHUB_OUTPUT
66+
git config --global user.name "${GITHUB_ACTOR}"
67+
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
68+
git tag -a $TAG -m "Published version $TAG" ${GITHUB_SHA}
69+
git push origin $TAG
70+
71+
- name: Create Release
72+
uses: softprops/action-gh-release@v2
73+
with:
74+
files: build/*.so
75+
tag_name: ${{ steps.tag.outputs.tag }}
76+
name: ${{ steps.tag.outputs.time }}

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
BUILDDIR=./build
2-
GOTIFY_VERSION=v2.6.1
32
PLUGIN_NAME=telegram-plugin
43
PLUGIN_ENTRY=plugin.go
54
GO_VERSION=`cat $(BUILDDIR)/gotify-server-go-version`
65
DOCKER_BUILD_IMAGE=gotify/build
76
DOCKER_WORKDIR=/proj
87
DOCKER_RUN=docker run --rm -v "$$PWD/.:${DOCKER_WORKDIR}" -v "`go env GOPATH`/pkg/mod/.:/go/pkg/mod:ro" -w ${DOCKER_WORKDIR}
98
DOCKER_GO_BUILD=go build -mod=readonly -a -installsuffix cgo -ldflags "$$LD_FLAGS" -buildmode=plugin
10-
GOMOD_CAP=go run github.com/gotify/plugin-api/cmd/gomod-cap
119

1210
download-tools:
13-
GO111MODULE=off go get -u github.com/gotify/plugin-api/cmd/gomod-cap
11+
go get -u github.com/gotify/plugin-api/cmd/gomod-cap
1412

1513
create-build-dir:
1614
mkdir -p ${BUILDDIR} || true
1715

1816
update-go-mod: create-build-dir
19-
wget -LO ${BUILDDIR}/gotify-server.mod https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/go.mod
20-
$(GOMOD_CAP) -from ${BUILDDIR}/gotify-server.mod -to go.mod
17+
GOTIFY_COMMIT=$(shell curl -s https://api.github.com/repos/gotify/server/git/ref/tags/v${GOTIFY_VERSION} | jq -r '.object.sha') && \
18+
wget -O ${BUILDDIR}/gotify-server.mod https://raw.githubusercontent.com/gotify/server/$${GOTIFY_COMMIT}/go.mod
19+
go run github.com/gotify/plugin-api/cmd/gomod-cap -from ${BUILDDIR}/gotify-server.mod -to go.mod
2120
rm ${BUILDDIR}/gotify-server.mod || true
2221
go mod tidy
2322

2423
get-gotify-server-go-version: create-build-dir
25-
rm ${BUILDDIR}/gotify-server-go-version || true
26-
wget -LO ${BUILDDIR}/gotify-server-go-version https://raw.githubusercontent.com/gotify/server/${GOTIFY_VERSION}/GO_VERSION
24+
rm -f ${BUILDDIR}/gotify-server-go-version || true
25+
GOTIFY_COMMIT=$(shell curl -s https://api.github.com/repos/gotify/server/git/ref/tags/v${GOTIFY_VERSION} | jq -r '.object.sha') && \
26+
wget -O ${BUILDDIR}/gotify-server-go-version https://raw.githubusercontent.com/gotify/server/$${GOTIFY_COMMIT}/GO_VERSION
2727

2828
build-linux-amd64: get-gotify-server-go-version update-go-mod
29-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-amd64 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-amd64${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
29+
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-amd64 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-amd64-v${GOTIFY_VERSION}${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
3030

3131
build-linux-arm-7: get-gotify-server-go-version update-go-mod
32-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm-7 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-arm-7${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
32+
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm-7 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-arm-7-v${GOTIFY_VERSION}${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
3333

3434
build-linux-arm64: get-gotify-server-go-version update-go-mod
35-
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm64 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-arm64${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
35+
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-arm64 ${DOCKER_GO_BUILD} -o ${BUILDDIR}/${PLUGIN_NAME}-linux-arm64-v${GOTIFY_VERSION}${FILE_SUFFIX}.so ${DOCKER_WORKDIR}
3636

3737
build: build-linux-arm-7 build-linux-amd64 build-linux-arm64
3838

0 commit comments

Comments
 (0)