-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (117 loc) · 4.11 KB
/
ci_test-release.yaml
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
name: Java Maven CI for test and release actions
on:
push:
branches:
- 'main'
- 'feature/**'
- 'fix/**'
pull_request:
branches:
- 'main'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v2
with:
fetch-depth: 0 # shallow clones should be disabled for a better relevancy of analysis
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
architecture: x64
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-maven2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven2
- name: Build project
run: |
mvn --batch-mode package \
-DskipTests=true
- name: Test project
run: |
mvn --batch-mode verify
- name: Perform static code analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn --batch-mode sonar:sonar \
--settings ./.github/workflows/settings.xml \
-P analyzing
release:
needs: test
if: github.event_name == 'push' && github.ref_name == 'main'
runs-on: ubuntu-latest
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
architecture: x64
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-maven2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven2
- name: Import GPG key
run: echo "${GPG_SIGNING_KEY}" | base64 --decode | gpg --no-tty --batch --import
- name: Perform tagging if version has changed
id: tagging
uses: brettaufheber/auto-tagging-action@v1
with:
command: mvn --batch-mode help:evaluate -Dexpression=project.version | grep -v -E '^\[([A-Za-z])+\]'
tag-prefix: 'v'
- name: Publish to public Maven2 repository
if: ${{ steps.tagging.outputs.tag-created == 'yes' || steps.tagging.outputs.strategy == 'snapshot' }}
run: |
mvn --batch-mode deploy \
--settings ./.github/workflows/settings.xml \
-P signing,deploying \
-DskipTests=true
- name: Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Docker registry
if: ${{ steps.tagging.outputs.tag-created == 'yes' && steps.tagging.outputs.version-major-minor-patch }}
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./docker/Dockerfile
tags: |
ghcr.io/opalia/osgi-launcher:latest
ghcr.io/opalia/osgi-launcher:canary
ghcr.io/opalia/osgi-launcher:${{ steps.tagging.outputs.version-major }}
ghcr.io/opalia/osgi-launcher:${{ steps.tagging.outputs.version-major-minor }}
ghcr.io/opalia/osgi-launcher:${{ steps.tagging.outputs.version-major-minor-patch }}
- name: Publish to Docker registry (canary release only)
if: ${{ steps.tagging.outputs.tag-created == 'no' }}
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./docker/Dockerfile
tags: |
ghcr.io/opalia/osgi-launcher:canary