-
Notifications
You must be signed in to change notification settings - Fork 217
81 lines (71 loc) · 2.76 KB
/
release-project-in-dir.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
name: Release project in specified directory
on:
workflow_call:
inputs:
project_dir:
type: string
required: true
version_branch:
type: string
required: true
env:
# set the target pom to use the input directory as root
MAVEN_ARGS: -V -ntp -e -f ${{ inputs.project_dir }}/pom.xml
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout "${{inputs.version_branch}}" branch
uses: actions/checkout@v4
with:
ref: "${{inputs.version_branch}}"
- name: Set up Java and Maven
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
cache: 'maven'
- name: Change version to release version
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
run: |
mvn ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit -DprocessAllModules
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1
with:
maven_profiles: "release"
maven_args: ${{ env.MAVEN_ARGS }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_TOKEN }}
# This is separate job because there were issues with git after release step, was not able to commit changes.
update-working-version:
runs-on: ubuntu-latest
needs: publish
if: "!contains(github.event.release.tag_name, 'RC')" # not sure we should keep this the RC part
steps:
- name: Checkout "${{inputs.version_branch}}" branch
uses: actions/checkout@v4
with:
ref: "${{inputs.version_branch}}"
- name: Set up Java and Maven
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
cache: 'maven'
- name: Update version to new SNAPSHOT version
run: |
mvn ${MAVEN_ARGS} build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit -DprocessAllModules
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Set new SNAPSHOT version into pom files." -a
env:
RELEASE_VERSION: ${{ github.event.release.tag_name }}
- name: Push changes to branch
uses: ad-m/github-push-action@master
with:
branch: "${{inputs.version_branch}}"
github_token: ${{ secrets.GITHUB_TOKEN }}