@@ -413,3 +413,93 @@ jobs:
413
413
name : deb-package-signed
414
414
path : ${{ env.ARTIFACTS_DIR }}/signed
415
415
# End build & sign Ubuntu package
416
+
417
+ create-github-release :
418
+ runs-on : ubuntu-latest
419
+ needs : [prereqs, windows_artifacts, mac_artifacts, ubuntu_sign-artifacts]
420
+ if : |
421
+ success() ||
422
+ (needs.ubuntu_sign-artifacts.result == 'skipped' &&
423
+ needs.mac_artifacts.result == 'success' &&
424
+ needs.windows_artifacts.result == 'success')
425
+ steps :
426
+ - name : Download Windows portable installer
427
+ uses : actions/download-artifact@v2
428
+ with :
429
+ name : win-portable-x86_64
430
+ path : win-portable-x86_64
431
+ - name : Download Windows x86_64 installer
432
+ uses : actions/download-artifact@v2
433
+ with :
434
+ name : win-installer-x86_64
435
+ path : win-installer-x86_64
436
+ - name : Download Mac installer
437
+ uses : actions/download-artifact@v2
438
+ with :
439
+ name : osx-installer
440
+ path : osx-installer
441
+ - name : Download Ubuntu package (signed)
442
+ if : needs.prereqs.outputs.deb_signable == 'true'
443
+ uses : actions/download-artifact@v2
444
+ with :
445
+ name : deb-package-signed
446
+ path : deb-package
447
+ - name : Download Ubuntu package (unsigned)
448
+ if : needs.prereqs.outputs.deb_signable != 'true'
449
+ uses : actions/download-artifact@v2
450
+ with :
451
+ name : deb-package-unsigned
452
+ path : deb-package
453
+ - uses : actions/github-script@v4
454
+ with :
455
+ script : |
456
+ const fs = require('fs');
457
+ const path = require('path');
458
+
459
+ var releaseMetadata = {
460
+ owner: context.repo.owner,
461
+ repo: context.repo.repo
462
+ };
463
+
464
+ // Create the release
465
+ var tagName = "${{ needs.prereqs.outputs.tag_name }}";
466
+ var createdRelease = await github.repos.createRelease({
467
+ ...releaseMetadata,
468
+ draft: true,
469
+ tag_name: tagName,
470
+ name: tagName
471
+ });
472
+ releaseMetadata.release_id = createdRelease.data.id;
473
+
474
+ // Uploads contents of directory to the release created above
475
+ async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
476
+ return fs.promises.readdir(directory)
477
+ .then(async(files) => Promise.all(
478
+ files.filter(file => {
479
+ return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
480
+ })
481
+ .map(async (file) => {
482
+ var filePath = path.join(directory, file);
483
+ github.repos.uploadReleaseAsset({
484
+ ...releaseMetadata,
485
+ name: file,
486
+ headers: {
487
+ "content-length": (await fs.promises.stat(filePath)).size
488
+ },
489
+ data: fs.createReadStream(filePath)
490
+ });
491
+ }))
492
+ );
493
+ }
494
+
495
+ await Promise.all([
496
+ // Upload Windows artifacts
497
+ uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
498
+ uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
499
+
500
+ // Upload Mac artifacts
501
+ uploadDirectoryToRelease('osx-installer'),
502
+
503
+ // Upload Ubuntu artifacts
504
+ uploadDirectoryToRelease('deb-package')
505
+ ]);
0 commit comments