Skip to content

Commit 7839236

Browse files
committed
build: Introduce GA/EA Release Types in GitHub Actions
1 parent e182186 commit 7839236

16 files changed

Lines changed: 187 additions & 128 deletions

.github/actions/prepare/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
description: "Enables or disables 'Install UPX' step"
1818
required: false
1919
default: "false"
20+
release-type:
21+
description: "Release type"
22+
required: false
23+
default: "EA"
2024

2125
runs:
2226
using: composite
@@ -36,6 +40,7 @@ runs:
3640
*) echo "Unsupported RUNNER_ARCH: $RUNNER_ARCH"; exit 1 ;;
3741
esac
3842
echo "ARCH=${ARCH}" >> "$GITHUB_ENV"
43+
echo "PROJECT_VERSION=$(yq -r '.project.version' "jreleaser.yml" | sed "s/-.*//")" >> ${GITHUB_ENV}
3944
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}
4045
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}
4146
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}
@@ -80,6 +85,17 @@ runs:
8085
restore-keys: |
8186
${{ runner.os }}-${{ inputs.maven-repo-cache-key }}-
8287
88+
- name: "Set Project Version in JReleaser"
89+
if: ${{ inputs.release-type == 'GA' }}
90+
uses: mikefarah/yq@v4
91+
with:
92+
cmd: yq -i '.project.version = strenv(PROJECT_VERSION)' "jreleaser.yml"
93+
94+
- name: "Set Project Version in Maven"
95+
if: ${{ inputs.release-type == 'GA' }}
96+
shell: bash
97+
run: ./mvnw versions:set -DnewVersion="${PROJECT_VERSION}" -DgenerateBackupPoms=false
98+
8399
- name: "Generate Workflow Stats"
84100
if: ${{ inputs.generate-workflow-stats == 'true' }}
85101
shell: bash
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: "Call: Project 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+
project-version-bump-type:
12+
description: "Part of the project 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+
project-version-bump:
22+
name: "Project 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 Project Version"
41+
id: get-project-version
42+
uses: mikefarah/yq@v4
43+
with:
44+
cmd: yq '.project.version' "jreleaser.yml"
45+
46+
- name: "Bump Project Version"
47+
env:
48+
PROJECT_VERSION: ${{ steps.get-project-version.outputs.result }}
49+
PROJECT_VERSION_BUMP_TYPE: ${{ inputs.project-version-bump-type }}
50+
shell: bash
51+
run: |
52+
if [[ -z "${PROJECT_VERSION}" || "${PROJECT_VERSION}" == "null" ]]; then
53+
echo "Project Version Bump failed as it could not be resolved"
54+
exit 1
55+
else
56+
IFS='.' read -r major minor patch <<< "${PROJECT_VERSION%%-*}"
57+
case "${PROJECT_VERSION_BUMP_TYPE}" in
58+
MAJOR) major=$((major + 1)); minor=0; patch=0 ;;
59+
MINOR) minor=$((minor + 1)); patch=0 ;;
60+
PATCH) patch=$((patch + 1)) ;;
61+
*) echo "Invalid project-version-bump-type: ${PROJECT_VERSION_BUMP_TYPE}"
62+
echo "Allowed values: MAJOR, MINOR, PATCH"
63+
exit 1 ;;
64+
esac
65+
BUMPED_PROJECT_VERSION="${major}.${minor}.${patch}-SNAPSHOT"
66+
fi
67+
echo "BUMPED_PROJECT_VERSION=${BUMPED_PROJECT_VERSION}" >> "$GITHUB_ENV"
68+
69+
- name: "Set Project Version in JReleaser"
70+
uses: mikefarah/yq@v4
71+
with:
72+
cmd: yq -i '.project.version = strenv(BUMPED_PROJECT_VERSION)' "jreleaser.yml"
73+
74+
- name: "Set Project Version in Maven"
75+
shell: bash
76+
run: ./mvnw versions:set -DnewVersion="${BUMPED_PROJECT_VERSION}" -DgenerateBackupPoms=false
77+
78+
- name: "Verify changes"
79+
shell: bash
80+
run: |
81+
if [[ -z "$(git status --porcelain)" ]]; then
82+
echo "No changes to commit. Project Version Bump failed"
83+
exit 1
84+
fi
85+
86+
- name: "Commit and Push"
87+
uses: IAreKyleW00t/verified-bot-commit@v2
88+
if: ${{ inputs.draft-release != 'true' }}
89+
with:
90+
message: "chore: Bump Project Version to ${{ env.BUMPED_PROJECT_VERSION }}"
91+
ref: ${{ github.ref_name }}
92+
token: ${{ steps.jdheim-actions-bot-token.outputs.token }}
93+
files: |
94+
**

