Skip to content

Commit 2cfe374

Browse files
Merge pull request #38 from finos/develop
Refactor GitHub workflows to formalize the new release process and improve reuse
2 parents 05e1e51 + 0420cf0 commit 2cfe374

12 files changed

Lines changed: 249 additions & 124 deletions

File tree

.github/workflows/build-and-test-main.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,55 @@
1-
name: Build and Test (Reusable)
1+
# .github/workflows/build-and-test.yml
2+
3+
name: Core Build and Test
24

35
on:
46
workflow_call:
7+
inputs:
8+
java-version:
9+
required: false
10+
type: string
11+
default: '21'
12+
python-version:
13+
required: false
14+
type: string
15+
default: '3.11'
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
520

621
jobs:
7-
build_and_test:
22+
build-and-test:
823
runs-on: ubuntu-latest
24+
925
steps:
10-
- uses: actions/checkout@v4
11-
- name: Set up JDK 21
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
# Java
32+
- name: Set up Java
1233
uses: actions/setup-java@v4
1334
with:
14-
java-version: '21'
15-
distribution: 'temurin'
35+
distribution: temurin
36+
java-version: ${{ inputs.java-version }}
1637
cache: maven
17-
- name: Set up Python 3.11
18-
uses: actions/setup-python@v4
38+
39+
- name: Build & Test (Java)
40+
run: mvn -B clean verify
41+
42+
# Python
43+
- name: Set up Python
44+
uses: actions/setup-python@v5
1945
with:
20-
python-version: '3.11'
21-
- name: Build with Maven
22-
run: mvn -B package -Psign-artifacts --file pom.xml
46+
python-version: ${{ inputs.python-version }}
47+
cache: pip
48+
2349
- name: Run Python Unit Tests
2450
run: |
2551
chmod +x test/python_setup/setup_python_env.sh
2652
chmod +x test/python_setup/cleanup_python_env.sh
2753
chmod +x test/python_unit_tests/setup_unit_test_env.sh
2854
chmod +x test/python_unit_tests/run_python_unit_tests.sh
29-
test/python_unit_tests/run_python_unit_tests.sh
55+
test/python_unit_tests/run_python_unit_tests.sh

.github/workflows/ci-develop.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# .github/workflows/ci-develop.yml
2+
3+
name: CI - Develop
4+
5+
on:
6+
push:
7+
branches: [develop]
8+
pull_request:
9+
branches: [develop]
10+
11+
concurrency:
12+
group: ci-develop-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build-and-test:
17+
uses: ./.github/workflows/build-and-test.yml
18+
with:
19+
java-version: '21'
20+
python-version: '3.11'

.github/workflows/ci-main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# .github/workflows/ci-main.yml
2+
3+
name: CI - Main
4+
5+
on:
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
11+
concurrency:
12+
group: ci-main-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build-and-test:
17+
uses: ./.github/workflows/build-and-test.yml
18+
with:
19+
java-version: '21'
20+
python-version: '3.11'

