Skip to content

Commit 8208437

Browse files
committed
build: Add version bump workflow
1 parent 9d3f6b0 commit 8208437

10 files changed

Lines changed: 232 additions & 89 deletions

File tree

.github/actions/prepare/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ runs:
3636
*) echo "Unsupported RUNNER_ARCH: $RUNNER_ARCH"; exit 1 ;;
3737
esac
3838
echo "ARCH=${ARCH}" >> "$GITHUB_ENV"
39-
echo "JDK_VERSION=$(xmlstarlet sel -N "n=http://maven.apache.org/POM/4.0.0" -t -v "/n:project/n:properties/n:jdk.version" "pom.xml")" >> ${GITHUB_ENV}
39+
echo "JDK_VERSION=$(xmlstarlet sel -N "n=http://maven.apache.org/POM/4.0.0" -t -v "/n:project/n:properties/n:graalvm-jdk.version" "pom.xml")" >> ${GITHUB_ENV}
4040
echo "SYFT_VERSION=$(xmlstarlet sel -N "n=http://maven.apache.org/POM/4.0.0" -t -v "/n:project/n:properties/n:syft.version" "pom.xml")" >> ${GITHUB_ENV}
4141
echo "SYFT_SHA256=$(xmlstarlet sel -N "n=http://maven.apache.org/POM/4.0.0" -t -v "/n:project/n:properties/n:syft.sha256.linux-${ARCH}" "pom.xml")" >> ${GITHUB_ENV}
4242
echo "UPX_VERSION=$(xmlstarlet sel -N "n=http://maven.apache.org/POM/4.0.0" -t -v "/n:project/n:properties/n:upx.version" "pom.xml")" >> ${GITHUB_ENV}

.github/workflows/call-release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
required: true
1010
JDHEIM_GPG_PASSPHRASE:
1111
required: true
12+
inputs:
13+
draft-release:
14+
description: "Create draft release"
15+
required: true
16+
type: string
1217
outputs:
1318
version:
1419
description: "Release Version"
@@ -65,7 +70,7 @@ jobs:
6570
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JDHEIM_GPG_PASSPHRASE }}
6671
JRELEASER_SIGNING_ACTIVE: ALWAYS
6772
JRELEASER_ASSEMBLE_ARCHIVE_TOOLFETCH_ACTIVE: ALWAYS
68-
JRELEASER_DRAFT: true
73+
JRELEASER_DRAFT: ${{ inputs.draft-release }}
6974
with:
7075
version: latest
7176
setup-java: false
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: "Call: Version Bump"
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
JDHEIM_ACTIONS_BOT_CLIENT_ID:
7+
required: true
8+
JDHEIM_ACTIONS_BOT_PRIVATE_KEY:
9+
required: true
10+
inputs:
11+
version-bump-type:
12+
description: "Part of the version to bump: major, minor, or patch"
13+
required: true
14+
type: string
15+
draft-release:
16+
description: "Create draft release"
17+
required: true
18+
type: string
19+
20+
jobs:
21+
version-bump:
22+
name: "Version Bump"
23+
timeout-minutes: 15
24+
permissions:
25+
contents: write
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: "Generate Token of jdheim-actions[bot]"
29+
id: jdheim-actions-bot-token
30+
uses: actions/create-github-app-token@v3
31+
with:
32+
app-id: ${{ secrets.JDHEIM_ACTIONS_BOT_CLIENT_ID }}
33+
private-key: ${{ secrets.JDHEIM_ACTIONS_BOT_PRIVATE_KEY }}
34+
35+
- name: "Checkout"
36+
uses: actions/checkout@v6
37+
with:
38+
token: ${{ steps.jdheim-actions-bot-token.outputs.token }}
39+
40+
- name: "Get Version"
41+
id: get-version
42+
uses: mikefarah/yq@v4
43+
with:
44+
cmd: yq '.project.version' "jreleaser.yml"
45+
46+
- name: "Bump Version"
47+
env:
48+
VERSION: ${{ steps.get-version.outputs.result }}
49+
VERSION_BUMP_TYPE: ${{ inputs.version-bump-type }}
50+
shell: bash
51+
run: |
52+
if [[ -z "${VERSION}" ]]; then
53+
BUMPED_VERSION="0.0.1"
54+
else
55+
IFS='.' read -r major minor patch <<< "${VERSION%%-*}"
56+
case "${VERSION_BUMP_TYPE}" in
57+
major) major=$((major + 1)); minor=0; patch=0 ;;
58+
minor) minor=$((minor + 1)); patch=0 ;;
59+
patch) patch=$((patch + 1)) ;;
60+
*) echo "Invalid version-bump-type: ${VERSION_BUMP_TYPE}"
61+
echo "Allowed values: major, minor, patch"
62+
exit 1 ;;
63+
esac
64+
BUMPED_VERSION="${major}.${minor}.${patch}"
65+
fi
66+
echo "BUMPED_VERSION=${BUMPED_VERSION}" >> "$GITHUB_ENV"
67+
68+
- name: "Set Version in JReleaser"
69+
uses: mikefarah/yq@v4
70+
with:
71+
cmd: yq -i '.project.version = strenv(BUMPED_VERSION)' "jreleaser.yml"
72+
73+
- name: "Set Version in Maven"
74+
shell: bash
75+
run: ./mvnw versions:set -DnewVersion="${BUMPED_VERSION}" -DgenerateBackupPoms=false
76+
77+
- name: "Verify changes"
78+
shell: bash
79+
run: |
80+
if [[ -z "$(git status --porcelain)" ]]; then
81+
echo "No changes to commit. Version increment failed"
82+
exit 1
83+
fi
84+
85+
- name: "Commit and Push"
86+
uses: IAreKyleW00t/verified-bot-commit@v2
87+
if: ${{ inputs.draft-release != 'true' }}
88+
with:
89+
message: "chore: Bump version to ${{ env.BUMPED_VERSION }}"
90+
ref: ${{ github.ref_name }}
91+
token: ${{ steps.jdheim-actions-bot-token.outputs.token }}
92+
files: |
93+
**