.github/workflows/call-release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
JDHEIM_GPG_PASSPHRASE:
1111
required: true
1212
inputs:
13+
release-type:
14+
description: "Release type"
15+
required: true
16+
type: string
1317
draft-release:
1418
description: "Create draft release"
1519
required: true
@@ -46,7 +50,8 @@ jobs:
4650
- name: "Prepare"
4751
uses: ./.github/actions/prepare
4852
with:
49-
maven-repo-cache-key: "release-m2-repo"
53+
maven-repo-cache-key: release-m2-repo
54+
release-type: ${{ inputs.release-type }}
5055

5156
- name: "Download ToolFetch Archives"
5257
uses: actions/download-artifact@v8

.github/workflows/call-scan-owasp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: "Prepare"
2323
uses: ./.github/actions/prepare
2424
with:
25-
maven-repo-cache-key: "owasp-scan-m2-repo"
25+
maven-repo-cache-key: owasp-scan-m2-repo
2626

2727
# https://dependency-check.github.io/DependencyCheck/analyzers/assembly-analyzer.html
2828
- name: "Install .NET SDK required by AssemblyAnalyzer"

.github/workflows/call-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: "Prepare"
3636
uses: ./.github/actions/prepare
3737
with:
38-
maven-repo-cache-key: "${{ inputs.maven-repo-cache-key-prefix }}-${{ matrix.scan.id }}"
38+
maven-repo-cache-key: ${{ inputs.maven-repo-cache-key-prefix }}-${{ matrix.scan.id }}
3939

4040
- name: "Scan"
4141
working-directory: scripts

.github/workflows/call-test-native.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: "Prepare"
3232
uses: ./.github/actions/prepare
3333
with:
34-
maven-repo-cache-key: "${{ inputs.maven-repo-cache-key-prefix }}-${{ matrix.job.runner }}"
34+
maven-repo-cache-key: ${{ inputs.maven-repo-cache-key-prefix }}-${{ matrix.job.runner }}
3535

3636
- name: "Download ToolFetch Binary"
3737
uses: actions/download-artifact@v8

.github/workflows/call-toolfetch-archive.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: "Call: Assemble ToolFetch Archive"
22

33
on:
44
workflow_call:
5+
inputs:
6+
release-type:
7+
description: "Release type"
8+
required: false
9+
type: string
10+
default: "EA"
511

612
jobs:
713
toolfetch-archive:
@@ -25,7 +31,8 @@ jobs:
2531
- name: "Prepare"
2632
uses: ./.github/actions/prepare
2733
with:
28-
maven-repo-cache-key: "toolfetch-archive-${{ matrix.job.runner }}-m2-repo"
34+
maven-repo-cache-key: toolfetch-archive-${{ matrix.job.runner }}-m2-repo
35+
release-type: ${{ inputs.release-type }}
2936

3037
- name: "Prepare Native Build"
3138
working-directory: scripts

.github/workflows/call-toolfetch-binary.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
required: false
99
type: string
1010
default: "toolfetch-binary-m2-repo"
11+
release-type:
12+
description: "Release type"
13+
required: false
14+
type: string
15+
default: "EA"
1116

1217
jobs:
1318
toolfetch-binary:
@@ -31,9 +36,10 @@ jobs:
3136
- name: "Prepare"
3237
uses: ./.github/actions/prepare
3338
with:
34-
maven-repo-cache-key: "${{ inputs.maven-repo-cache-key-prefix }}-${{ matrix.job.runner }}"
35-
install-syft: "true"
36-
install-upx: "true"
39+
maven-repo-cache-key: ${{ inputs.maven-repo-cache-key-prefix }}-${{ matrix.job.runner }}
40+
install-syft: true
41+
install-upx: true
42+
release-type: ${{ inputs.release-type }}
3743

3844
- name: "Prepare Native Build"
3945
working-directory: scripts

.github/workflows/call-toolfetch-sboms.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: "Call: Assemble ToolFetch SBOMs"
22

33
on:
44
workflow_call:
5+
inputs:
6+
release-type:
7+
description: "Release type"
8+
required: false
9+
type: string
10+
default: "EA"
511

612
jobs:
713
toolfetch-sboms:
@@ -19,7 +25,8 @@ jobs:
1925
- name: "Prepare"
2026
uses: ./.github/actions/prepare
2127
with:
22-
maven-repo-cache-key: "toolfetch-sboms-m2-repo"
28+
maven-repo-cache-key: toolfetch-sboms-m2-repo
29+
release-type: ${{ inputs.release-type }}
2330

2431
- name: "Prepare Native Build"
2532
working-directory: scripts

.github/workflows/call-version-bump.yml

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

0 commit comments

Comments
 (0)