|
49 | 49 | type: boolean |
50 | 50 |
|
51 | 51 |
|
52 | | -defaults: |
53 | | - run: |
54 | | - shell: bash |
55 | | - |
56 | | - |
57 | | -env: |
58 | | - JAVA_VERSION: 17 |
59 | | - KEYSTORE_PATH: /tmp/sebthom.github.io.p12 |
60 | | - KEYSTORE_PW: whatever |
61 | | - |
62 | | - |
63 | 52 | jobs: |
64 | | - |
65 | 53 | ########################################################### |
66 | | - maven-build: |
| 54 | + eclipse-plugin-build: |
67 | 55 | ########################################################### |
68 | | - runs-on: ubuntu-latest |
69 | | - |
70 | | - |
71 | | - # https://docs.github.com/en/actions/using-jobs/using-concurrency |
72 | | - concurrency: |
73 | | - group: ${{ github.workflow }}-${{ github.ref }} |
74 | | - cancel-in-progress: false |
75 | | - |
76 | | - |
77 | | - steps: |
78 | | - - name: "Show: GitHub context" |
79 | | - env: |
80 | | - GITHUB_CONTEXT: ${{ toJSON(github) }} |
81 | | - run: echo $GITHUB_CONTEXT |
82 | | - |
83 | | - |
84 | | - - name: "Show: environment variables" |
85 | | - run: env | sort |
86 | | - |
87 | | - |
88 | | - - name: Git Checkout |
89 | | - uses: actions/checkout@v4 # https://github.com/actions/checkout |
90 | | - |
91 | | - |
92 | | - - name: Verify Syntax Registration |
93 | | - run: | |
94 | | - set -euo pipefail |
95 | | -
|
96 | | - pip install ruamel.yaml |
97 | | - python plugin/verify-syntax-registrations.py |
98 | | -
|
99 | | -
|
100 | | - - name: "Install: JDK ${{ env.JAVA_VERSION }} ☕" |
101 | | - uses: actions/setup-java@v4 # https://github.com/actions/setup-java |
102 | | - with: |
103 | | - distribution: temurin |
104 | | - java-version: ${{ env.JAVA_VERSION }} |
105 | | - |
106 | | - |
107 | | - - name: "Cache: Restore" |
108 | | - id: cache-restore |
109 | | - if: ${{ !env.ACT }} # https://github.com/nektos/act#skipping-steps |
110 | | - uses: actions/cache/restore@v4 |
111 | | - with: |
112 | | - path: | |
113 | | - ~/.m2/repository |
114 | | - !~/.m2/repository/.cache/tycho/https/raw.githubusercontent.com |
115 | | - !~/.m2/repository/*SNAPSHOT* |
116 | | - key: ${{ runner.os }}-${{ hashFiles('build.target') }}-${{ hashFiles('**/pom.xml') }} |
117 | | - |
118 | | - |
119 | | - - name: Get Signing Certificate |
120 | | - if: ${{ github.ref_name == 'main' && !env.ACT }} |
121 | | - env: |
122 | | - CERTDB: ${{ secrets.CERTDB }} # populated by https://github.com/sebthom/sebthom.github.io/actions/workflows/renew-cert.yml |
123 | | - run: | |
124 | | - echo "$CERTDB" | base64 --decode | tar xvz -C /tmp |
125 | | - (set -x; openssl pkcs12 -export \ |
126 | | - -inkey /tmp/etc/letsencrypt/live/sebthom.github.io/privkey.pem \ |
127 | | - -in /tmp/etc/letsencrypt/live/sebthom.github.io/fullchain.pem \ |
128 | | - -name sebthom.github.io \ |
129 | | - -password env:KEYSTORE_PW \ |
130 | | - -out $KEYSTORE_PATH) |
131 | | -
|
132 | | - (set -x; keytool -keypass:env KEYSTORE_PW -storepass:env KEYSTORE_PW -list -keystore $KEYSTORE_PATH) |
133 | | -
|
134 | | -
|
135 | | - - name: "Install: Maven" |
136 | | - uses: stCarolas/setup-maven@v5 # https://github.com/stCarolas/setup-maven |
137 | | - with: |
138 | | - maven-version: 3.9.9 |
139 | | - |
| 56 | + uses: sebthom/gha-shared/.github/workflows/reusable.eclipse-plugin-build.yml@v1 |
| 57 | + with: |
| 58 | + timeout-minutes: 10 |
140 | 59 |
|
141 | | - - name: "Build with Maven 🔨" |
142 | | - env: |
143 | | - GITHUB_USER: ${{ github.actor }} |
144 | | - GITHUB_API_KEY: ${{ github.token }} |
145 | | - run: | |
146 | | - set -eu |
| 60 | + target-files: build.target |
147 | 61 |
|
148 | | - # https://github.community/t/github-actions-bot-email-address/17204 |
149 | | - git config user.name "github-actions[bot]" |
150 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 62 | + extra-maven-args: ${{ inputs.extra-maven-args }} |
| 63 | + jarsigner-alias: sebthom.github.io |
151 | 64 |
|
152 | | - MAVEN_OPTS="${MAVEN_OPTS:-}" |
153 | | - MAVEN_OPTS+=" -Djava.security.egd=file:/dev/./urandom" # https://stackoverflow.com/questions/58991966/what-java-security-egd-option-is-for/59097932#59097932 |
154 | | - MAVEN_OPTS+=" -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS" # https://stackoverflow.com/questions/5120470/how-to-time-the-different-stages-of-maven-execution/49494561#49494561 |
155 | | - MAVEN_OPTS+=" -Xmx1024m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dhttps.protocols=TLSv1.3,TLSv1.2" |
156 | | - export MAVEN_OPTS |
157 | | - echo "MAVEN_OPTS: $MAVEN_OPTS" |
| 65 | + development-branch: none |
| 66 | + development-updatesite-branch: updatesite-preview |
| 67 | + release-branch: main |
| 68 | + release-updatesite-branch: updatesite |
| 69 | + release-archive-name: de.sebthom.eclipse.extra_syntax_highlighting.updatesite.zip |
158 | 70 |
|
159 | | - mvn \ |
160 | | - --errors \ |
161 | | - --update-snapshots \ |
162 | | - --batch-mode \ |
163 | | - --show-version \ |
164 | | - --no-transfer-progress \ |
165 | | - -s .ci/maven-settings.xml \ |
166 | | - -t .ci/maven-toolchains.xml \ |
167 | | - -Dtycho.disableP2Mirrors=true \ |
168 | | - $([[ -f $KEYSTORE_PATH ]] && echo "-Djarsigner.keystore.path=$KEYSTORE_PATH -Djarsigner.keystore.password=$KEYSTORE_PW" || true) \ |
169 | | - ${{ github.event.inputs.additional_maven_args }} \ |
170 | | - clean verify |
| 71 | + debug-with-ssh: ${{ inputs.debug-with-ssh }} |
| 72 | + debug-with-ssh-only-for-actor: ${{ inputs.debug-with-ssh-only-for-actor }} |
171 | 73 |
|
172 | | - mv updatesite/target/de.sebthom.eclipse.extra_syntax_highlighting.updatesite-*.zip updatesite/target/de.sebthom.eclipse.extra_syntax_highlighting.updatesite.zip |
173 | | -
|
174 | | -
|
175 | | - - name: "Delete previous 'latest' release" |
176 | | - if: ${{ github.ref_name == 'main' && !env.ACT }} |
177 | | - env: |
178 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
179 | | - RELEASE_NAME: latest |
180 | | - # https://cli.github.com/manual/gh_release_delete |
181 | | - run: | |
182 | | - GH_DEBUG=1 gh release delete "$RELEASE_NAME" --yes --cleanup-tag || true |
183 | | -
|
184 | | -
|
185 | | - - name: "Create 'latest' release" |
186 | | - if: ${{ github.ref_name == 'main' && !env.ACT }} |
187 | | - env: |
188 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
189 | | - RELEASE_NAME: latest |
190 | | - # https://cli.github.com/manual/gh_release_create |
191 | | - run: | |
192 | | - GH_DEBUG=1 gh release create "$RELEASE_NAME" \ |
193 | | - --title "$RELEASE_NAME" \ |
194 | | - --latest \ |
195 | | - --notes "${{ github.event.head_commit.message }}" \ |
196 | | - --target "${{ github.sha }}" \ |
197 | | - updatesite/target/de.sebthom.eclipse.extra_syntax_highlighting.updatesite.zip |
198 | | -
|
199 | | -
|
200 | | - - name: Deploy p2 update site |
201 | | - if: ${{ github.ref_name == 'main' && !env.ACT }} |
202 | | - run: | |
203 | | - set -eux |
204 | | -
|
205 | | - last_commit_message=$(git log --pretty=format:"%s (%h)" -1) |
206 | | -
|
207 | | - cd /tmp |
208 | | - github_repo_url="https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}" |
209 | | - if curl --output /dev/null --silent --head --fail "$github_repo_url/tree/updatesite"; then |
210 | | - git clone $github_repo_url --single-branch --branch updatesite updatesite |
211 | | - cd updatesite |
212 | | - # https://github.community/t/github-actions-bot-email-address/17204 |
213 | | - git config user.name "github-actions[bot]" |
214 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
215 | | - git reset --hard HEAD^ |
216 | | - else |
217 | | - git clone $github_repo_url updatesite |
218 | | - cd updatesite |
219 | | - git checkout --orphan updatesite |
220 | | - git rm -rf . |
221 | | - cat <<EOF > index.html |
222 | | - <!DOCTYPE html> |
223 | | - <html> |
224 | | - <head> |
225 | | - <title>${{ github.repository }} - Update Site</title> |
226 | | - </head> |
227 | | - <body> |
228 | | - <h1>${{ github.repository }} - Update Site</h1> |
229 | | - </body> |
230 | | - </html> |
231 | | - EOF |
232 | | - git add index.html |
233 | | - # https://github.community/t/github-actions-bot-email-address/17204 |
234 | | - git config user.name "github-actions[bot]" |
235 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
236 | | - git commit -am "Initialize Update Site" |
237 | | - fi |
238 | | -
|
239 | | - mv $GITHUB_WORKSPACE/updatesite/target/repository/* . |
240 | | - git add --all |
241 | | - git commit -am "$last_commit_message" |
242 | | - git push origin updatesite --force |
243 | | -
|
244 | | -
|
245 | | - ################################################## |
246 | | - # Cache Update |
247 | | - # See https://github.com/actions/cache/issues/342 |
248 | | - ################################################## |
249 | | - - name: "Cache: Delete Previous" |
250 | | - if: ${{ steps.cache-restore.outputs.cache-hit && !env.ACT }} |
251 | | - env: |
252 | | - GH_TOKEN: ${{ github.token }} |
253 | | - run: | |
254 | | - gh extension install actions/gh-actions-cache |
255 | | - # "|| true" is to avoid "Error: Resource not accessible by integration" from failing the job |
256 | | - gh actions-cache delete ${{ steps.cache-restore.outputs.cache-primary-key }} --confirm || true |
257 | | -
|
258 | | - - name: "Cache: Update" |
259 | | - uses: actions/cache/save@v4 |
260 | | - if: ${{ always() && !cancelled() && !env.ACT }} # save cache even fails |
261 | | - with: |
262 | | - path: | |
263 | | - ~/.m2/repository |
264 | | - !~/.m2/repository/.cache/tycho/https/raw.githubusercontent.com |
265 | | - !~/.m2/repository/*SNAPSHOT* |
266 | | - key: ${{ steps.cache-restore.outputs.cache-primary-key }} |
267 | | - |
268 | | - |
269 | | - ################################################## |
270 | | - # Setup SSH debug session |
271 | | - ################################################## |
272 | | - - name: "SSH session for debugging: check" |
273 | | - id: DEBUG_SSH_SESSSION_CHECK |
274 | | - if: always() |
275 | | - run: | |
276 | | - set -eu |
277 | | -
|
278 | | - when="${{ inputs.debug-with-ssh }}" |
279 | | -
|
280 | | - if [[ $when == "always" ]] || case "${{ job.status }}" in |
281 | | - success) [[ $when == "always" ]] ;; |
282 | | - cancelled) [[ $when == "on_failure_or_cancelled" ]] ;; |
283 | | - failure) [[ $when == "on_failure"* ]] ;; |
284 | | - esac; then |
285 | | - echo "start_ssh_session=true" | tee -a "$GITHUB_OUTPUT" |
286 | | - fi |
287 | | -
|
288 | | -
|
289 | | - - name: "SSH session for debugging: start" |
290 | | - uses: mxschmitt/action-tmate@v3 # https://github.com/mxschmitt/action-tmate |
291 | | - if: always() && steps.DEBUG_SSH_SESSSION_CHECK.outputs.start_ssh_session |
292 | | - with: |
293 | | - limit-access-to-actor: ${{ inputs.debug-with-ssh-only-for-actor }} |
294 | | - |
295 | | - |
296 | | - ########################################################### |
297 | | - dependabot-pr-auto-merge: |
298 | | - ########################################################### |
299 | | - needs: maven-build |
300 | | - if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }} |
301 | | - runs-on: ubuntu-latest |
302 | | - |
303 | | - concurrency: dependabot-pr-auto-merge |
| 74 | + secrets: |
| 75 | + JARSIGNER_KEYSTORE: ${{ secrets.CERTDB }} # populated by https://github.com/sebthom/sebthom.github.io/actions/workflows/renew-cert.yml |
304 | 76 |
|
305 | 77 | permissions: |
306 | | - contents: write |
307 | | - pull-requests: write |
308 | | - |
309 | | - steps: |
310 | | - - name: Dependabot metadata |
311 | | - id: metadata |
312 | | - uses: dependabot/fetch-metadata@v2 # https://github.com/dependabot/fetch-metadata/ |
313 | | - with: |
314 | | - github-token: "${{ secrets.GITHUB_TOKEN }}" |
315 | | - |
316 | | - |
317 | | - - name: Enable auto-merge for Dependabot PRs |
318 | | - if: | |
319 | | - ${{ |
320 | | - ( |
321 | | - steps.dependabot-metadata.outputs.package-ecosystem == 'github-actions' && |
322 | | - steps.metadata.outputs.update-type == 'version-update:semver-major' |
323 | | - ) || ( |
324 | | - steps.dependabot-metadata.outputs.package-ecosystem == 'maven' && |
325 | | - steps.metadata.outputs.update-type == 'version-update:semver-minor' |
326 | | - ) |
327 | | - }} |
328 | | - run: | |
329 | | - gh pr merge --auto --rebase "$PR_URL" |
330 | | - env: |
331 | | - PR_URL: ${{github.event.pull_request.html_url}} |
332 | | - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 78 | + actions: write # to delete action cache entries |
| 79 | + contents: write # to create releases (commit to updatesite branches) |
| 80 | + pull-requests: write # for dependabot auto merges |
0 commit comments