Skip to content

Commit 9bf1d8b

Browse files
refactor github actions. add build and test on develop. release on dsl version change
1 parent c4181d4 commit 9bf1d8b

File tree

8 files changed

+167
-59
lines changed

8 files changed

+167
-59
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ on:
88

99
jobs:
1010
build_and_test:
11-
uses: ./.github/workflows/build-and-test.yml
11+
uses: ./.github/workflows/build-and-test-core.yml

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ on:
88

99
jobs:
1010
build_and_test:
11-
uses: ./.github/workflows/build-and-test.yml
11+
uses: ./.github/workflows/build-and-test-core.yml

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

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

.github/workflows/release-core.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# .github/workflows/release-core.yml
2+
name: Core Release Workflow
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
release_version:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build_and_release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: 'temurin'
22+
java-version: '21'
23+
cache: maven
24+
25+
- name: Get artifactId
26+
id: get_artifact_id
27+
run: |
28+
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
29+
echo "artifact_id=$ARTIFACT_ID" >> $GITHUB_OUTPUT
30+
31+
- name: Set POM version to release version and build
32+
run: |
33+
echo "Updating POM version to ${{ inputs.release_version }}"
34+
mvn -B versions:set -DnewVersion=${{ inputs.release_version }}
35+
mvn -B package -Psign-artifacts
36+
37+
- name: Revert POM changes
38+
run: git checkout -- pom.xml
39+
40+
- name: Check if tag already exists and create if not
41+
id: create_tag
42+
env:
43+
RELEASE_TAG: "rosetta-dsl-v${{ inputs.release_version }}"
44+
run: |
45+
# Fetch all tags to check for existence
46+
git fetch --tags
47+
if git tag | grep -q "${{ env.RELEASE_TAG }}"; then
48+
echo "Tag ${{ env.RELEASE_TAG }} already exists, skipping tag creation."
49+
else
50+
echo "Creating and pushing tag ${{ env.RELEASE_TAG }}"
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
git tag "${{ env.RELEASE_TAG }}"
54+
git push origin "${{ env.RELEASE_TAG }}"
55+
fi
56+
echo "TAG_NAME=${{ env.RELEASE_TAG }}" >> $GITHUB_ENV
57+
58+
- name: Create GitHub Release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
tag_name: ${{ env.TAG_NAME }}
62+
name: Release ${{ env.TAG_NAME }}
63+
files: |
64+
target/${{ steps.get_artifact_id.outputs.artifact_id }}-${{ inputs.release_version }}.jar
65+
target/${{ steps.get_artifact_id.outputs.artifact_id }}-${{ inputs.release_version }}-javadoc.jar
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# .github/workflows/release-on-dsl-version-change.yml
2+
3+
name: Release on DSL Version Change
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
check-dsl-version:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
dsl_version_changed: ${{ steps.check_dsl.outputs.dsl_version_changed }}
15+
current: ${{ steps.get_version.outputs.current }}
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Fetch all tags
21+
22+
- name: Set up JDK
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: 'temurin'
26+
java-version: '21'
27+
cache: maven
28+
29+
- name: Get current DSL version from POM
30+
id: get_version
31+
run: |
32+
CURRENT=$(mvn help:evaluate -Dexpression=rosetta.dsl.version -q -DforceStdout)
33+
echo "Current DSL version: $CURRENT"
34+
echo "current=$CURRENT" >> $GITHUB_OUTPUT
35+
36+
- name: Get latest rosetta-dsl-v* tag
37+
id: get_tag
38+
run: |
39+
TAG=$(git tag --list 'rosetta-dsl-v*' --sort=-v:refname | head -n 1)
40+
if [ -z "$TAG" ]; then
41+
TAG_VERSION=""
42+
else
43+
TAG_VERSION="${TAG#rosetta-dsl-v}"
44+
fi
45+
echo "Latest tag: $TAG"
46+
echo "Latest tag version: $TAG_VERSION"
47+
echo "tag=$TAG" >> $GITHUB_OUTPUT
48+
echo "tag_version=$TAG_VERSION" >> $GITHUB_OUTPUT
49+
50+
- name: Check if DSL version is different from latest tag
51+
id: check_dsl
52+
run: |
53+
CURRENT="${{ steps.get_version.outputs.current }}"
54+
TAG_VERSION="${{ steps.get_tag.outputs.tag_version }}"
55+
if [ -z "$TAG_VERSION" ]; then
56+
echo "No previous tag found. Proceeding with release."
57+
echo "dsl_version_changed=true" >> $GITHUB_OUTPUT
58+
elif [ "$CURRENT" != "$TAG_VERSION" ]; then
59+
echo "DSL version ($CURRENT) is different from latest tag ($TAG_VERSION). Proceeding with release."
60+
echo "dsl_version_changed=true" >> $GITHUB_OUTPUT
61+
else
62+
echo "DSL version ($CURRENT) matches latest tag ($TAG_VERSION). Skipping release."
63+
echo "dsl_version_changed=false" >> $GITHUB_OUTPUT
64+
fi
65+
66+
release:
67+
needs: check-dsl-version
68+
if: needs.check-dsl-version.outputs.dsl_version_changed == 'true'
69+
uses: ./.github/workflows/release-core.yml
70+
with:
71+
release_version: ${{ needs.check-dsl-version.outputs.current }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .github/workflows/release-on-tag.yml
2+
3+
name: Release on tag
4+
5+
on:
6+
push:
7+
tags:
8+
- '*'
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Get tag name
15+
id: get_tag
16+
run: |
17+
TAG_NAME=${GITHUB_REF#refs/tags/}
18+
# Extract version from tag name (e.g., 'rosetta-dsl-v1.2.3' -> '1.2.3')
19+
RELEASE_VERSION=${TAG_NAME#rosetta-dsl-v}
20+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
21+
echo "release_version=$RELEASE_VERSION" >> $GITHUB_OUTPUT
22+
23+
- name: Call core release workflow
24+
uses: ./.github/workflows/release-core.yml
25+
with:
26+
release_version: ${{ steps.get_tag.outputs.release_version }}

build/common-domain-model

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 4709e5277a075be43942a27b91a275c098fc65e9

0 commit comments

Comments
 (0)