Skip to content

Commit 14f473b

Browse files
committed
implement a release workflow
1 parent 27b0b57 commit 14f473b

6 files changed

Lines changed: 136 additions & 37 deletions

File tree

.github/workflows/main.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ concurrency:
1010

1111
jobs:
1212
test:
13-
name: Tests
14-
uses: ./.github/workflows/test.yml
15-
secrets: inherit
13+
name: Tests (PostgreSQL ${{ matrix.postgres-version }})
14+
runs-on: ubuntu-24.04
15+
timeout-minutes: 5
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
postgres-version: [ 15, 16, 17, 18 ]
20+
steps:
21+
- uses: actions/checkout@v5
22+
with:
23+
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
24+
- uses: aboutbits/github-actions-java/setup-with-gradle@v4
25+
with:
26+
java-version: 25
27+
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
28+
- name: Build & Test
29+
run: >-
30+
./gradlew
31+
--console=colored
32+
:operator:test
33+
--fail-fast
34+
-Dquarkus.test.profile=test-pg${{ matrix.postgres-version }}
35+
env:
36+
GITHUB_USER_NAME: ${{ github.actor }}
37+
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
increment:
7+
description: "Version increment type"
8+
type: choice
9+
required: true
10+
default: "Patch"
11+
options:
12+
- "Major"
13+
- "Minor"
14+
- "Patch"
15+
- "Prerelease"
16+
17+
env:
18+
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/app
19+
20+
jobs:
21+
build-and-publish:
22+
runs-on: ubuntu-24.04
23+
timeout-minutes: 15
24+
steps:
25+
- uses: actions/checkout@v6
26+
with:
27+
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
28+
- uses: aboutbits/github-actions-base/git-setup@v2
29+
- uses: aboutbits/github-actions-java/setup-with-gradle@v4
30+
with:
31+
java-version: 25
32+
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
33+
- name: Increment version
34+
run: ./gradlew --console=colored createRelease -Prelease.versionIncrementer=increment${{ github.event.inputs.increment }}
35+
shell: bash
36+
- name: Get next package version
37+
id: nextVersion
38+
run: echo "version=$(./gradlew currentVersion -q -Prelease.quiet)" >> $GITHUB_OUTPUT
39+
shell: bash
40+
- name: Build package
41+
run: ./gradlew --console=colored build
42+
- name: Build Docker image
43+
uses: aboutbits/github-actions-docker/build-push@v1
44+
with:
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
docker-image: ${{ env.DOCKER_IMAGE }}
48+
docker-tag: ${{ steps.nextVersion.outputs.version }}
49+
working-directory: './operator'
50+
dockerfile: './operator/src/main/docker/Dockerfile.jvm'
51+
- name: Push tag to remote
52+
run: ./gradlew --console=colored pushRelease
53+
shell: bash
54+
- uses: aboutbits/github-actions-base/github-create-release@v2
55+
with:
56+
tag-name: 'v${{ steps.nextVersion.outputs.version }}'
57+
release-description: |
58+
## Installation
59+
60+
**Docker Image:**
61+
```bash
62+
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.nextVersion.outputs.version }}
63+
```
64+
65+
**Helm Chart:**
66+
```bash
67+
helm install postgresql-operator https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/postgresql-operator-${{ steps.nextVersion.outputs.version }}.tgz
68+
```
69+
70+
**Manually installing CRDs:**
71+
```bash
72+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/clusterconnections.postgresql.aboutbits.it-v1.yml
73+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/databases.postgresql.aboutbits.it-v1.yml
74+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/schemas.postgresql.aboutbits.it-v1.yml
75+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/roles.postgresql.aboutbits.it-v1.yml
76+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/grants.postgresql.aboutbits.it-v1.yml
77+
kubectl apply -f https://github.com/${{ github.repository }}/releases/download/v${{ steps.nextVersion.outputs.version }}/defaultprivileges.postgresql.aboutbits.it-v1.yml
78+
```
79+
release-notes-generation: 'true'
80+
- name: Upload Helm chart and CRD assets
81+
env:
82+
GH_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
83+
run: |
84+
gh release upload v${{ steps.nextVersion.outputs.version }} operator/build/helm/kubernetes/*.tgz operator/build/kubernetes/*.postgresql.aboutbits.it-v1.yml
85+
shell: bash

.github/workflows/test.yml

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

build.gradle.kts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,36 @@ plugins {
88
java
99
checkstyle
1010
id("io.quarkus").apply(false)
11+
alias(libs.plugins.axionReleasePlugin)
1112
alias(libs.plugins.errorPronePlugin)
1213
alias(libs.plugins.jooqPlugin).apply(false)
1314
}
1415

1516
description = "AboutBits PostgreSQL Operator"
1617

18+
scmVersion {
19+
checks {
20+
aheadOfRemote = true
21+
snapshotDependencies = false
22+
uncommittedChanges = false
23+
}
24+
releaseBranchNames = setOf("main")
25+
releaseOnlyOnReleaseBranches = true
26+
versionCreator("simple")
27+
}
28+
29+
version = scmVersion.version
30+
1731
allprojects {
1832
group = "it.aboutbits.postgresql"
19-
version = "0.0.1-SNAPSHOT"
33+
version = rootProject.version
2034

2135
tasks.withType<Checkstyle>().configureEach {
2236
dependsOn(":checkstyleExtractConfig")
2337

2438
reports {
25-
html.required.set(false)
26-
xml.required.set(false)
39+
html.required = false
40+
xml.required = false
2741
}
2842
}
2943
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Gradle properties
22
org.gradle.caching=true
3-
org.gradle.parallel=true
3+
# TODO: Set to true when https://github.com/quarkusio/quarkus/issues/49115 is fixed
4+
org.gradle.parallel=false
45
org.gradle.logging.level=INFO
56

67
# Quarkus

gradle/libs.versions.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
## AboutBits Libraries ##
33
checkstyleConfig = "2.0.0"
44

5+
# Axion Release Plugin #
6+
axionReleasePlugin = "1.21.1"
7+
58
## Libraries ##
69
jooq = "3.20.10"
710
jSpecify = "1.0.0"
@@ -19,6 +22,10 @@ errorPronePlugin = "4.4.0"
1922
nullAway = "0.13.0"
2023

2124
[plugins]
25+
# https://github.com/allegro/axion-release-plugin
26+
# https://axion-release-plugin.readthedocs.io/
27+
axionReleasePlugin = { id = "pl.allegro.tech.build.axion-release", version.ref = "axionReleasePlugin" }
28+
2229
# https://github.com/tbroyer/gradle-errorprone-plugin
2330
# https://mvnrepository.com/artifact/net.ltgt.errorprone/net.ltgt.errorprone.gradle.plugin
2431
errorPronePlugin = { id = "net.ltgt.errorprone", version.ref = "errorPronePlugin" }

0 commit comments

Comments
 (0)