Skip to content

Commit f4ee355

Browse files
chore(DVIZ-24): add maven release github action
1 parent a032970 commit f4ee355

File tree

4 files changed

+471
-21
lines changed

4 files changed

+471
-21
lines changed

.github/workflows/release.yml

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,64 @@ on:
77
- main
88
- release/*
99

10-
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
packages: write
1114

1215
jobs:
13-
build_and_release:
16+
release-and-tag:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
version: ${{ steps.release.outputs.version }}
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: '0'
25+
- name: Set up JDK
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '21'
29+
distribution: 'corretto'
30+
cache: 'maven'
31+
32+
- name: Configure Git user
33+
run: |
34+
git config user.email "actions@github.com"
35+
git config user.name "GitHub Actions"
36+
37+
- name: Prepare Release
38+
id: release
39+
run: |
40+
# Get current version from pom.xml
41+
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
42+
echo "Current version: $CURRENT_VERSION"
43+
44+
# Remove -SNAPSHOT and calculate next version
45+
VERSION=${CURRENT_VERSION%-SNAPSHOT}
46+
IFS='.' read -r major minor patch <<< "$VERSION"
47+
NEXT_VERSION="$major.$minor.$((patch + 1))-SNAPSHOT"
48+
49+
# Perform release
50+
mvn -B release:prepare release:perform \
51+
-DreleaseVersion=$VERSION \
52+
-DdevelopmentVersion=$NEXT_VERSION \
53+
-DtagNameFormat=v@{project.version} \
54+
-DpushChanges=true \
55+
-DlocalCheckout=true \
56+
-DpreparationGoals="clean verify" \
57+
-DskipTests
58+
59+
echo "version=$VERSION" >> $GITHUB_OUTPUT
60+
echo "Released version $VERSION"
61+
62+
build-and-push-docker-image:
63+
needs: release-and-tag
1464
runs-on: ubuntu-latest
1565
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v3
66+
- name: Checkout Repository
67+
uses: actions/checkout@v4
1868

1969
- name: Set up QEMU
2070
uses: docker/setup-qemu-action@v3
@@ -31,17 +81,6 @@ jobs:
3181
username: ${{ secrets.DOCKER_USERNAME }}
3282
password: ${{ secrets.DOCKER_PASSWORD }}
3383

34-
- name: Determine the version tag
35-
id: version
36-
run: |
37-
if [ "${{ github.event_name }}" = "release" ]; then
38-
echo "Using release tag: ${{ github.ref_name }}"
39-
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
40-
else
41-
echo "No release detected. Using tag: latest"
42-
echo "version=latest" >> $GITHUB_OUTPUT
43-
fi
44-
4584
- name: Build and push Docker image
4685
uses: docker/build-push-action@v6
4786
with:
@@ -50,5 +89,9 @@ jobs:
5089
cache-to: type=gha, scope=data-viz-admin
5190
context: .
5291
push: true
53-
tags: ${{ vars.DOCKER_REGISTRY }}/data-viz-admin:${{ steps.version.outputs.version }}
54-
92+
build-args: |
93+
VERSION=${{ needs.release-and-tag.outputs.version }}
94+
TAG=${{ needs.release-and-tag.outputs.version }}
95+
tags: |
96+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:latest
97+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:v${{ needs.release-and-tag.outputs.version }}

mvnw

Lines changed: 259 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)