-
Notifications
You must be signed in to change notification settings - Fork 6
193 lines (171 loc) · 7.26 KB
/
build-and-deploy.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
name: Build and Deploy
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
permissions:
contents: write
pages: write
id-token: write
jobs:
check:
runs-on: ubuntu-latest
outputs:
annotations-status: ${{ steps.annotations-check.outputs.annotations-status }}
plugin-status: ${{ steps.plugin-check.outputs.plugin-status }}
steps:
- uses: actions/checkout@v3
- name: Detect production files changes
id: changes
uses: dorny/paths-filter@v2
with:
filters: |
annotations:
- 'livingdoc-annotations/src/**'
- 'livingdoc-annotations/pom.xml'
plugin:
- 'livingdoc-maven-plugin/src/**'
- 'livingdoc-maven-plugin/pom.xml'
- name: Save annotations project production files changes status
id: annotations-check
run: |
status="skip"
if [ "${{ steps.changes.outputs.annotations }}" == "true" ]; then
status="deploy"
fi
echo "annotations-status=$status" >> $GITHUB_OUTPUT
- name: Save plugin project production files changes status
id: plugin-check
run: |
status="skip"
if [ "${{ steps.changes.outputs.plugin }}" == "true" ]; then
status="deploy"
fi
echo "plugin-status=$status" >> $GITHUB_OUTPUT
livingdoc-annotations:
runs-on: ubuntu-latest
needs: check
if: "needs.check.outputs.annotations-status == 'deploy' && !contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.ACTION_BOT_SECRET_KEY }}
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: 19
distribution: adopt
cache: maven
server-id: ossrh
server-username: OSS_SONATYPE_USERNAME
server-password: OSS_SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Create maven release version
if: ${{ github.event_name == 'push' }}
working-directory: ./livingdoc-annotations
run: mvn -f pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion} versions:commit
- name: Deploy
working-directory: ./livingdoc-annotations
run: mvn deploy -P release -DskipTests=true
env:
OSS_SONATYPE_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
OSS_SONATYPE_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Create and commit next dev version
if: ${{ github.event_name == 'push' }}
working-directory: ./livingdoc-annotations
run: mvn -f pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT versions:commit
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Post release - livingdoc-annotations - ci skip
livingdoc-maven-plugin:
runs-on: ubuntu-latest
needs: check
if: "needs.check.outputs.plugin-status == 'deploy' && !contains(github.event.head_commit.message, 'ci skip')"
steps:
- uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.ACTION_BOT_SECRET_KEY }}
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: 19
distribution: adopt
cache: maven
server-id: ossrh
server-username: OSS_SONATYPE_USERNAME
server-password: OSS_SONATYPE_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Create maven release version
if: ${{ github.event_name == 'push' }}
run: |
mvn -f livingdoc-maven-plugin/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion} versions:commit
mvn -f livingdoc-examples/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion} versions:commit
- name: Deploy
working-directory: ./livingdoc-maven-plugin
run: mvn --batch-mode --update-snapshots deploy -P release -X
env:
OSS_SONATYPE_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
OSS_SONATYPE_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Save artefacts for next jobs
uses: actions/upload-artifact@v3
with:
name: livingdoc-maven-plugin-artifact
path: |
livingdoc-maven-plugin/target/livingdoc-maven-plugin-*.jar
livingdoc-maven-plugin/target/livingdoc-maven-plugin-*.pom
retention-days: 1
- name: Create next dev version
if: ${{ github.event_name == 'push' }}
run: |
mvn -f livingdoc-maven-plugin/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT versions:commit
mvn -f livingdoc-examples/pom.xml -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}-SNAPSHOT versions:commit
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Post release - livingdoc-maven-plugin - ci skip
tests_java_plugin:
runs-on: ubuntu-latest
needs:
- check
- livingdoc-maven-plugin
if: "needs.check.outputs.plugin-status == 'deploy' && github.event_name == 'pull_request'"
strategy:
matrix:
version: [11, 15, 17]
env:
folder: livingdoc-examples
steps:
- uses: actions/checkout@v3
- name: Set up java
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.version }}
distribution: adopt
cache: maven
- name: Prepare to install livingdoc-maven-plugin artifact locally
working-directory: ./livingdoc-maven-plugin
run: |
ARTIFACT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
ARTIFACT_PATH=~/.m2/repository/ch/ifocusit/livingdoc/livingdoc-maven-plugin/$ARTIFACT_VERSION/
echo ::set-env name=ARTIFACT_PATH::$ARTIFACT_PATH
echo ::set-env name=LIVINGDOC-MAVEN-PLUGIN_VERSION::$ARTIFACT_VERSION
- name: Install livingdoc-maven-plugin artifact locally
uses: actions/download-artifact@v3
with:
name: livingdoc-maven-plugin-artifact
path: ${{ env.ARTIFACT_PATH }}
- name: Test ${{ matrix.version }}
working-directory: ./livingdoc-maven-plugin/src/nonreg/example-java-x
run: |
sed -i -e "s/\${env.LIVINGDOC-MAVEN-PLUGIN_VERSION}/${{ env.LIVINGDOC-MAVEN-PLUGIN_VERSION }}/g" pom.xml
mvn --batch-mode --update-snapshots verify
env:
JAVA_VERSION: ${{ matrix.version }}
LIVINGDOC-MAVEN-PLUGIN_VERSION: ${{ env.LIVINGDOC-MAVEN-PLUGIN_VERSION }}