-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (185 loc) · 7.06 KB
/
build-develop.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: JUDO Documentation Develop
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
workflow_dispatch:
jobs:
build:
name: ⏳ Build, test and deploy artifacts
runs-on: judong
timeout-minutes: 30
env:
SIGN_KEY_ID: ${{ secrets.GPG_KEYNAME }}
SIGN_KEY_PASS: ${{ secrets.GPG_PASSPHRASE }}
SIGN_KEY: ${{ secrets.GPG_SECRET_KEYS }}
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: 🛠️ Project context
id: context
uses: zero88/[email protected]
- name: 🛠️ Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'zulu'
- name: 🔢 Get the current PR number
uses: jwalton/gh-find-current-pr@v1
id: current-pr
with:
state: open
- name: 🧹 Remove settings.xml
run: rm $HOME/.m2/settings.xml || true
- name: 🛠️ Setup maven settings.xml
uses: whelk-io/maven-settings-xml-action@v20
with:
servers: >
[
{
"id": "judong-nexus-mirror",
"username": "${{ secrets.JUDONG_NEXUS_USERNAME }}",
"password": "${{ secrets.JUDONG_NEXUS_PASSWORD }}"
},
{
"id": "judong-nexus-distribution",
"username": "${{ secrets.JUDONG_NEXUS_USERNAME }}",
"password": "${{ secrets.JUDONG_NEXUS_PASSWORD }}"
},
{
"id": "ossrh",
"username": "${{ secrets.SONATYPE_USERNAME }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}
]
mirrors: >
[
{
"id": "judong-nexus-mirror",
"mirrorOf": "*",
"url": "https://nexus.judo.technology/repository/maven-judong/"
}
]
- name: 🔢 Calculate version number
id: version
run: |-
POM_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dtycho.mode=maven -DskipModules=true -Dexpression=project.version -q -DforceStdout)
if [[ "${POM_VERSION}" == *-SNAPSHOT ]]; then
BASE_VERSION=$(echo "${POM_VERSION}" | cut -d'-' -f 1)
else
BASE_VERSION=${POM_VERSION}
fi
if [[ "${{ github.base_ref }}" == "master" ]]; then
VERSION_NUMBER=${BASE_VERSION}
else
TAG_NAME=$(echo "${{ steps.context.outputs.branch }}" | cut -d ' ' -f2 | tr '#\/\.-' '_')
VERSION_NUMBER=${BASE_VERSION}.$(date +%Y%m%d_%H%M%S)_${{ steps.context.outputs.shortCommitId }}_${TAG_NAME//[(\)]}
fi
echo "Version from POM: ${POM_VERSION}"
echo "Base version from POM: ${BASE_VERSION}"
echo "Building version: ${VERSION_NUMBER}"
echo "version=${VERSION_NUMBER}" >> $GITHUB_OUTPUT
##########################
# MAVEN BUILD START
##########################
# Phase 1 - Build and deploy to judong nexus
- name: 🔥 Build with Maven (build, test)
run: |-
./mvnw -B -Dstyle.color=always \
-Drevision=${{ steps.version.outputs.version }} \
-Psign-artifacts \
-Prelease-judong \
deploy
##########################
# MAVEN BUILD END
##########################
- name: Auth
if: |-
${{ always() && startsWith(github.head_ref, 'develop') && job.status == 'success' }}
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.JUDO_DOCUMENTATION_GCP }}
- name: Upload
if: |-
${{ always() && startsWith(github.head_ref, 'develop') && job.status == 'success' }}
uses: google-github-actions/upload-cloud-storage@v1
with:
path: build/
parent: false
destination: judo-develop-documentation
concurrency: 10
- name: create-json
if: |-
${{ always() && startsWith(github.head_ref, 'develop') && job.status == 'success' }}
uses: jsdaniell/[email protected]
with:
name: "gcp-token.json"
json: ${{ secrets.JUDO_DOCUMENTATION_GCP }}
- name: 'Set up Cloud SDK'
if: |-
${{ always() && startsWith(github.head_ref, 'develop') && job.status == 'success' }}
uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 363.0.0'
- name: set mainfile in bucket
if: |-
${{ always() && startsWith(github.head_ref, 'develop') && job.status == 'success' }}
run: |-
gcloud auth activate-service-account --key-file=gcp-token.json
gsutil web set -m index.html gs://judo-develop-documentation
- name: 📌 Create version tag
uses: actions/github-script@v5
with:
github-token: ${{ secrets.OSS_PAT }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/v${{ steps.version.outputs.version }}',
sha: context.sha
})
- name: 🏗️ Build Changelog
id: create_changelog
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
toTag: v${{ steps.version.outputs.version }}
- name: 🎤 Create message
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: v${{ steps.version.outputs.version }}
tag: v${{ steps.version.outputs.version }}
generateReleaseNotes: false
body: ${{steps.create_changelog.outputs.changelog}}
draft: false
prerelease: true
- name: Create message
id: message
if: ${{ always() }}
run: |-
if [ "${{ job.status }}" == "success" ]; then
message=":white_check_mark: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
message="${message} Version: ${{ steps.version.outputs.version }}"
fi
if [ "${{ job.status }}" == "failure" ]; then
message=":x: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi
if [ "${{ job.status }}" == "canceled" ]; then
message=":x: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi
echo "::set-output name=message::${message}"
- name: 📢 Send message to discord
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.JUDONG_DISCORD_WEBHOOK }}
title: "Gitub action"
description: "${{ steps.message.outputs.message }}"