@@ -487,3 +487,93 @@ jobs:
487487 name : deb-package-signed
488488 path : ${{ env.ARTIFACTS_DIR }}/signed
489489 # End build & sign Ubuntu package
490+
491+ create-github-release :
492+ runs-on : ubuntu-latest
493+ needs : [prereqs, windows_artifacts, mac_artifacts, ubuntu_sign-artifacts]
494+ if : |
495+ success() ||
496+ (needs.ubuntu_sign-artifacts.result == 'skipped' &&
497+ needs.mac_artifacts.result == 'success' &&
498+ needs.windows_artifacts.result == 'success')
499+ steps :
500+ - name : Download Windows portable installer
501+ uses : actions/download-artifact@v2
502+ with :
503+ name : win-portable-x86_64
504+ path : win-portable-x86_64
505+ - name : Download Windows x86_64 installer
506+ uses : actions/download-artifact@v2
507+ with :
508+ name : win-installer-x86_64
509+ path : win-installer-x86_64
510+ - name : Download Mac installer
511+ uses : actions/download-artifact@v2
512+ with :
513+ name : osx-installer
514+ path : osx-installer
515+ - name : Download Ubuntu package (signed)
516+ if : needs.prereqs.outputs.deb_signable == 'true'
517+ uses : actions/download-artifact@v2
518+ with :
519+ name : deb-package-signed
520+ path : deb-package
521+ - name : Download Ubuntu package (unsigned)
522+ if : needs.prereqs.outputs.deb_signable != 'true'
523+ uses : actions/download-artifact@v2
524+ with :
525+ name : deb-package-unsigned
526+ path : deb-package
527+ - uses : actions/github-script@v4
528+ with :
529+ script : |
530+ const fs = require('fs');
531+ const path = require('path');
532+
533+ var releaseMetadata = {
534+ owner: context.repo.owner,
535+ repo: context.repo.repo
536+ };
537+
538+ // Create the release
539+ var tagName = "${{ needs.prereqs.outputs.tag_name }}";
540+ var createdRelease = await github.repos.createRelease({
541+ ...releaseMetadata,
542+ draft: true,
543+ tag_name: tagName,
544+ name: tagName
545+ });
546+ releaseMetadata.release_id = createdRelease.data.id;
547+
548+ // Uploads contents of directory to the release created above
549+ async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
550+ return fs.promises.readdir(directory)
551+ .then(async(files) => Promise.all(
552+ files.filter(file => {
553+ return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
554+ })
555+ .map(async (file) => {
556+ var filePath = path.join(directory, file);
557+ github.repos.uploadReleaseAsset({
558+ ...releaseMetadata,
559+ name: file,
560+ headers: {
561+ "content-length": (await fs.promises.stat(filePath)).size
562+ },
563+ data: fs.createReadStream(filePath)
564+ });
565+ }))
566+ );
567+ }
568+
569+ await Promise.all([
570+ // Upload Windows artifacts
571+ uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
572+ uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
573+
574+ // Upload Mac artifacts
575+ uploadDirectoryToRelease('osx-installer'),
576+
577+ // Upload Ubuntu artifacts
578+ uploadDirectoryToRelease('deb-package')
579+ ]);
0 commit comments