Skip to content

Commit

Permalink
release: create draft GitHub release with packages & installers
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
2 people authored and dscho committed Nov 3, 2023
1 parent ff6a052 commit 7e07030
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build-git-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,89 @@ jobs:
path: |
*.deb
# End build and sign Debian package

create-github-release:
runs-on: ubuntu-latest
needs: [validate-installers]
if: |
success() ||
(needs.create-linux-artifacts.result == 'skipped' &&
needs.create-macos-artifacts.result == 'success' &&
needs.windows_artifacts.result == 'success')
steps:
- name: Download Windows portable installer
uses: actions/download-artifact@v3
with:
name: win-portable-x86_64
path: win-portable-x86_64

- name: Download Windows x86_64 installer
uses: actions/download-artifact@v3
with:
name: win-installer-x86_64
path: win-installer-x86_64

- name: Download macOS artifacts
uses: actions/download-artifact@v3
with:
name: macos-artifacts
path: macos-artifacts

- name: Download Debian package
uses: actions/download-artifact@v3
with:
name: linux-artifacts
path: deb-package
- uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const path = require('path');
var releaseMetadata = {
owner: context.repo.owner,
repo: context.repo.repo
};
// Create the release
var tagName = "${{ needs.prereqs.outputs.tag_name }}";
var createdRelease = await github.rest.repos.createRelease({
...releaseMetadata,
draft: true,
tag_name: tagName,
name: tagName
});
releaseMetadata.release_id = createdRelease.data.id;
// Uploads contents of directory to the release created above
async function uploadDirectoryToRelease(directory, includeExtensions=[]) {
return fs.promises.readdir(directory)
.then(async(files) => Promise.all(
files.filter(file => {
return includeExtensions.length==0 || includeExtensions.includes(path.extname(file).toLowerCase());
})
.map(async (file) => {
var filePath = path.join(directory, file);
github.rest.repos.uploadReleaseAsset({
...releaseMetadata,
name: file,
headers: {
"content-length": (await fs.promises.stat(filePath)).size
},
data: fs.createReadStream(filePath)
});
}))
);
}
await Promise.all([
// Upload Windows artifacts
uploadDirectoryToRelease('win-installer-x86_64', ['.exe']),
uploadDirectoryToRelease('win-portable-x86_64', ['.exe']),
// Upload Mac artifacts
uploadDirectoryToRelease('macos-artifacts'),
// Upload Ubuntu artifacts
uploadDirectoryToRelease('deb-package')
]);

0 comments on commit 7e07030

Please sign in to comment.