Skip to content

Commit b3fdc42

Browse files
committed
Separate build- and release-workflow
- Reduce complexity - Avoid accidental release when branch name matches tag pattern - Add maven options which are useful in CI environments
1 parent a6cd9d4 commit b3fdc42

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: build
22
on:
33
push:
44
branches: [ '*' ]
5-
tags: [ '*' ]
65
pull_request:
76
branches: [ '*' ]
87
jobs:
@@ -15,21 +14,4 @@ jobs:
1514
distribution: 'zulu'
1615
java-version: '8'
1716
- name: maven build
18-
env:
19-
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
20-
GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }}
21-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
22-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
23-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
24-
run: |
25-
if echo "${GITHUB_REF_NAME}" | egrep '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$'
26-
then
27-
# the tag looks like a version number: proceed with release
28-
echo ${GPG_SECRET_KEY} | base64 --decode | gpg --import --no-tty --batch --yes
29-
echo ${GPG_OWNERTRUST} | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes
30-
mvn -ntp versions:set -DnewVersion=${GITHUB_REF_NAME}
31-
mvn -ntp -s .github/settings.xml -Prelease deploy
32-
else
33-
# this is a regular build
34-
mvn -ntp install
35-
fi
17+
run: mvn --batch-mode --errors --show-version --no-transfer-progress clean verify

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: release
2+
on:
3+
push:
4+
tags: [ '*' ]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-java@v3
12+
with:
13+
distribution: 'zulu'
14+
java-version: '8'
15+
- name: maven release
16+
env:
17+
GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
18+
GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }}
19+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
20+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
21+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
22+
run: |
23+
if echo "${GITHUB_REF_NAME}" | egrep '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$'
24+
then
25+
# the tag looks like a version number: proceed with release
26+
echo ${GPG_SECRET_KEY} | base64 --decode | gpg --import --no-tty --batch --yes
27+
echo ${GPG_OWNERTRUST} | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes
28+
mvn --batch-mode --errors --show-version --no-transfer-progress versions:set -DnewVersion=${GITHUB_REF_NAME}
29+
mvn --batch-mode --errors --show-version --no-transfer-progress --settings .github/settings.xml -Prelease deploy
30+
fi

0 commit comments

Comments
 (0)