-
Notifications
You must be signed in to change notification settings - Fork 41
227 lines (209 loc) · 8.7 KB
/
publish-snapshot.yml
File metadata and controls
227 lines (209 loc) · 8.7 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: Publish Snapshot
on:
workflow_run:
workflows: [Build Snapshot]
types:
- completed
branches:
- main
permissions:
contents: read # to fetch code (actions/checkout)
env:
LANG: 'en_US.UTF-8'
jobs:
check-version:
# only run in the official pmd/pmd-eclipse-plugin repo, where we have access to the secrets and not on forks
# and only run for _successful_ push workflow runs on branch "main".
if: ${{ github.repository == 'pmd/pmd-eclipse-plugin'
&& contains(fromJSON('["push", "workflow_dispatch", "schedule"]'), github.event.workflow_run.event)
&& github.event.workflow_run.head_branch == 'main'
&& github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
ref: main
- name: Set up JDK 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0
with:
distribution: temurin
java-version: '21'
- name: Cache local Maven repository
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 #v5.0.3
with:
path: |
~/.m2/repository
net.sourceforge.pmd.eclipse.plugin/japicmp-data
# re-cache on changes in the pom and target files
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Determine Version
id: version
run: |
VERSION=$(./mvnw --batch-mode --no-transfer-progress help:evaluate -Dexpression=project.version -q -DforceStdout -Dtycho.mode=maven)
echo "Determined VERSION=$VERSION"
if [[ "$VERSION" != *-SNAPSHOT ]]; then
echo "::error ::VERSION=$VERSION is not a snapshot version, aborting."
exit 1
fi
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Add Job Summary
env:
WORKFLOW_RUN_DISPLAY_TITLE: ${{ github.event.workflow_run.display_title }}
WORKFLOW_RUN_NAME: ${{ github.event.workflow_run.name }}
WORKFLOW_RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
WORKFLOW_RUN_HTML_URL: ${{ github.event.workflow_run.html_url }}
VERSION: ${{ steps.version.outputs.VERSION }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
echo "### Run Info" >> "${GITHUB_STEP_SUMMARY}"
echo "Building Version: ${VERSION}" >> "${GITHUB_STEP_SUMMARY}"
echo "" >> "${GITHUB_STEP_SUMMARY}"
echo "Branch: ${BRANCH}" >> "${GITHUB_STEP_SUMMARY}"
echo "" >> "${GITHUB_STEP_SUMMARY}"
echo "Called by [${WORKFLOW_RUN_DISPLAY_TITLE} (${WORKFLOW_RUN_NAME} #${WORKFLOW_RUN_NUMBER})](${WORKFLOW_RUN_HTML_URL})" >> "${GITHUB_STEP_SUMMARY}"
echo "" >> "${GITHUB_STEP_SUMMARY}"
create-signed-update-site:
needs: check-version
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
- name: Set up JDK 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 #v5.2.0
with:
distribution: temurin
java-version: '21'
gpg-private-key: ${{ secrets.PMD_CI_GPG_PRIVATE_KEY }}
- name: Cache local Maven repository
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 #v5.0.3
with:
path: |
~/.m2/repository
net.sourceforge.pmd.eclipse.plugin/japicmp-data
# re-cache on changes in the pom and target files
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', '**/*.target') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build
env:
MAVEN_GPG_PASSPHRASE: ${{ secrets.PMD_CI_GPG_PASSPHRASE }}
run: |
./mvnw --show-version --errors --batch-mode \
verify \
-Psign -DskipTests
- name: Upload update-site
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
with:
name: update-site
path: net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-*.zip
deploy-to-sourceforge-files:
needs: [check-version, create-signed-update-site]
# use environment sourceforge, where secrets/vars are configured for PMD_WEB_SOURCEFORGE_NET_DEPLOY_KEY
# and PMD_WEB_SOURCEFORGE_NET_KNOWN_HOSTS
environment:
name: sourceforge
url: https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
shell: bash
steps:
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 #v8.0.0
with:
name: update-site
- name: Setup ssh key for sourceforge
env:
WEB_SF_DEPLOY_KEY: ${{ secrets.PMD_WEB_SOURCEFORGE_NET_DEPLOY_KEY }}
WEB_SF_KNOWN_HOSTS: ${{ vars.PMD_WEB_SOURCEFORGE_NET_KNOWN_HOSTS }}
run: |
mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
printenv WEB_SF_DEPLOY_KEY > "${HOME}/.ssh/web.sourceforge.net_deploy_key"
chmod 600 "${HOME}/.ssh/web.sourceforge.net_deploy_key"
echo "
Host web.sourceforge.net
IdentityFile=$HOME/.ssh/web.sourceforge.net_deploy_key
" > "$HOME/.ssh/config"
echo "${WEB_SF_KNOWN_HOSTS}" > "$HOME/.ssh/known_hosts"
- name: Upload to sourceforge
id: upload
env:
VERSION: ${{ needs.check-version.outputs.VERSION }}
PMD_SF_USER: adangel
run: |
uploadUrl="${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd-eclipse/zipped/"
rsync -avh \
net.sourceforge.pmd.eclipse.p2updatesite-*.zip \
"${uploadUrl}/net.sourceforge.pmd.eclipse.p2updatesite-SNAPSHOT.zip"
- name: Cleanup ssh
if: ${{ always() }}
run: |
rm -rf "${HOME}/.ssh"
deploy-to-pmd-eclipse-plugin-p2-site:
needs: [check-version, create-signed-update-site]
environment:
name: github-pages
url: https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/
runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
shell: bash
steps:
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 #v8.0.0
with:
name: update-site
- uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf #v2.2.1
id: pmd-actions-helper-app-token
with:
app-id: ${{ secrets.PMD_ACTIONS_HELPER_ID }}
private-key: ${{ secrets.PMD_ACTIONS_HELPER_PRIVATE_KEY }}
owner: pmd
repositories: pmd-eclipse-plugin-p2-site
permission-contents: write
- name: Prepare Local P2 Repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
repository: pmd/pmd-eclipse-plugin-p2-site
ref: gh-pages
path: current-p2-site
token: ${{ steps.pmd-actions-helper-app-token.outputs.token }}
- name: Update Local P2 Repository
env:
VERSION: ${{ needs.check-version.outputs.VERSION }}
run: |
cd current-p2-site
# https://api.github.com/users/pmd-actions-helper[bot]
git config user.name "pmd-actions-helper[bot]"
git config user.email "207160486+pmd-actions-helper[bot]@users.noreply.github.com"
qualifiedVersion="$(basename ../net.sourceforge.pmd.eclipse.p2updatesite-*.zip)"
qualifiedVersion="${qualifiedVersion%.zip}"
qualifiedVersion="${qualifiedVersion#net.sourceforge.pmd.eclipse.p2updatesite-}"
rm -rf snapshot
unzip -q -d snapshot ../net.sourceforge.pmd.eclipse.p2updatesite-*.zip
echo "This is a Eclipse Update Site for the [PMD Eclipse Plugin](https://github.com/pmd/pmd-eclipse-plugin/) ${VERSION}.
Use <https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/> to install the plugin with the Eclipse Update Manager.
<dl>
<dt>Feature ID</dt>
<dd>net.sourceforge.pmd.eclipse</dd>
<dt>Version</dt>
<dd>${qualifiedVersion}</dd>
</dl>
" > snapshot/index.md
git add snapshot
# create a new single commit
git checkout --orphan=gh-pages-2
git commit -a -m "Update pmd/pmd-eclipse-plugin-p2-site"
git push --force origin gh-pages-2:gh-pages