Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
533 lines (500 loc) · 24.5 KB
/
Copy pathaction.yml
File metadata and controls
533 lines (500 loc) · 24.5 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
name: 'Publish Native Installers'
description: Publish jDeploy Bundles on Github or npm
author: shannah
branding:
icon: archive
color: blue
inputs:
deploy_target:
description: Target deployment destination (npm or github).
# Options are github or npm
default: github
github_token:
description: Github token
required: false
npm_token:
description: npm token
required: false
jdeploy_version:
description: The version of Jdeploy
default: '6.1.12'
jdeploy_registry_url:
description: The URL of the jDeploy application registry
required: false
default: 'https://www.jdeploy.com/'
target_repository:
description: Optional target repository where to publish releases.
required: false
default: ${{ github.repository }}
require_existing_jdeploy_tag:
description: |
Fail if jdeploy tag doesn't exist (strict mode for established projects).
Set to 'true' for projects that should always have a jdeploy tag.
This prevents accidental data loss by ensuring package-info.json exists before updating.
required: false
default: 'false'
win_signing_certificate:
description: Base64-encoded PFX/PKCS12 certificate for Windows Authenticode signing.
required: false
win_signing_password:
description: Password/PIN for the Windows signing keystore or PKCS#11 token.
required: false
win_signing_keystore_type:
description: 'Keystore type: PKCS12 (default), JKS, or PKCS11.'
required: false
win_signing_pkcs11_config:
description: Path to the PKCS#11 provider configuration file (for HSM signing).
required: false
win_signing_key_alias:
description: Alias of the signing key within the keystore. Defaults to first alias.
required: false
win_signing_key_password:
description: Password for the private key (if different from keystore password).
required: false
win_signing_timestamp_url:
description: RFC 3161 timestamp server URL.
required: false
win_signing_hash_algorithm:
description: Hash algorithm for the signature (e.g. SHA-256).
required: false
win_signing_description:
description: Description embedded in the Authenticode signature.
required: false
win_signing_url:
description: URL embedded in the Authenticode signature.
required: false
runs:
using: composite
steps:
- name: Validate Branch/Tag Name
shell: bash
run: |
REF_NAME="${{ github.ref_name }}"
# Check if ref name contains only allowed characters (letters, digits, dash, underscore, dot)
if [[ ! "$REF_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
echo "Branch/tag name '$REF_NAME' contains illegal characters. Only letters, digits, dash (-), underscore (_), and dot (.) are allowed."
echo "Skipping action execution due to invalid ref name."
echo "JDEPLOY_SKIP_EXECUTION=true" >> $GITHUB_ENV
exit 0
fi
# Check if ref name length exceeds 16 characters
if [[ ${#REF_NAME} -gt 16 ]]; then
echo "Branch/tag name '$REF_NAME' is too long (${#REF_NAME} characters). Maximum allowed length is 16 characters."
echo "Skipping action execution due to ref name length limit."
echo "JDEPLOY_SKIP_EXECUTION=true" >> $GITHUB_ENV
exit 0
fi
echo "Branch/tag name '$REF_NAME' is valid."
echo "JDEPLOY_SKIP_EXECUTION=false" >> $GITHUB_ENV
- name: Check Deploy Target
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target != 'github' && inputs.deploy_target != 'npm' }}
shell: bash
run: |
echo "Unsupported jdeploy deploy_target: ${{ inputs.deploy_target }}"
exit 1
- name: Check Github Deployment Inputs
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && inputs.github_token == '' }}
shell: bash
run: |
echo "jdeploy action missing github_token parameter"
exit 1
- name: Check npm Deployment Inputs
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'npm' && inputs.npm_token == '' }}
shell: bash
run: |
echo "jdeploy action missing npm_token parameter"
exit 1
- name: Set up Git Config
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' }}
shell: bash
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Set up Node
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' }}
uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Upgrade npm for trusted publishing
# Only needed for npm trusted publishing (OIDC provenance); GitHub
# releases don't use it. Pin the major version rather than tracking
# npm@latest so a new npm release with a higher Node engine requirement
# can't break this step without a Node bump here.
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'npm' }}
run: npm install -g npm@11
shell: bash
- name: Setup jDeploy Registry
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' }}
shell: bash
run: |
echo "JDEPLOY_REGISTRY_URL=${{ inputs.jdeploy_registry_url }}" >> $GITHUB_ENV
- name: Set Up Windows Authenticode Signing
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && (inputs.win_signing_certificate != '' || inputs.win_signing_pkcs11_config != '') }}
shell: bash
run: |
if [ -n "${{ inputs.win_signing_certificate }}" ]; then
CERT_PATH="${{ runner.temp }}/jdeploy-win-certificate.pfx"
echo "${{ inputs.win_signing_certificate }}" | base64 -d > "$CERT_PATH"
echo "JDEPLOY_WIN_KEYSTORE_PATH=$CERT_PATH" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_keystore_type }}" ]; then
echo "JDEPLOY_WIN_KEYSTORE_TYPE=${{ inputs.win_signing_keystore_type }}" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_pkcs11_config }}" ]; then
echo "JDEPLOY_WIN_PKCS11_CONFIG=${{ inputs.win_signing_pkcs11_config }}" >> $GITHUB_ENV
fi
echo "JDEPLOY_WIN_KEYSTORE_PASSWORD=${{ inputs.win_signing_password }}" >> $GITHUB_ENV
if [ -n "${{ inputs.win_signing_key_alias }}" ]; then
echo "JDEPLOY_WIN_KEY_ALIAS=${{ inputs.win_signing_key_alias }}" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_key_password }}" ]; then
echo "JDEPLOY_WIN_KEY_PASSWORD=${{ inputs.win_signing_key_password }}" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_timestamp_url }}" ]; then
echo "JDEPLOY_WIN_TIMESTAMP_URL=${{ inputs.win_signing_timestamp_url }}" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_hash_algorithm }}" ]; then
echo "JDEPLOY_WIN_HASH_ALGORITHM=${{ inputs.win_signing_hash_algorithm }}" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_description }}" ]; then
echo "JDEPLOY_WIN_SIGN_DESCRIPTION=${{ inputs.win_signing_description }}" >> $GITHUB_ENV
fi
if [ -n "${{ inputs.win_signing_url }}" ]; then
echo "JDEPLOY_WIN_SIGN_URL=${{ inputs.win_signing_url }}" >> $GITHUB_ENV
fi
echo "Windows Authenticode signing configured."
- name: Save Original JAVA_HOME
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && env.JAVA_HOME }}
shell: bash
run: |
echo "ORIGINAL_JAVA_HOME=${JAVA_HOME}" >> $GITHUB_ENV
- name: Set up Isolated Java for jDeploy (only for git:// version)
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'zulu'
cache: maven
id: setup-java-jdeploy
- name: Configure Java for jDeploy Only
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
shell: bash
run: |
echo "JAVA_HOME_JDEPLOY=${{ steps.setup-java-jdeploy.outputs.path }}" >> $GITHUB_ENV
echo "Using isolated JAVA_HOME for jDeploy: $JAVA_HOME_JDEPLOY"
- name: Restore Original JAVA_HOME
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') && env.ORIGINAL_JAVA_HOME }}
shell: bash
run: |
echo "Restoring original JAVA_HOME"
echo "JAVA_HOME=${ORIGINAL_JAVA_HOME}" >> $GITHUB_ENV
- name: Set jDeploy Ref
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
shell: bash
run: |
jdeploy_version="${{ inputs.jdeploy_version }}"
JDEPLOY_REF="${jdeploy_version#git://}"
echo "JDEPLOY_REF=$JDEPLOY_REF" >> $GITHUB_ENV
- name: Checkout jDeploy Source
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
uses: actions/checkout@v3
with:
repository: 'shannah/jdeploy'
path: './jdeploy-source'
ref: '${{ env.JDEPLOY_REF }}'
- name: Install jDeploy from Source
id: jdeploy_install_source
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && startsWith(inputs.jdeploy_version, 'git://') }}
shell: bash
run: |
export JAVA_HOME="$JAVA_HOME_JDEPLOY"
export PATH="$JAVA_HOME/bin:$PATH"
echo "Building jDeploy from source..."
cd jdeploy-source/shared
mvn clean install -DskipTests --batch-mode --no-transfer-progress
cd ../cli
mvn clean package -DskipTests --batch-mode --no-transfer-progress
npm install
npm link
echo "jdeploy_exec=$(which jdeploy)" >> $GITHUB_ENV
env:
MAVEN_OPTS: "-Xmx2g"
- name: Install jDeploy from NPM
id: jdeploy_install_standard
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && !startsWith(inputs.jdeploy_version, 'git://') }}
shell: bash
run: |
echo "jdeploy_exec=npx jdeploy@${JDEPLOY_VERSION}" >> $GITHUB_ENV
env:
JDEPLOY_VERSION: ${{ inputs.jdeploy_version }}
- name: Set jdeploy.jdeployVersion for Branch
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
shell: bash
run: |
if [[ "${{ startsWith(inputs.jdeploy_version, 'git://') }}" == "true" ]]; then
npm pkg set jdeploy.jdeployVersion='latest'
else
npm pkg set jdeploy.jdeployVersion='${{ inputs.jdeploy_version }}'
fi
npm pkg set version="0.0.0-${{ github.ref_name }}"
npm pkg set jdeploy.commitHash="$GITHUB_SHA"
GITHUB_REPOSITORY=${{ inputs.target_repository }} $jdeploy_exec github-prepare-release
env:
GH_TOKEN: ${{ github.actor }}:${{ inputs.github_token }}
- name: Sanitize version name
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && github.ref_type == 'tag' }}
shell: bash
run: |
TAG_VERSION=${{ github.ref_name }}
if [[ $TAG_VERSION} = v* ]]; then
echo "TAG_VERSION=${TAG_VERSION:1}" >> $GITHUB_ENV
else
echo "TAG_VERSION=${TAG_VERSION}" >> $GITHUB_ENV
fi
- name: Prepare Installer Bundles for Branch
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' }}
shell: bash
run: |
npm pkg set version="0.0.0-${{ github.ref_name }}"
if [[ "${{ startsWith(inputs.jdeploy_version, 'git://') }}" == "true" ]]; then
npm pkg set jdeploy.jdeployVersion='latest'
else
npm pkg set jdeploy.jdeployVersion='${{ inputs.jdeploy_version }}'
fi
npm pkg set jdeploy.commitHash="$GITHUB_SHA"
GITHUB_REPOSITORY=${{ inputs.target_repository }} $jdeploy_exec github-prepare-release
env:
GH_TOKEN: ${{ github.actor }}:${{ inputs.github_token }}
JDEPLOY_REQUIRE_EXISTING_TAG: ${{ inputs.require_existing_jdeploy_tag }}
- name: Prepare Installer Bundles for Tag
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' }}
shell: bash
run: |
npm pkg set version="$TAG_VERSION"
if [[ "${{ startsWith(inputs.jdeploy_version, 'git://') }}" == "true" ]]; then
npm pkg set jdeploy.jdeployVersion='latest'
else
npm pkg set jdeploy.jdeployVersion='${{ inputs.jdeploy_version }}'
fi
npm pkg set jdeploy.commitHash="$GITHUB_SHA"
npm pkg set jdeploy.gitTag="${{ github.ref_name }}"
GITHUB_REPOSITORY=${{ inputs.target_repository }} $jdeploy_exec github-prepare-release
env:
GH_TOKEN: ${{ github.actor }}:${{ inputs.github_token }}
JDEPLOY_REQUIRE_EXISTING_TAG: ${{ inputs.require_existing_jdeploy_tag }}
- name: Download Baseline package-info.json from jdeploy Tag
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' }}
shell: bash
run: |
chmod +x "${{ github.action_path }}/.github/scripts/download-jdeploy-baseline.sh"
"${{ github.action_path }}/.github/scripts/download-jdeploy-baseline.sh" \
"${{ inputs.target_repository }}" \
"${{ inputs.github_token }}"
- name: Publish package-info.json to jdeploy Tag
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' }}
shell: bash
run: |
chmod +x "${{ github.action_path }}/.github/scripts/upload-jdeploy-package-info.sh"
"${{ github.action_path }}/.github/scripts/upload-jdeploy-package-info.sh" \
"${{ inputs.target_repository }}" \
"${{ inputs.github_token }}" \
"./jdeploy/github-release-files"
- name: Upload files to GitHub Snapshot Release for Branch
uses: softprops/action-gh-release@v2
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' && inputs.target_repository == github.repository }}
with:
tag_name: "${{ github.ref_name }}"
token: "${{ inputs.github_token }}"
prerelease: true
files: |
./jdeploy/github-release-files/*
- name: Upload files to Github Release in Target Repository
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && inputs.target_repository != github.repository }}
shell: bash
run: |
set -e
# Branch builds are snapshots of a moving branch, so they must not be
# promoted to "Latest" in the target repository. Only tag builds are.
PRERELEASE_FLAG=()
if [[ "${{ github.ref_type }}" == "branch" ]]; then
PRERELEASE_FLAG=(--prerelease)
fi
gh release delete -R '${{ inputs.target_repository }}' '${{ github.ref_name }}' || true
gh release create -R '${{ inputs.target_repository }}' '${{ github.ref_name }}' "${PRERELEASE_FLAG[@]}" -F ./jdeploy/github-release-files/jdeploy-release-notes.md ./jdeploy/github-release-files/*
env:
GH_TOKEN: ${{ inputs.github_token }}
# For versioned (tag) releases we already have a release in the repository
# running the workflow, so give it a copy of the installers as well. Only the
# installers: the rest of the release files (platform bundles, package-info.json,
# icons, etc..) stay in the target repository, which is the publication channel.
- name: Upload Installers to Github Release for Tag in Current Repository
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository != github.repository }}
shell: bash
env:
# Writing to this repository's own release uses the workflow's own token.
# inputs.github_token is the credential for the target repository, which here
# is a different repository and generally cannot write here - the API answers
# an unauthorized write with 404 rather than 403, so this shows up as a
# confusing "Not Found" on the releases endpoint.
GH_TOKEN: ${{ github.token }}
run: |
set -e
# The installers are exactly the files github-prepare-release put in
# jdeploy/installers, which it copies into the release files with spaces
# replaced by dots. Deriving the list from that directory keeps this step
# working with every jdeploy version, rather than depending on a CLI
# subcommand that only newer releases have.
INSTALLERS=()
if [ -d ./jdeploy/installers ]; then
for installer in ./jdeploy/installers/*; do
[ -f "$installer" ] || continue
name=$(basename "$installer")
releaseFile="./jdeploy/github-release-files/${name// /.}"
if [ ! -f "$releaseFile" ]; then
releaseFile="./jdeploy/github-release-files/${name}"
fi
if [ -f "$releaseFile" ]; then
INSTALLERS+=("$releaseFile")
else
echo "Warning: no release file found for installer $name"
fi
done
fi
if [ ${#INSTALLERS[@]} -eq 0 ]; then
echo "No installer artifacts found. Skipping upload to ${{ github.repository }}."
exit 0
fi
echo "Uploading ${#INSTALLERS[@]} installer(s) to ${{ github.repository }} release ${{ github.ref_name }}"
# A tag build runs against a release that already exists here, so this only
# ever adds assets to it - it never creates one. The installers are already
# published to the target repository, which is the distribution channel, so
# anything that stops the copy is reported but does not fail the release.
if ! gh release view -R '${{ github.repository }}' '${{ github.ref_name }}' > /dev/null 2>&1; then
echo "::warning::No release for ${{ github.ref_name }} in ${{ github.repository }} (or no permission to read it), so the installers were published only to ${{ inputs.target_repository }}. This step reads and writes this repository's own release, so the calling workflow needs 'contents: write' permission."
exit 0
fi
if ! gh release upload -R '${{ github.repository }}' '${{ github.ref_name }}' --clobber "${INSTALLERS[@]}"; then
echo "::warning::Could not upload the installers to ${{ github.repository }}, so they were published only to ${{ inputs.target_repository }}. The calling workflow needs 'contents: write' permission."
exit 0
fi
- name: Update release body for Tag in Current Repository
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository != github.repository }}
shell: bash
env:
# This repository's own release, so the workflow's own token - see above.
GITHUB_TOKEN: ${{ github.token }}
run: |
set -e
# Point the installer download links at this repository, since that is where
# the installers were just uploaded. The CLI installation links keep pointing
# at the target repository, which hosts the package metadata - they are
# jdeploy.com/gh/<repo> URLs, so this rewrite does not touch them. The
# substitution is a literal bash replacement rather than a regex, so a
# repository name containing a dot cannot match the wrong text.
NOTES=$(cat ./jdeploy/github-release-files/jdeploy-release-notes.md)
DOWNLOAD_PREFIX_FROM="https://github.com/${{ inputs.target_repository }}/releases/download/"
DOWNLOAD_PREFIX_TO="https://github.com/${{ github.repository }}/releases/download/"
BODY="${NOTES//"$DOWNLOAD_PREFIX_FROM"/"$DOWNLOAD_PREFIX_TO"}"
RELEASE_RESULT=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }})
RELEASE_ID=$( jq -r '.id // empty' <<< "${RELEASE_RESULT}" )
if [ -z "$RELEASE_ID" ]; then
echo "::warning::No release found for ${{ github.ref_name }} in ${{ github.repository }}, so its release notes were left unchanged."
exit 0
fi
OLD_BODY=$( jq -r '.body // ""' <<< "${RELEASE_RESULT}" )
NEW_BODY=$(GITHUB_RELEASE_BODY="$OLD_BODY" JDEPLOY_RELEASE_NOTES="$BODY" $jdeploy_exec github-build-release-body)
BODY_JSON="{\"body\": $(echo "$NEW_BODY" | jq -sR .)}"
echo "Release ID is ${RELEASE_ID}"
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID} \
-d "$BODY_JSON"
- name: Upload Files to Github Release for Tag
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository == github.repository }}
uses: xresloader/upload-to-github-release@v1.6.0
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
with:
file: "./jdeploy/github-release-files/*"
tags: true
overwrite: true
- name: Update release body (for branch release)
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'branch' && inputs.target_repository == github.repository }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
set -e
BODY=$(cat ./jdeploy/github-release-files/jdeploy-release-notes.md)
BODY_JSON="{\"body\": $(echo "$BODY" | jq -sR .)}"
RELEASE_RESULT=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${GITHUB_REF_NAME})
RELEASE_ID=$( jq -r '.id' <<< "${RELEASE_RESULT}" )
echo "Release ID is ${RELEASE_ID}"
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID} \
-d "$BODY_JSON"
- name: Update release body (for tag release)
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'github' && github.ref_type == 'tag' && inputs.target_repository == github.repository }}
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
set -e
BODY=$(cat ./jdeploy/github-release-files/jdeploy-release-notes.md)
RELEASE_RESULT=$(curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${GITHUB_REF_NAME})
RELEASE_ID=$( jq -r '.id' <<< "${RELEASE_RESULT}" )
OLD_BODY=$(jq -r '.body' <<< "${RELEASE_RESULT}" )
NEW_BODY=$(GITHUB_RELEASE_BODY="$OLD_BODY" JDEPLOY_RELEASE_NOTES="$BODY" $jdeploy_exec github-build-release-body)
BODY_JSON="{\"body\": $(echo "$NEW_BODY" | jq -sR .)}"
echo "Release ID is ${RELEASE_ID}"
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID} \
-d "$BODY_JSON"
- name: Publish to npm
if: ${{ env.JDEPLOY_SKIP_EXECUTION != 'true' && inputs.deploy_target == 'npm' && github.ref_type == 'tag' }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.npm_token }}
run: |
npm pkg set version="$TAG_VERSION"
if [[ "${{ startsWith(inputs.jdeploy_version, 'git://') }}" == "true" ]]; then
npm pkg set jdeploy.jdeployVersion='latest'
else
npm pkg set jdeploy.jdeployVersion='${{ inputs.jdeploy_version }}'
fi
npm pkg set jdeploy.commitHash="$GITHUB_SHA"
$jdeploy_exec publish
- name: Clean Up Windows Signing Certificate
if: ${{ always() && env.JDEPLOY_WIN_KEYSTORE_PATH != '' }}
shell: bash
run: |
rm -f "$JDEPLOY_WIN_KEYSTORE_PATH"
echo "Cleaned up signing certificate."