-
-
Notifications
You must be signed in to change notification settings - Fork 9
190 lines (162 loc) · 5.97 KB
/
build.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
# Copyright 2018-2024 Volkan Yazıcı <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permits and
# limitations under the License.
name: build
on:
push:
# Avoid workflow run for _merged_ `dependabot` PRs.
# They were (hopefully!) already tested in PR-triggered workflow.
branches-ignore: "dependabot/**"
pull_request:
paths-ignore:
- "**.adoc"
- "**.md"
- "**.txt"
permissions:
contents: write
pull-requests: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup JDK 8
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-package: jdk
architecture: x64
cache: maven
- name: Build with Maven
shell: bash
run: |
./mvnw \
--show-version --batch-mode --errors --no-transfer-progress \
-DtrimStackTrace=false \
-DskipTests=true \
verify
- name: Test scheduler shutdown
timeout-minutes: 1
# pwsh (the default shell on Windows) hijacks "exec" keyword
shell: bash
run: |
./mvnw \
--show-version --batch-mode --errors --no-transfer-progress \
-Dexec.classpathScope=test \
-Dexec.mainClass=com.vlkan.rfos.SchedulerShutdownTestApp \
exec:java
merge:
runs-on: ubuntu-latest
needs: build
steps:
- name: "[dependabot] Fetch metadata"
id: metadata
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: "[dependabot] Auto-merge the PR"
if: github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-latest
needs: merge
if: github.repository == 'vy/rotating-fos' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/'))
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup JDK 8
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-package: jdk
architecture: x64
cache: maven
- name: Import GPG private key
run: |
echo -n "$GPG_PKEY" \
| base64 --decode \
| gpg -v --batch --import --yes --pinentry-mode error
env:
GPG_PKEY: ${{ secrets.GPG_PKEY }}
- name: Export artifact version
run: |
./mvnw \
--quiet --batch-mode -DforceStdout=true \
-Dexpression=project.version \
help:evaluate \
| tee /tmp/mvnw-project-version.out
- name: Check version (SNAPSHOT)
if: github.ref == 'refs/heads/master'
run: |
export REVISION=$(</tmp/mvnw-project-version.out)
[[ "$REVISION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] || {
echo "was expecting a snapshot version, found: $REVISION" 1>&2
exit 1
}
- name: Check version (RELEASE)
if: startsWith(github.ref, 'refs/heads/release/')
run: |
export REVISION=$(</tmp/mvnw-project-version.out)
[[ "${GITHUB_REF/refs\/heads\/release\//}" == "$REVISION" ]] || {
echo "git ref \"$GITHUB_REF\" mismatches with the version: \"$REVISION\"" 1>&2
exit 1
}
[[ "$REVISION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "was expecting a release version, found: \"$REVISION\"" 1>&2
exit 1
}
export CHANGELOG_VERSION=$(grep "^### " CHANGELOG.md | head -n 1 | sed -r 's/^### \(.*\) v(.*)$/\1/')
[[ "$REVISION" == "$CHANGELOG_VERSION" ]] || {
echo "version \"$REVISION\" doesn't match the one in the CHANGELOG: \"$CHANGELOG_VERSION\"" 1>&2
exit 1
}
export CURRENT_DATE=$(date +%Y-%m-%d)
export CHANGELOG_DATE=$(grep "^### " CHANGELOG.md | head -n 1 | sed -r 's/^### \((.*)\) v.*$/\1/')
[[ "$CURRENT_DATE" == "$CHANGELOG_DATE" ]] || {
echo "current date \"$CURRENT_DATE\" doesn't match the one in the CHANGELOG: \"$CHANGELOG_DATE\"" 1>&2
exit 1
}
- name: Deploy
# "package" phase is necessary before "gpg:sign" goal.
run: |
./mvnw \
-V -B --no-transfer-progress -e \
-DskipTests=true \
-DperformRelease=true \
-DdeployAtEnd=true \
--settings .github/maven-settings.xml \
package gpg:sign install:install deploy:deploy
env:
GPG_PKEY_ID: ${{ secrets.GPG_PKEY_ID }}
GPG_PKEY_PASS: ${{ secrets.GPG_PKEY_PASS }}
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_PASS: ${{ secrets.NEXUS_PASS }}
- name: Tag version (RELEASE)
if: startsWith(github.ref, 'refs/heads/release/')
run: |
export REVISION=$(</tmp/mvnw-project-version.out)
export TAG="v$REVISION"
git config user.name github-actions
git config user.email [email protected]
git tag "$TAG"
git push origin "$TAG"