Skip to content

Commit b92f293

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 <[email protected]>
1 parent e1e4390 commit b92f293

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
@@ -698,3 +698,112 @@ jobs:
698698
path: |
699699
*.deb
700700
# End build and sign Debian package
701+
702+
create-github-release:
703+
runs-on: ubuntu-latest
704+
permissions:
705+
contents: write
706+
needs:
707+
- create-linux-artifacts
708+
- create-macos-artifacts
709+
- windows_artifacts
710+
- prereqs
711+
if: |
712+
success() ||
713+
(needs.create-linux-artifacts.result == 'skipped' &&
714+
needs.create-macos-artifacts.result == 'success' &&
715+
needs.windows_artifacts.result == 'success')
716+
steps:
717+
- name: Download Windows portable (x86_64)
718+
uses: actions/download-artifact@v4
719+
with:
720+
name: win-portable-x86_64
721+
path: win-portable-x86_64
722+
723+
- name: Download Windows portable (aarch64)
724+
uses: actions/download-artifact@v4
725+
with:
726+
name: win-portable-aarch64
727+
path: win-portable-aarch64
728+
729+
- name: Download Windows installer (x86_64)
730+
uses: actions/download-artifact@v4
731+
with:
732+
name: win-installer-x86_64
733+
path: win-installer-x86_64
734+
735+
- name: Download Windows installer (aarch64)
736+
uses: actions/download-artifact@v4
737+
with:
738+
name: win-installer-aarch64
739+
path: win-installer-aarch64
740+
741+
- name: Download macOS artifacts
742+
uses: actions/download-artifact@v4
743+
with:
744+
name: macos-artifacts
745+
path: macos-artifacts
746+
747+
- name: Download Debian package
748+
uses: actions/download-artifact@v4
749+
with:
750+
name: linux-artifacts
751+
path: deb-package
752+
753+
- uses: actions/github-script@v6
754+
with:
755+
script: |
756+
const fs = require('fs');
757+
const path = require('path');
758+
759+
var releaseMetadata = {
760+
owner: context.repo.owner,
761+
repo: context.repo.repo
762+
};
763+
764+
// Create the release
765+
var tagName = "${{ needs.prereqs.outputs.tag_name }}";
766+
var createdRelease = await github.rest.repos.createRelease({
767+
...releaseMetadata,
768+
draft: true,
769+
tag_name: tagName,
770+
name: tagName
771+
});
772+
releaseMetadata.release_id = createdRelease.data.id;
773+
774+
// Uploads contents of directory to the release created above
775+
async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
776+
return fs.promises.readdir(directory)
777+
.then(async(files) => Promise.all(
778+
files.filter(file => {
779+
return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
780+
})
781+
.map(async (file) => {
782+
var filePath = path.join(directory, file);
783+
github.rest.repos.uploadReleaseAsset({
784+
...releaseMetadata,
785+
name: file,
786+
headers: {
787+
"content-length": (await fs.promises.stat(filePath)).size
788+
},
789+
data: fs.createReadStream(filePath)
790+
});
791+
}))
792+
);
793+
}
794+
795+
await Promise.all([
796+
// Upload Windows x86_64 artifacts
797+
uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
798+
uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
799+
800+
// Upload Windows aarch64 artifacts
801+
uploadDirectoryToRelease('win-installer-aarch64', ['.exe']),
802+
uploadDirectoryToRelease('win-portable-aarch64', ['.exe']),
803+
804+
// Upload Mac artifacts
805+
uploadDirectoryToRelease('macos-artifacts'),
806+
807+
// Upload Ubuntu artifacts
808+
uploadDirectoryToRelease('deb-package')
809+
]);

0 commit comments

Comments
 (0)