.github/workflows/release.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ run-name: "${{ github.workflow }} • ${{ github.ref_name }} • ${{ github.even
33

44
on:
55
workflow_dispatch:
6+
inputs:
7+
version-bump-type:
8+
description: "Part of the version to bump"
9+
required: true
10+
type: choice
11+
options:
12+
- "patch"
13+
- "minor"
14+
- "major"
15+
default: "patch"
16+
draft-release:
17+
description: "Create draft release"
18+
required: true
19+
type: choice
20+
options:
21+
- "true"
22+
- "false"
23+
default: "false"
624

725
concurrency:
826
group: release-${{ github.ref }}
@@ -56,6 +74,21 @@ jobs:
5674
JDHEIM_GPG_PUBLIC_KEY: ${{ secrets.JDHEIM_GPG_PUBLIC_KEY }}
5775
JDHEIM_GPG_SECRET_KEY: ${{ secrets.JDHEIM_GPG_SECRET_KEY }}
5876
JDHEIM_GPG_PASSPHRASE: ${{ secrets.JDHEIM_GPG_PASSPHRASE }}
77+
with:
78+
draft-release: ${{ inputs.draft-release }}
79+
80+
version-bump:
81+
name: "Version Bump"
82+
needs: release
83+
permissions:
84+
contents: write
85+
uses: jdheim/toolfetch/.github/workflows/call-version-bump.yml@main
86+
secrets:
87+
JDHEIM_ACTIONS_BOT_CLIENT_ID: ${{ secrets.JDHEIM_ACTIONS_BOT_CLIENT_ID }}
88+
JDHEIM_ACTIONS_BOT_PRIVATE_KEY: ${{ secrets.JDHEIM_ACTIONS_BOT_PRIVATE_KEY }}
89+
with:
90+
version-bump-type: ${{ inputs.version-bump-type }}
91+
draft-release: ${{ inputs.draft-release }}
5992

