-
Notifications
You must be signed in to change notification settings - Fork 30
133 lines (118 loc) · 4.49 KB
/
release.yml
File metadata and controls
133 lines (118 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Release
on:
release:
types:
- published
jobs:
sonar:
if: "!contains(github.event.head_commit.message, '[version bump]')"
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'microsoft'
java-version: '21'
cache: 'maven'
- name: Build and Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify sonar:sonar -Dgpg.skip
publish:
if: "!contains(github.event.head_commit.message, '[version bump]')"
runs-on: ubuntu-latest
needs: [ sonar ]
steps:
- name: Checkout project
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'microsoft'
java-version: '21'
cache: 'maven'
server-id: 'central'
server-username: SONATYPE_USERNAME
server-password: SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Configure Git user
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
- name: Get version from POM without SNAPSHOT
run: |
VERSION_PARTS=($(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | cut -d- -f1 | tr "." "\n"))
echo "MAJOR=${VERSION_PARTS[0]}" >> $GITHUB_ENV
echo "MINOR=${VERSION_PARTS[1]}" >> $GITHUB_ENV
echo "PATCH=${VERSION_PARTS[2]}" >> $GITHUB_ENV
- name: Setup release version
run: |
NEW_VERSION="$((MAJOR)).$((MINOR)).$((PATCH))"
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Update POM Version
run: |
echo "New version is: $NEW_VERSION"
mvn versions:set -DnewVersion=${NEW_VERSION} -DgenerateBackupPoms=false -B
- name: Build and Publish
run: |
mvn \
--no-transfer-progress \
--batch-mode \
-DskipTests=true \
-Psonatype-deploy \
deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
- name: Commit files
run: |
git commit -m "[version bump]" -a
git tag -a release-$NEW_VERSION -m "[version bump]"
git push origin release-$NEW_VERSION
bump:
if: "!contains(github.event.head_commit.message, '[version bump]')"
runs-on: ubuntu-latest
needs: [ publish ]
steps:
- name: Checkout Branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.release.target_commitish }}
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'microsoft'
java-version: '21'
cache: 'maven'
- name: Configure Git user
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
- name: Get version from POM without SNAPSHOT
run: |
VERSION_PARTS=($(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | cut -d- -f1 | tr "." "\n"))
echo "MAJOR=${VERSION_PARTS[0]}" >> $GITHUB_ENV
echo "MINOR=${VERSION_PARTS[1]}" >> $GITHUB_ENV
echo "PATCH=${VERSION_PARTS[2]}" >> $GITHUB_ENV
- name: Bump And Update POM Version to new Development version
id: bump_version
run: |
NEW_VERSION="$((MAJOR)).$((MINOR)).$((PATCH+1))-SNAPSHOT"
echo "New development version is: $NEW_VERSION"
mvn versions:set -DnewVersion=${NEW_VERSION} -DgenerateBackupPoms=false
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
title: "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
body: "Bumps the version to the next development version."
branch: "chore/bump-version-${{ steps.bump_version.outputs.new_version }}"
base: ${{ github.event.release.target_commitish || 'main' }}
labels: automerge