-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (112 loc) · 5.11 KB
/
bump-version.yml
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
name: Bump version
on:
workflow_dispatch:
inputs:
next_version:
description: Updated version (if not set next minor is used)
type: string
required: false
default: "Auto"
jobs:
bump-version:
runs-on: judong
timeout-minutes: 30
env:
SIGN_KEY_ID: ${{ secrets.GPG_KEYNAME }}
SIGN_KEY_PASS: ${{ secrets.GPG_PASSPHRASE }}
SIGN_KEY: ${{ secrets.GPG_SECRET_KEYS }}
outputs:
version: ${{ steps.version.outputs.version }}
message: ${{ steps.success_message.outputs.message }}${{ steps.failure_message.outputs.message }}${{ steps.cancel_message.outputs.message }}
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v3
with:
ref: develop
token: ${{ secrets.OSS_PAT }}
fetch-depth: 2
- name: 🛠️ Project context
id: context
uses: zero88/[email protected]
- name: 🧹 Remove toolchains.xml
run: rm $HOME/.m2/toolchains.xml || true
- name: 🛠️ Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: 🧹 Remove settings.xml
run: rm $HOME/.m2/settings.xml || true
- name: 🛠️ Setup maven settings.xml
uses: whelk-io/maven-settings-xml-action@v21
with:
servers: >
[
{
"id": "judong-nexus-mirror",
"username": "${{ secrets.JUDONG_NEXUS_USERNAME }}",
"password": "${{ secrets.JUDONG_NEXUS_PASSWORD }}"
},
{
"id": "judong-nexus-distribution",
"username": "${{ secrets.JUDONG_NEXUS_USERNAME }}",
"password": "${{ secrets.JUDONG_NEXUS_PASSWORD }}"
}
]
mirrors: >
[
{
"id": "judong-nexus-mirror",
"mirrorOf": "*",
"url": "https://nexus.judo.technology/repository/maven-judong/"
}
]
- name: 🔢 Calculate version number
id: version
run: |-
TAG_NAME=$(echo "${{ steps.context.outputs.branch }}" | cut -d ' ' -f2 | tr '#\/\.-' '_')
BASE_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dtycho.mode=maven -DskipModules=true -Dexpression=project.version -q -DforceStdout | cut -d'-' -f 1)
VERSION_NUMBER=${BASE_VERSION}
echo "Base version from POM: $BASE_VERSION"
echo "Building version: ${VERSION_NUMBER}"
echo "version=${VERSION_NUMBER}" >> $GITHUB_OUTPUT
echo "base-version=${BASE_VERSION}" >> $GITHUB_OUTPUT
- name: ⏭️ Increase version number
id: next_version
run: |-
NEXT_VERSION="${{ github.event.inputs.next_version }}"
if [ -z "$NEXT_VERSION" ] || [ $NEXT_VERSION == "Auto" ]; then
NEXT_VERSION=`(echo $(./mvnw build-helper:parse-version org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dtycho.mode=maven -DskipModules=true -Dexpression="parsedVersion.majorVersion" -q -DforceStdout) &&\
echo "." && \
echo $(./mvnw build-helper:parse-version org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dtycho.mode=maven -DskipModules=true -Dexpression="parsedVersion.minorVersion" -q -DforceStdout) &&\
echo "." && \
echo $(./mvnw build-helper:parse-version org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dtycho.mode=maven -DskipModules=true -Dexpression="parsedVersion.nextIncrementalVersion" -q -DforceStdout) &&\
echo "-SNAPSHOT") \
| tr -d '\n'`
fi
if [[ ! $NEXT_VERSION =~ ^.*-SNAPSHOT ]]; then
NEXT_VERSION="${NEXT_VERSION}-SNAPSHOT"
fi
echo "Next version is: $NEXT_VERSION"
echo "version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
- name: Set next version
run: |-
mvn tycho-versions:set-version -DnewVersion=${{ steps.next_version.outputs.version }} -Dtycho.mode=maven
mvn tycho-versions:update-eclipse-metadata -Dtycho.mode=maven
git ls-files | grep pom.xml | xargs git restore --
./mvnw versions:set-property -Dproperty=revision -DnewVersion=${{ steps.next_version.outputs.version }} -Dtycho.mode=maven -DskipModules=true
- name: ⬆️ Create Pull Request for increased version into develop
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.OSS_PAT }}
commit-message: '[BUMP VERSION] Increase version to ${{ steps.next_version.outputs.version }}'
branch: increment/v${{ steps.next_version.outputs.version }}
delete-branch: true
branch-suffix: short-commit-hash
title: '[BUMP VERSION] Set develop version to: ${{ steps.next_version.outputs.version }}'
body: >
This PR is auto-generated. Increasing development version and creates a pull request to develop.
labels: release, automated pr