Skip to content

Commit c2233ce

Browse files
vdyeldennington
authored andcommitted
release: create draft GitHub release with packages & installers
- create release & uploads artifact using Octokit - use job "if" condition to handle uploading signed *or* unsigned .deb Co-authored-by: Lessley Dennington <ldennington@github.com>
1 parent 5180fdc commit c2233ce

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

.github/workflows/build-git-installers.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,3 +599,112 @@ jobs:
599599
path: |
600600
*.deb
601601
# End build and sign Debian package
602+
603+
create-github-release:
604+
runs-on: ubuntu-latest
605+
permissions:
606+
contents: write
607+
needs:
608+
- create-linux-artifacts
609+
- create-macos-artifacts
610+
- windows_artifacts
611+
- prereqs
612+
if: |
613+
success() ||
614+
(needs.create-linux-artifacts.result == 'skipped' &&
615+
needs.create-macos-artifacts.result == 'success' &&
616+
needs.windows_artifacts.result == 'success')
617+
steps:
618+
- name: Download Windows portable (x86_64)
619+
uses: actions/download-artifact@v4
620+
with:
621+
name: win-portable-x86_64
622+
path: win-portable-x86_64
623+
624+
- name: Download Windows portable (aarch64)
625+
uses: actions/download-artifact@v4
626+
with:
627+
name: win-portable-aarch64
628+
path: win-portable-aarch64
629+
630+
- name: Download Windows installer (x86_64)
631+
uses: actions/download-artifact@v4
632+
with:
633+
name: win-installer-x86_64
634+
path: win-installer-x86_64
635+
636+
- name: Download Windows installer (aarch64)
637+
uses: actions/download-artifact@v4
638+
with:
639+
name: win-installer-aarch64
640+
path: win-installer-aarch64
641+
642+
- name: Download macOS artifacts
643+
uses: actions/download-artifact@v4
644+
with:
645+
name: macos-artifacts
646+
path: macos-artifacts
647+
648+
- name: Download Debian package
649+
uses: actions/download-artifact@v4
650+
with:
651+
name: linux-artifacts
652+
path: deb-package
653+
654+
- uses: actions/github-script@v6
655+
with:
656+
script: |
657+
const fs = require('fs');
658+
const path = require('path');
659+
660+
var releaseMetadata = {
661+
owner: context.repo.owner,
662+
repo: context.repo.repo
663+
};
664+
665+
// Create the release
666+
var tagName = "${{ needs.prereqs.outputs.tag_name }}";
667+
var createdRelease = await github.rest.repos.createRelease({
668+
...releaseMetadata,
669+
draft: true,
670+
tag_name: tagName,
671+
name: tagName
672+
});
673+
releaseMetadata.release_id = createdRelease.data.id;
674+
675+
// Uploads contents of directory to the release created above
676+
async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
677+
return fs.promises.readdir(directory)
678+
.then(async(files) => Promise.all(
679+
files.filter(file => {
680+
return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
681+
})
682+
.map(async (file) => {
683+
var filePath = path.join(directory, file);
684+
github.rest.repos.uploadReleaseAsset({
685+
...releaseMetadata,
686+
name: file,
687+
headers: {
688+
"content-length": (await fs.promises.stat(filePath)).size
689+
},
690+
data: fs.createReadStream(filePath)
691+
});
692+
}))
693+
);
694+
}
695+
696+
await Promise.all([
697+
// Upload Windows x86_64 artifacts
698+
uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
699+
uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
700+
701+
// Upload Windows aarch64 artifacts
702+
uploadDirectoryToRelease('win-installer-aarch64', ['.exe']),
703+
uploadDirectoryToRelease('win-portable-aarch64', ['.exe']),
704+
705+
// Upload Mac artifacts
706+
uploadDirectoryToRelease('macos-artifacts'),
707+
708+
// Upload Ubuntu artifacts
709+
uploadDirectoryToRelease('deb-package')
710+
]);

0 commit comments

Comments
 (0)