-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (96 loc) · 3.93 KB
/
release.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
# This configuration is used for the deployment and publish to GitHub Packages
name: release
on:
push:
branches:
# Runs only on push to the master branch
- master
jobs:
release:
timeout-minutes: 30
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
# Setup java environment
- name: setup-java
uses: actions/setup-java@v1
with:
java-version: 11
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
# Checkout the git repository
- name: setup-github-release
run: sed -i -e 's/<\/servers>/<server><id>github<\/id><username>x-access-token<\/username><password>${GITHUB_TOKEN}<\/password><\/server><\/servers>/g' /home/runner/.m2/settings.xml
# Setup GPG for Maven Central deployment
- name: setup-gpg
env:
GPG_PRIVATE_KEY: ${{ secrets.OS_GPG_PRIVATE_KEY }}
run: cat <(echo -e "${GPG_PRIVATE_KEY}") | gpg --batch --import
# Checkout the git repository
- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GPR_TOKEN }}
fetch-depth: ''
# Execute some necessary git commands to get more repository informations
- name: post-checkout
run: git fetch --prune --unshallow
# Setup GitHub Actions caching for external dependencies, in this case especially for Maven
- name: caching
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
# Execute Maven command for the deployment and publish to Maven Central
- name: deploy
env:
OSSRH_USERNAME: ${{ secrets.OS_OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OS_OSSRH_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.OS_GPG_PASSPHRASE }}
run: mvn deploy -Dmaven.wagon.http.pool=false -Dgpg.executable=gpg -Dgpg.passphrase=${GPG_PASSPHRASE}
# Execute sonar analysis and publish results to the sonarcloud server
- name: sonar-analyse
env:
SONAR_HOST: ${{ secrets.OS_SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.OS_SONAR_TOKEN }}
run: |
export SONAR_ORGANIZATION=$(echo ${GITHUB_REPOSITORY} | cut -d / -f 1)
mvn sonar:sonar \
-Dsonar.host.url=${SONAR_HOST} \
-Dsonar.login=${SONAR_TOKEN} \
-Dsonar.organization=${SONAR_ORGANIZATION} \
-Dsonar.projectKey=${GITHUB_REPOSITORY//\//_} \
-Dsonar.java.binaries=./target/classes
# Get the current project version from POM
- name: get-project-version
id: get_project_version
uses: avides/actions-project-version-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
file-to-check: pom.xml
only-return-version: true
# Get last commit message for GitHub Release tag
- name: setup-github-release
id: setup_github_release
env:
PROJECT_VERSION: ${{ steps.get_project_version.outputs.version }}
run: |
echo ::set-output name=gitcommitmessage::$(git log --no-merges -1 --oneline)
if [[ "$PROJECT_VERSION" == *"SNAPSHOT"* || "$PROJECT_VERSION" == *"RC"* ]]; then
echo ::set-output name=isprerelease::true
fi
# Create and publish GitHub Release tag
- name: github-release
uses: actions/create-release@v1
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
with:
tag_name: ${{ steps.get_project_version.outputs.version }}
release_name: ${{ steps.get_project_version.outputs.version }}
body: ${{ steps.setup_github_release.outputs.gitcommitmessage }}
prerelease: ${{ steps.setup_github_release.outputs.isprerelease }}