6093
github-slsa-provenance:
6194
name: "GitHub SLSA Provenance"
@@ -81,4 +114,4 @@ jobs:
81114
provenance-name: toolfetch-${{ needs.release.outputs.version }}-provenance.intoto.jsonl
82115
upload-tag-name: ${{ needs.release.outputs.tag_name }}
83116
base64-subjects: ${{ needs.release.outputs.base64_subjects }}
84-
draft-release: 'true'
117+
draft-release: ${{ inputs.draft-release }}

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
<img src="https://img.shields.io/github/actions/workflow/status/jdheim/toolfetch/tests-and-scans.yml?label=Tests%20%26%20Scans&logo=github&logoColor=white&branch=main" alt="Tests & Scans"/>
1414
</a>
1515
<a href="https://github.com/jdheim/toolfetch/actions/workflows/scheduled-security-scans.yml" rel="noreferrer">
16-
<img src="https://img.shields.io/github/actions/workflow/status/jdheim/toolfetch/scheduled-security-scans.yml?label=Security%20%20Scans&logo=github&logoColor=white&branch=main" alt="Security Scans"/>
16+
<img src="https://img.shields.io/github/actions/workflow/status/jdheim/toolfetch/scheduled-security-scans.yml?label=Security%20Scans&logo=github&logoColor=white&branch=main" alt="Security Scans"/>
17+
</a>
18+
<a href="https://github.com/jdheim/toolfetch/actions/workflows/github-code-scanning/codeql" rel="noreferrer">
19+
<img src="https://img.shields.io/github/actions/workflow/status/jdheim/toolfetch/github-code-scanning/codeql?label=CodeQL&logo=github&logoColor=white&branch=main" alt="CodeQL"/>
1720
</a>
1821
</p>
1922

