Skip to content

Commit c3acd1c

Browse files
github action to build and tag from rosetta.bundle
1 parent 97d912b commit c3acd1c

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and Tag with Rosetta Bundle Version
2+
3+
on:
4+
workflow_dispatch:
5+
# Optionally, you can trigger on push to main or other events
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
contents: write
13+
packages: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: '21'
24+
cache: maven
25+
26+
- name: Cache Maven dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.m2/repository
30+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
31+
restore-keys: |
32+
${{ runner.os }}-maven-
33+
34+
- name: Download external POM
35+
run: |
36+
curl -L -o cdm-pom.xml https://raw.githubusercontent.com/finos/common-domain-model/main/pom.xml
37+
38+
- name: Extract rosetta.bundle.version from external POM
39+
id: extract_version
40+
run: |
41+
# Try to extract from <properties> first, fallback to profile if needed
42+
version=$(xmllint --xpath "string(//properties/rosetta.bundle.version)" cdm-pom.xml)
43+
if [ -z "$version" ]; then
44+
version=$(xmllint --xpath "string(//profile/properties/rosetta.bundle.version)" cdm-pom.xml)
45+
fi
46+
echo "rosetta.bundle.version=$version"
47+
echo "version=$version" >> $GITHUB_OUTPUT
48+
49+
- name: Override rosetta.bundle.version in local pom.xml
50+
run: |
51+
version="${{ steps.extract_version.outputs.version }}"
52+
# Replace in <properties>
53+
sed -i "s|<rosetta.bundle.version>.*</rosetta.bundle.version>|<rosetta.bundle.version>${version}</rosetta.bundle.version>|" pom.xml
54+
# Replace in <profile> (if present)
55+
sed -i "s|<rosetta.bundle.version>.*</rosetta.bundle.version>|<rosetta.bundle.version>${version}</rosetta.bundle.version>|" pom.xml
56+
57+
- name: Set POM version to rosetta.bundle.version
58+
run: |
59+
version="${{ steps.extract_version.outputs.version }}"
60+
echo "Setting POM version to $version"
61+
mvn -B versions:set -DnewVersion=$version
62+
63+
- name: Build with Maven
64+
run: mvn -B package
65+
66+
- name: Revert POM changes
67+
run: git checkout -- pom.xml
68+
69+
- name: Upload JAR files
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: jar-files
73+
path: target/*.jar
74+
75+
- name: Create GitHub Tag and Release
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
tag_name: ${{ steps.extract_version.outputs.version }}
79+
name: Release ${{ steps.extract_version.outputs.version }}
80+
files: target/*.jar
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)