Skip to content

Commit 1159c26

Browse files
committed
feat: enhance GitHub Actions workflow to support MongoDB 8.0 and add artifact upload steps
1 parent 6bb2ff5 commit 1159c26

File tree

1 file changed

+181
-63
lines changed

1 file changed

+181
-63
lines changed

.github/workflows/tags.yml

Lines changed: 181 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
mongodb-version: ["5.0", "6.0", "7.0"]
17+
mongodb-version: ["5.0", "6.0", "7.0", "8.0"]
1818
timeout-minutes: 10
1919
steps:
2020
- uses: actions/checkout@v4
@@ -30,9 +30,21 @@ jobs:
3030
run: |
3131
mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}"
3232
33-
# Deploy the project to Maven Central and DockerHub
34-
deploy:
33+
- name: Upload build artifacts for Docker jobs
34+
if: matrix.mongodb-version == '8.0'
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: restheart-artifacts
38+
path: |
39+
core/target/restheart.jar
40+
core/target/lib/*.jar
41+
core/target/plugins/*.jar
42+
core/target/plugins/lib/*.jar
43+
44+
# Release the project on GitHub
45+
release:
3546
if: "!contains(github.event.head_commit.message, 'skip ci')"
47+
needs: build
3648
runs-on: ubuntu-latest
3749
outputs:
3850
version: ${{ steps.set_version.outputs.version }}
@@ -53,44 +65,13 @@ jobs:
5365
- name: Build and Test
5466
run: mvn -B clean verify -Dmongodb.version="${{ matrix.mongodb-version }}"
5567

56-
- name: Import private gpg key
57-
run: |
58-
printf "%s" "$GPG_PRIVATE_KEY" > private.key
59-
gpg --pinentry-mode=loopback --batch --yes --fast-import private.key
60-
continue-on-error: true
61-
env:
62-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
63-
64-
- name: Deploy to Maven Central
65-
continue-on-error: true
66-
run: |
67-
MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" \
68-
mvn -B deploy -Pdeploy -DskipTests -Dmongodb.version="${{ matrix.mongodb-version }}" -s settings.xml
69-
env:
70-
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
71-
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
72-
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
73-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
74-
75-
- name: Set up QEMU
76-
uses: docker/setup-qemu-action@v3
77-
78-
- name: Set up Docker Buildx
79-
uses: docker/setup-buildx-action@v3
80-
81-
- name: Login to DockerHub
82-
uses: docker/login-action@v3
83-
with:
84-
username: ${{ secrets.DOCKER_USER }}
85-
password: ${{ secrets.DOCKER_TOKEN }}
86-
8768
- name: Set VERSION
8869
id: set_version
8970
run: |
9071
VERSION=${GITHUB_REF#refs/tags/}
9172
echo "VERSION=$VERSION" >> $GITHUB_ENV
9273
echo "version=$VERSION" >> $GITHUB_OUTPUT
93-
74+
9475
- name: Extract Version Components
9576
id: extract_version
9677
run: |
@@ -103,13 +84,60 @@ jobs:
10384
echo "MINOR=$MINOR" >> $GITHUB_ENV
10485
echo "PATCH=$PATCH" >> $GITHUB_ENV
10586
87+
- name: Upload GitHub release
88+
uses: softprops/action-gh-release@v2
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
with:
92+
body: |
93+
# Release ${{ env.VERSION }}
94+
files: |
95+
core/target/restheart.tar.gz
96+
core/target/restheart.zip
97+
draft: true
98+
prerelease: false
99+
100+
build-docker-standard:
101+
if: "!contains(github.event.head_commit.message, 'skip ci')"
102+
needs: build
103+
runs-on: ubuntu-latest
104+
strategy:
105+
matrix:
106+
mongodb-version: ["8.0"]
107+
timeout-minutes: 10
108+
steps:
109+
- uses: actions/checkout@v4
110+
- name: Download build artifacts
111+
uses: actions/download-artifact@v4
112+
with:
113+
name: restheart-artifacts
114+
path: core/target/
115+
- name: Set VERSION
116+
run: |
117+
VERSION=${GITHUB_REF#refs/tags/}
118+
echo "VERSION=$VERSION" >> $GITHUB_ENV
119+
- name: Extract Version Components
120+
run: |
121+
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1)
122+
MINOR=$(echo "$VERSION" | cut -d '.' -f 2)
123+
PATCH=$(echo "$VERSION" | cut -d '.' -f 3)
124+
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
125+
echo "MINOR=$MINOR" >> $GITHUB_ENV
126+
echo "PATCH=$PATCH" >> $GITHUB_ENV
106127
- name: Set Docker Tags for standard images
107128
id: set_tags
108129
run: |
109-
# Construct all tags based on the MAJOR.MINOR.PATCH format
110-
TAGS="softinstigate/restheart:latest,softinstigate/restheart:${{ env.MAJOR }},softinstigate/restheart:${{ env.MAJOR }}.${{ env.MINOR }},softinstigate/restheart:${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}"
130+
TAGS="softinstigate/restheart:latest,softinstigate/restheart:$MAJOR,softinstigate/restheart:$MAJOR.$MINOR,softinstigate/restheart:$MAJOR.$MINOR.$PATCH"
111131
echo "TAGS=$TAGS" >> $GITHUB_ENV
112-
132+
- name: Set up QEMU
133+
uses: docker/setup-qemu-action@v3
134+
- name: Set up Docker Buildx
135+
uses: docker/setup-buildx-action@v3
136+
- name: Login to DockerHub
137+
uses: docker/login-action@v3
138+
with:
139+
username: ${{ secrets.DOCKER_USER }}
140+
password: ${{ secrets.DOCKER_TOKEN }}
113141
- name: Build and Push multi-arch Docker images
114142
uses: docker/build-push-action@v6
115143
with:
@@ -119,17 +147,51 @@ jobs:
119147
linux/arm64,
120148
linux/ppc64le,
121149
linux/s390x
122-
push: true # push all images built
123-
pull: true # pull all required images before building
150+
push: true
151+
pull: true
124152
tags: ${{ env.TAGS }}
125153

154+
build-docker-graalvm:
155+
if: "!contains(github.event.head_commit.message, 'skip ci')"
156+
needs: build
157+
runs-on: ubuntu-latest
158+
strategy:
159+
matrix:
160+
mongodb-version: ["8.0"]
161+
timeout-minutes: 10
162+
steps:
163+
- uses: actions/checkout@v4
164+
- name: Download build artifacts
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: restheart-artifacts
168+
path: core/target/
169+
- name: Set VERSION
170+
run: |
171+
VERSION=${GITHUB_REF#refs/tags/}
172+
echo "VERSION=$VERSION" >> $GITHUB_ENV
173+
- name: Extract Version Components
174+
run: |
175+
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1)
176+
MINOR=$(echo "$VERSION" | cut -d '.' -f 2)
177+
PATCH=$(echo "$VERSION" | cut -d '.' -f 3)
178+
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
179+
echo "MINOR=$MINOR" >> $GITHUB_ENV
180+
echo "PATCH=$PATCH" >> $GITHUB_ENV
126181
- name: Set Docker Tags for GraalVM image
127182
id: set_graalvm_tags
128183
run: |
129-
# Construct all tags based on the MAJOR.MINOR.PATCH format
130-
TAGS_GRAALVM="softinstigate/restheart:latest-graalvm,softinstigate/restheart:${{ env.MAJOR }}-graalvm,softinstigate/restheart:${{ env.MAJOR }}.${{ env.MINOR }}-graalvm,softinstigate/restheart:${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}-graalvm"
184+
TAGS_GRAALVM="softinstigate/restheart:latest-graalvm,softinstigate/restheart:$MAJOR-graalvm,softinstigate/restheart:$MAJOR.$MINOR-graalvm,softinstigate/restheart:$MAJOR.$MINOR.$PATCH-graalvm"
131185
echo "TAGS_GRAALVM=$TAGS_GRAALVM" >> $GITHUB_ENV
132-
186+
- name: Set up QEMU
187+
uses: docker/setup-qemu-action@v3
188+
- name: Set up Docker Buildx
189+
uses: docker/setup-buildx-action@v3
190+
- name: Login to DockerHub
191+
uses: docker/login-action@v3
192+
with:
193+
username: ${{ secrets.DOCKER_USER }}
194+
password: ${{ secrets.DOCKER_TOKEN }}
133195
- name: Build and Push GraalVM Docker image
134196
uses: docker/build-push-action@v6
135197
with:
@@ -138,17 +200,51 @@ jobs:
138200
platforms: |
139201
linux/amd64,
140202
linux/arm64
141-
push: true # push all images built
142-
pull: true # pull all required images before building
203+
push: true
204+
pull: true
143205
tags: ${{ env.TAGS_GRAALVM }}
144206

207+
build-docker-distroless:
208+
if: "!contains(github.event.head_commit.message, 'skip ci')"
209+
needs: build
210+
runs-on: ubuntu-latest
211+
strategy:
212+
matrix:
213+
mongodb-version: ["8.0"]
214+
timeout-minutes: 10
215+
steps:
216+
- uses: actions/checkout@v4
217+
- name: Download build artifacts
218+
uses: actions/download-artifact@v4
219+
with:
220+
name: restheart-artifacts
221+
path: core/target/
222+
- name: Set VERSION
223+
run: |
224+
VERSION=${GITHUB_REF#refs/tags/}
225+
echo "VERSION=$VERSION" >> $GITHUB_ENV
226+
- name: Extract Version Components
227+
run: |
228+
MAJOR=$(echo "$VERSION" | cut -d '.' -f 1)
229+
MINOR=$(echo "$VERSION" | cut -d '.' -f 2)
230+
PATCH=$(echo "$VERSION" | cut -d '.' -f 3)
231+
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
232+
echo "MINOR=$MINOR" >> $GITHUB_ENV
233+
echo "PATCH=$PATCH" >> $GITHUB_ENV
145234
- name: Set Docker tags for Distroless image
146235
id: set_distroless_tags
147236
run: |
148-
# Construct all tags based on the MAJOR.MINOR.PATCH format
149-
TAGS_DISTROLESS="softinstigate/restheart:latest-distroless,softinstigate/restheart:${{ env.MAJOR }}-distroless,softinstigate/restheart:${{ env.MAJOR }}.${{ env.MINOR }}-distroless,softinstigate/restheart:${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}-distroless"
237+
TAGS_DISTROLESS="softinstigate/restheart:latest-distroless,softinstigate/restheart:$MAJOR-distroless,softinstigate/restheart:$MAJOR.$MINOR-distroless,softinstigate/restheart:$MAJOR.$MINOR.$PATCH-distroless"
150238
echo "TAGS_DISTROLESS=$TAGS_DISTROLESS" >> $GITHUB_ENV
151-
239+
- name: Set up QEMU
240+
uses: docker/setup-qemu-action@v3
241+
- name: Set up Docker Buildx
242+
uses: docker/setup-buildx-action@v3
243+
- name: Login to DockerHub
244+
uses: docker/login-action@v3
245+
with:
246+
username: ${{ secrets.DOCKER_USER }}
247+
password: ${{ secrets.DOCKER_TOKEN }}
152248
- name: Build and Push distroless docker image
153249
uses: docker/build-push-action@v6
154250
with:
@@ -158,28 +254,50 @@ jobs:
158254
linux/amd64,
159255
linux/arm64,
160256
linux/ppc64le
161-
push: true # push all images built
162-
pull: true # pull all required images before building
257+
push: true
258+
pull: true
163259
tags: ${{ env.TAGS_DISTROLESS }}
164260

165-
- name: Upload GitHub release
166-
uses: softprops/action-gh-release@v2
167-
env:
168-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
261+
deploy-maven-central:
262+
if: "!contains(github.event.head_commit.message, 'skip ci')"
263+
needs: build
264+
runs-on: ubuntu-latest
265+
strategy:
266+
matrix:
267+
mongodb-version: ["8.0"]
268+
timeout-minutes: 20
269+
steps:
270+
- uses: actions/checkout@v4
271+
272+
- name: Set up JDK 21
273+
uses: actions/setup-java@v4
169274
with:
170-
body: |
171-
# Release ${{ env.VERSION }}
172-
files: |
173-
core/target/restheart.tar.gz
174-
core/target/restheart.zip
175-
draft: true
176-
prerelease: false
275+
distribution: "temurin"
276+
java-version: "21"
277+
cache: "maven"
278+
279+
- name: Import private gpg key
280+
run: |
281+
printf "%s" "$GPG_PRIVATE_KEY" > private.key
282+
gpg --pinentry-mode=loopback --batch --yes --fast-import private.key
283+
env:
284+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
285+
286+
- name: Deploy to Maven Central
287+
run: |
288+
MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" \
289+
mvn -B deploy -Pdeploy -DskipTests -Dmongodb.version="${{ matrix.mongodb-version }}" -s settings.xml
290+
env:
291+
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
292+
CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }}
293+
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
294+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
177295

178296
# Separate job to call the reusable workflow
179297
call-native-image-release:
180298
if: "!contains(github.event.head_commit.message, 'skip ci')"
181-
needs: deploy
299+
needs: release
182300
uses: softinstigate/restheart/.github/workflows/native-image-release.yml@master
183301
secrets: inherit
184302
with:
185-
version: "${{ needs.deploy.outputs.version }}"
303+
version: "${{ needs.release.outputs.version }}"

0 commit comments

Comments
 (0)