jreleaser.yml

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
environment:
22
properties:
3-
graalVmDir: 'graalvm-jdk-25.0.2+10.1'
4-
3+
graalVmDir: 'graalvm-jdk-25.0.2'
54
project:
65
name: 'toolfetch'
76
version: '0.0.1'
@@ -29,42 +28,36 @@ project:
2928
languages:
3029
java:
3130
groupId: 'com.jdheim'
32-
3331
platform:
3432
replacements:
3533
x86_64: 'amd64'
3634
linux-x86_64: 'linux-amd64'
3735
aarch_64: 'arm64'
3836
linux-aarch_64: 'linux-arm64'
39-
4037
checksum:
4138
algorithms:
4239
- 'SHA_256'
4340
individual: true
44-
4541
signing:
4642
pgp:
4743
armored: true
4844
verify: true
4945
mode: 'MEMORY'
50-
5146
files:
5247
artifacts:
53-
- path: '{{outputDirectory}}/sbom/{{projectName}}-{{projectEffectiveVersion}}-sboms.zip'
54-
48+
- path: '{{outputDirectory}}/sbom/{{projectName}}-{{projectVersion}}-sboms.zip'
5549
distributions:
5650
toolfetch:
5751
type: 'BINARY'
5852
artifacts:
59-
- path: '{{assembleDirectory}}/{{projectName}}/archive/{{projectName}}-{{projectEffectiveVersion}}-linux-amd64.tar.gz'
53+
- path: '{{assembleDirectory}}/{{projectName}}/archive/{{projectName}}-{{projectVersion}}-linux-amd64.tar.gz'
6054
platform: 'linux-x86_64'
6155
extraProperties:
6256
graalVMNativeImage: 'true'
63-
- path: '{{assembleDirectory}}/{{projectName}}/archive/{{projectName}}-{{projectEffectiveVersion}}-linux-arm64.tar.gz'
57+
- path: '{{assembleDirectory}}/{{projectName}}/archive/{{projectName}}-{{projectVersion}}-linux-arm64.tar.gz'
6458
platform: 'linux-aarch_64'
6559
extraProperties:
6660
graalVMNativeImage: 'true'
67-
6861
assemble:
6962
archive:
7063
toolfetch:
@@ -76,7 +69,7 @@ assemble:
7669
longFileMode: 'POSIX'
7770
bigNumberMode: 'POSIX'
7871
artifacts:
79-
- path: '{{assembleDirectory}}/{{projectName}}_binary/native-image/{{projectName}}-{{projectEffectiveVersion}}-{{osPlatformReplaced}}'
72+
- path: '{{assembleDirectory}}/{{projectName}}_binary/native-image/{{projectName}}-{{projectVersion}}-{{osPlatformReplaced}}'
8073
transform: 'bin/{{projectName}}'
8174
fileSets:
8275
- input: "."
@@ -88,7 +81,7 @@ assemble:
8881
output: "licenses"
8982
nativeImage:
9083
toolfetch_binary:
91-
executable: '{{projectName}}-{{projectEffectiveVersion}}'
84+
executable: '{{projectName}}-{{projectVersion}}'
9285
archiving:
9386
enabled: false
9487
graalJdks:
@@ -100,13 +93,13 @@ assemble:
10093
- '-H:+UnlockExperimentalVMOptions'
10194
- '--enable-sbom=embed,cyclonedx,strict'
10295
mainJar:
103-
path: '{{baseOutputDirectory}}/{{projectName}}-{{projectEffectiveVersion}}.jar'
96+
path: '{{baseOutputDirectory}}/{{projectName}}-{{projectVersionNumber}}.jar'
10497
jars:
10598
- pattern: '{{baseOutputDirectory}}/third-party/lib/*.jar'
10699
java:
107100
mainClass: 'com.jdheim.{{projectName}}.Main'
108101
toolfetch_debug:
109-
executable: '{{projectName}}-{{projectEffectiveVersion}}'
102+
executable: '{{projectName}}-{{projectVersion}}'
110103
archiving:
111104
enabled: false
112105
graalJdks:
@@ -118,19 +111,18 @@ assemble:
118111
- '-H:+UnlockExperimentalVMOptions'
119112
- '-H:+JDWP'
120113
mainJar:
121-
path: '{{baseOutputDirectory}}/{{projectName}}-{{projectEffectiveVersion}}.jar'
114+
path: '{{baseOutputDirectory}}/{{projectName}}-{{projectVersionNumber}}.jar'
122115
jars:
123116
- pattern: '{{baseOutputDirectory}}/third-party/lib/*.jar'
124117
java:
125118
mainClass: 'com.jdheim.{{projectName}}.Main'
126-
127119
hooks:
128120
script:
129121
success:
130122
# Generate SBOM
131123
- run: |
132124
if [[ "${JRELEASER_ASSEMBLE_NATIVE_IMAGE_TOOLFETCH_BINARY_ACTIVE}" == "ALWAYS" ]]; then
133-
binary="$(find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectEffectiveVersion}}-{{osPlatformReplaced}}" -executable)"
125+
binary="$(find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectVersion}}-{{osPlatformReplaced}}" -executable)"
134126
if [[ -z "${binary}" ]]; then
135127
echo "[sbom] Missing {{projectName}} binary"
136128
exit 1
@@ -139,7 +131,7 @@ hooks:
139131
echo "[sbom] Generate SPDX SBOM with Syft $(syft --version | awk '{print $2}')"
140132
sbomDirectory="{{outputDirectory}}/sbom"
141133
mkdir -p "${sbomDirectory}"
142-
sbom="${sbomDirectory}/{{projectName}}-{{projectEffectiveVersion}}-{{osPlatformReplaced}}.spdx-json.sbom"
134+
sbom="${sbomDirectory}/{{projectName}}-{{projectVersion}}-{{osPlatformReplaced}}.spdx-json.sbom"
143135
syft file:"${binary}" -o spdx-json="${sbom}"
144136
else
145137
echo "[sbom] Syft not installed. Skipping"
@@ -151,7 +143,7 @@ hooks:
151143
# Compress with UPX
152144
- run: |
153145
if [[ "${JRELEASER_ASSEMBLE_NATIVE_IMAGE_TOOLFETCH_BINARY_ACTIVE}" == "ALWAYS" ]]; then
154-
binary="$(find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectEffectiveVersion}}-{{osPlatformReplaced}}" -executable)"
146+
binary="$(find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectVersion}}-{{osPlatformReplaced}}" -executable)"
155147
if [[ -z "${binary}" ]]; then
156148
echo "[sbom] Missing {{projectName}} binary"
157149
exit 1
@@ -173,7 +165,7 @@ hooks:
173165
- run: |
174166
if [[ "${JRELEASER_ASSEMBLE_NATIVE_IMAGE_TOOLFETCH_BINARY_ACTIVE}" == "ALWAYS" ]]; then
175167
echo "[native-image] Copy a native image to the target directory"
176-
find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectEffectiveVersion}}-{{osPlatformReplaced}}" -executable -exec cp -v {} {{baseOutputDirectory}}/{{projectName}} \;
168+
find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectVersion}}-{{osPlatformReplaced}}" -executable -exec cp -v {} {{baseOutputDirectory}}/{{projectName}} \;
177169
fi
178170
verbose: true
179171
filter:
@@ -189,8 +181,8 @@ hooks:
189181
cp -v {{baseOutputDirectory}}/jdks/graalvm-{{osPlatformReplaced}}/{{graalVmDir}}/lib/libsvmjdwp.so ${HOME}/.libsvmjdwp/graalvm-{{osPlatformReplaced}}/{{graalVmDir}}/
190182
fi
191183
cp -v ${HOME}/.libsvmjdwp/graalvm-{{osPlatformReplaced}}/{{graalVmDir}}/libsvmjdwp.so {{baseOutputDirectory}}
192-
find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectEffectiveVersion}}-{{osPlatformReplaced}}" -executable -exec cp -v {} {{baseOutputDirectory}}/{{projectName}} \;
193-
find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectEffectiveVersion}}.metadata" -exec cp -v {} {{baseOutputDirectory}}/{{projectName}}.metadata \;
184+
find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectVersion}}-{{osPlatformReplaced}}" -executable -exec cp -v {} {{baseOutputDirectory}}/{{projectName}} \;
185+
find {{assembleDirectory}} -type f -name "{{projectName}}-{{projectVersion}}.metadata" -exec cp -v {} {{baseOutputDirectory}}/{{projectName}}.metadata \;
194186
fi
195187
verbose: true
196188
filter:
@@ -209,25 +201,24 @@ hooks:
209201
echo "[sbom] Missing SBOM"
210202
exit 1
211203
fi
212-
204+
213205
valid=true
214206
for sbom in ${sboms}; do
215207
if ! grep -q "info.picocli-picocli" "${sbom}"; then
216208
valid=false
217209
break
218210
fi
219211
done
220-
212+
221213
if [[ "${valid}" != "true" ]]; then
222214
echo "[sbom] Missing libraries in SBOM"
223215
exit 1
224216
fi
225-
zip -j "${sbomDirectory}/{{projectName}}-{{projectEffectiveVersion}}-sboms.zip" ${sboms}
217+
zip -j "${sbomDirectory}/{{projectName}}-{{projectVersion}}-sboms.zip" ${sboms}
226218
fi
227219
verbose: true
228220
filter:
229221
includes: [ 'assemble' ]
230-
231222
release:
232223
github:
233224
releaseName: '{{tagName}}'
@@ -262,4 +253,4 @@ release:
262253
contributors:
263254
- 'p-marcin'
264255
- 'dependabot'
265-
- 'GitHub'
256+
- 'jdheim-repository'

0 commit comments

Comments
 (0)