forked from akurdyukov/crowd-ldap-server
-
Notifications
You must be signed in to change notification settings - Fork 3
156 lines (152 loc) · 6.4 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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
env:
CROWD_LICENSE_KEY: ${{ secrets.CROWD_LICENSE_KEY }}
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 resolving,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_KEY_BASE64 }}
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: Build project
run: |
mvn --batch-mode package \
-DskipTests=true
- 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 resolving,signing,deploying \
-DskipTests=true \
-DskipITs=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 GitHub Docker registry (base image RHEL UBI)
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-rhel
tags: |
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:rhel
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major }}-rhel
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major-minor }}-rhel
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major-minor-patch }}-rhel
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:canary-rhel
- name: Publish to GitHub Docker registry (base image Ubuntu)
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/${{ github.repository_owner }}/ldap-crowd-adapter:ubuntu
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major }}-ubuntu
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major-minor }}-ubuntu
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major-minor-patch }}-ubuntu
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:canary-ubuntu
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:latest
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major }}
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major-minor }}
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:${{ steps.tagging.outputs.version-major-minor-patch }}
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:canary
- name: Publish to GitHub Docker registry (base image RHEL UBI; canary release only)
if: ${{ steps.tagging.outputs.tag-created == 'no' }}
uses: docker/build-push-action@v2
with:
push: true
context: .
file: ./docker/Dockerfile-rhel
tags: |
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:canary-rhel
- name: Publish to GitHub Docker registry (base image Ubuntu; 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/${{ github.repository_owner }}/ldap-crowd-adapter:canary-ubuntu
ghcr.io/${{ github.repository_owner }}/ldap-crowd-adapter:canary