Repository navigation
77 lines (75 loc) · 2.91 KB
/
Copy pathrelease.yml
File metadata and controls
77 lines (75 loc) · 2.91 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
name: Release
on:
push:
branches: [ 'release/*' ]
jobs:
build:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v7
- name: Determine version
id: get_version
shell: bash
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
if [[ ${BRANCH##*/} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9\.]+)*(\+[A-Za-z0-9\.\-]+)?$ ]]; then
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
echo "VERSION=${BRANCH##*/}" >> $GITHUB_ENV
else
echo "::error::Not a valid version: ${BRANCH##*/}"
exit 1
fi
- name: Set up Java
uses: actions/setup-java@v6.0.0
with:
distribution: temurin
java-version: |
8
25
mvn-toolchain-id: |
jdk8
jdk25
cache: maven
mvn-server-credentials: central:MAVEN_CENTRAL_USERNAME:MAVEN_CENTRAL_TOKEN
gpg-passphrase-env-var: MAVEN_GPG_PASSPHRASE
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Set version
run: |
./mvnw --batch-mode versions:set versions:commit -DnewVersion="${VERSION}" -DprocessAllModules=true
./mvnw --batch-mode license:format
- name: Commit and tag new version
run: |
git config user.name "Talsma CI"
git config user.email "ci-user@talsma-ict.nl"
git commit -sam "Release: Set project version to ${VERSION}"
git tag -m "Release version ${VERSION}" "${VERSION}"
git push --follow-tags
- name: Deploy release
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USER }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./mvnw --batch-mode clean deploy -Dmaven.repository.credentialScope=id
- name: Create Github release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
draft: true
files: |
**/target/*.jar
**/target/*.jar.asc
- name: Set next snapshot version
run: |
read base minor suffix <<<$(echo "${VERSION}" | perl -pe 's/^(.*?)([0-9]+)([^0-9]*)$/\1 \2 \3/')
nextSnapshot="${base}$((minor+1))${suffix}-SNAPSHOT"
./mvnw --batch-mode versions:set versions:commit -DnewVersion="${nextSnapshot}" -DprocessAllModules=true
git commit -sam "Release: Set next project version to ${nextSnapshot}"
git push --follow-tags
- name: Create post-release merge request
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: gh pr create --head ${BRANCH} --title "Merge release ${VERSION} to main branch" --body 'Created by Github action'