.github/workflows/create-tagged-release.yml

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

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
concurrency:
7+
group: release-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
tag:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
tag_name: ${{ steps.set_tag.outputs.tag_name }}
15+
dsl_version: ${{ steps.get_dsl_version.outputs.dsl_version }}
16+
artifact_id: ${{ steps.get_artifact_id.outputs.artifact_id }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Java
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: 21
28+
cache: maven
29+
30+
- name: Get DSL version from pom.xml
31+
id: get_dsl_version
32+
run: |
33+
DSL_VERSION=$(mvn help:evaluate -Dexpression=rosetta.dsl.version -q -DforceStdout)
34+
echo "dsl_version=$DSL_VERSION" >> $GITHUB_OUTPUT
35+
36+
- name: Get artifactId from pom.xml
37+
id: get_artifact_id
38+
run: |
39+
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
40+
echo "artifact_id=$ARTIFACT_ID" >> $GITHUB_OUTPUT
41+
42+
- name: Fetch all tags
43+
run: git fetch --tags
44+
45+
- name: Determine next tag
46+
id: set_tag
47+
run: |
48+
DSL_VERSION="${{ steps.get_dsl_version.outputs.dsl_version }}"
49+
TAGS=$(git tag --list "${DSL_VERSION}.*" | sort -V)
50+
if [ -z "$TAGS" ]; then
51+
NEXT_TAG="${DSL_VERSION}.0"
52+
else
53+
MAX_N=$(echo "$TAGS" | sed "s/^${DSL_VERSION}\.//" | sort -n | tail -1)
54+
NEXT_N=$((MAX_N + 1))
55+
NEXT_TAG="${DSL_VERSION}.${NEXT_N}"
56+
fi
57+
echo "tag_name=$NEXT_TAG" >> $GITHUB_OUTPUT
58+
59+
- name: Create and push tag
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
TAG_NAME="${{ steps.set_tag.outputs.tag_name }}"
64+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
65+
echo "Tag $TAG_NAME already exists. Exiting."
66+
exit 1
67+
fi
68+
git config user.name "github-actions[bot]"
69+
git config user.email "github-actions[bot]@users.noreply.github.com"
70+
git tag "$TAG_NAME"
71+
git push origin "$TAG_NAME"
72+
73+
build-and-release:
74+
needs: tag
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
with:
80+
fetch-depth: 0
81+
82+
- name: Set up Java
83+
uses: actions/setup-java@v4
84+
with:
85+
distribution: temurin
86+
java-version: 21
87+
cache: maven
88+
89+
- name: Save original pom.xml
90+
run: cp pom.xml pom.xml.bak
91+
92+
- name: Update pom.xml version to match tag
93+
run: |
94+
mvn -B versions:set -DnewVersion=${{ needs.tag.outputs.tag_name }}
95+
mvn -B versions:commit
96+
97+
- name: Build JARs
98+
run: mvn -B clean package
99+
100+
- name: Revert pom.xml to original
101+
run: mv pom.xml.bak pom.xml
102+
103+
- name: Archive JARs
104+
id: archive
105+
run: |
106+
ARTIFACT_ID="${{ needs.tag.outputs.artifact_id }}"
107+
TAG_NAME="${{ needs.tag.outputs.tag_name }}"
108+
JAR="target/${ARTIFACT_ID}-${TAG_NAME}.jar"
109+
JAVADOC_JAR="target/${ARTIFACT_ID}-${TAG_NAME}-javadoc.jar"
110+
echo "jar_path=$JAR" >> $GITHUB_OUTPUT
111+
echo "javadoc_jar_path=$JAVADOC_JAR" >> $GITHUB_OUTPUT
112+
113+
- name: Create GitHub Release
114+
uses: softprops/action-gh-release@v2
115+
with:
116+
tag_name: ${{ needs.tag.outputs.tag_name }}
117+
name: ${{ needs.tag.outputs.tag_name }}
118+
body: |
119+
Automated release for DSL version ${{ needs.tag.outputs.dsl_version }}
120+
files: |
121+
${{ steps.archive.outputs.jar_path }}
122+
${{ steps.archive.outputs.javadoc_jar_path }}
123+
env:
124+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/renovate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# .github/workflows/renovate.yml
12
# This workflow runs Renovate Bot on a schedule or on demand.
23
# It uses the configuration file located at .github/renovate.json
34

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# workflows/cve-scanning.yml
2+
13
name: CVE Scanning for Maven
24

35
on:
@@ -7,7 +9,7 @@ on:
79

810
# Cancel previous jobs
911
concurrency:
10-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
group: cve-scan-${{ github.ref }}
1113
cancel-in-progress: true
1214

1315
jobs:

.github/workflows/license-scanning-maven.yml renamed to .github/workflows/scan-license.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#workflows/license-scanning-maven.yml
2+
13
name: License Scanning for Maven
24

35
on:
@@ -61,7 +63,7 @@ jobs:
6163
- name: Install XQ
6264
run: pip install xq
6365
- name: Build with Maven
64-
run: mvn clean install -Dmaven.test.skip=true
66+
run: mvn clean package -Dmaven.test.skip=true
6567
working-directory: .
6668
- name: License XML report
6769
run: mvn org.codehaus.mojo:license-maven-plugin:2.0.0:download-licenses

0 commit comments

Comments
 (0)