Merge pull request #207 from github/tweak-windows-build

Improve naming of Windows release asset
This commit is contained in:
Mislav Marohnić 2020-01-10 11:54:29 +01:00 committed by GitHub
commit f0ab533bbc
13 changed files with 17605 additions and 17540 deletions

View file

@ -1,9 +1,6 @@
name: 'Build MSI'
description: 'Build, sign, and release Windows installers using WiX'
inputs:
version:
description: 'what version to use for the built MSI'
required: true
exe:
description: 'path to exe to wrap in MSI '
required: true

File diff suppressed because one or more lines are too long

View file

@ -42,7 +42,7 @@ async function go_msi(version, exePath) {
console.log(`moving ${exePath} to bin/gh.exe`);
fs.renameSync(exePath, path.join(binPath, 'gh.exe'));
const msiPath = path.join(cwd, 'gh.msi');
const msiPath = path.join(cwd, path.basename(exePath, '.exe') + '.msi');
try {
await exec.exec(

View file

@ -1,8 +1,6 @@
{
"name": "build-msi",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@actions/core": {
"version": "1.2.0",
@ -108,6 +106,12 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz",
"integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA=="
},
"@zeit/ncc": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz",
"integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==",
"dev": true
},
"atob-lite": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz",

View file

@ -1,17 +1,15 @@
{
"name": "build-msi",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "rm -rf dist && ncc build index.js -o dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/exec": "^1.0.2",
"@actions/github": "^2.0.0"
},
"devDependencies": {
"@zeit/ncc": "^0.21.0"
}
}

View file

@ -1,8 +1,6 @@
{
"name": "download-exe",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@actions/core": {
"version": "1.2.0",
@ -95,6 +93,12 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.21.tgz",
"integrity": "sha512-8sRGhbpU+ck1n0PGAUgVrWrWdjSW2aqNeyC15W88GRsMpSwzv6RJGlLhE7s2RhVSOdyDmxbqlWSeThq4/7xqlA=="
},
"@zeit/ncc": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz",
"integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==",
"dev": true
},
"atob-lite": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz",

View file

@ -1,17 +1,15 @@
{
"name": "download-exe",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "rm -rf dist && ncc build index.js -o dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/github": "^2.0.0",
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@zeit/ncc": "^0.21.0"
}
}

View file

@ -1,5 +1,9 @@
name: 'Upload MSI'
description: 'Upload gh.msi to both homebrew-gh and gh-cli releases'
description: 'Upload an additional asset to a release'
inputs:
msi-file:
description: 'path to the MSI file to attach to a release'
required: true
runs:
using: 'node12'
main: 'dist/index.js'

File diff suppressed because one or more lines are too long

View file

@ -3,9 +3,10 @@ const path = require('path');
const github = require('@actions/github');
const core = require('@actions/core');
const Octokit = require('@octokit/rest');
const GITHUB_TOKEN = process.env['GITHUB_TOKEN'];
const MSI_PATH = 'gh.msi';
const MSI_PATH = core.getInput('msi-file');
process.on('unhandledRejection', function(reason, _) {
handleError(reason);
@ -21,23 +22,33 @@ async function main() {
const owner = github.context.repo.owner;
const repo = github.context.repo.repo;
const octokit = new github.GitHub(GITHUB_TOKEN);
const release = await getRelease(octokit, owner, repo, tag);
const release = await getRelease(GITHUB_TOKEN, owner, repo, tag);
const assetFile = fs.readFileSync(MSI_PATH);
await uploadAsset(GITHUB_TOKEN, release, assetFile);
const assetFile = fs.createReadStream(MSI_PATH);
try {
await uploadAsset(octokit, release, assetFile);
await deleteAsset(octokit, release, owner, repo, path.basename(MSI_PATH, '.msi') + '.exe');
} finally {
assetFile.close()
}
}
async function getRelease(token, owner, repo, tag) {
const octokit = new github.GitHub(token);
/**
* @param {github.GitHub} octokit
*/
async function getRelease(octokit, owner, repo, tag) {
const response = await octokit.repos.getReleaseByTag({ owner, repo, tag });
return response.data;
}
async function uploadAsset(token, release, assetFile) {
const octokit = new github.GitHub(token);
/**
* @param {github.GitHub} octokit
* @param {Octokit.ReposGetReleaseByTagResponse} release
*/
async function uploadAsset(octokit, release, assetFile) {
await octokit.repos.uploadReleaseAsset({
url: release.upload_url,
file: assetFile,
@ -49,6 +60,22 @@ async function uploadAsset(token, release, assetFile) {
});
}
/**
* @param {github.GitHub} octokit
* @param {Octokit.ReposGetReleaseByTagResponse} release
*/
async function deleteAsset(octokit, release, owner, repo, assetName) {
for (const asset of release.assets) {
if (asset.name == assetName) {
await octokit.repos.deleteReleaseAsset({
owner,
repo,
asset_id: asset.id
})
}
}
}
async function handleError(err) {
console.error(err);
core.setFailed(err.message);

View file

@ -95,6 +95,12 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.20.tgz",
"integrity": "sha512-VAe+DiwpnC/g448uN+/3gRl4th0BTdrR9gSLIOHA+SUQskaYZQDOHG7xmjiE7JUhjbXnbXytf6Ih+/pA6CtMFQ=="
},
"@zeit/ncc": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz",
"integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==",
"dev": true
},
"atob-lite": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz",

View file

@ -1,16 +1,14 @@
{
"name": "upload-msi",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "rm -rf dist && ncc build index.js -o dist"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/github": "^2.0.0"
},
"devDependencies": {
"@zeit/ncc": "^0.21.0"
}
}

View file

@ -61,6 +61,8 @@ jobs:
-Executable "${{ steps.buildmsi.outputs.msi }}"
- name: Upload MSI
uses: ./.github/actions/upload-msi
with:
msi-file: ${{ steps.buildmsi.outputs.msi }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
releases: