Skip to content
This repository was archived by the owner on Mar 23, 2021. It is now read-only.

Commit 5d90dea

Browse files
Upload the release binary to the GitHub release
To make sure we download the correct binary from the GitHub releases, the logic for determining the archive name now lives in a dedicated JavaScript module that is used by both, the release process in GitHub actions and the NPM package create-comit-app.
1 parent 94af839 commit 5d90dea

File tree

4 files changed

+47
-18
lines changed

4 files changed

+47
-18
lines changed

.github/workflows/release-bin.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@ jobs:
4343
- name: Build ${{ matrix.os }} release binary
4444
run: make release
4545

46+
- name: Use Node.js 10.x
47+
uses: actions/setup-node@v1
48+
with:
49+
node-version: 10.x
50+
51+
- name: Create archive
52+
if: startsWith(github.ref, 'refs/tags/')
53+
shell: bash
54+
run: |
55+
VERSION=$(git describe --tags)
56+
57+
# We need to do bash -c to make sure this also works on GitBash for Windows.
58+
# GitHub actions uses GitBash for Windows if we say 'shell: bash' on a Windows executor.
59+
ARCHIVE=$(bash -c "node .npm/printArchiveName.js ${VERSION}")
60+
61+
tar czvf ${ARCHIVE} -C target/release ${{ matrix.binary }}
62+
63+
- name: Upload asset to GitHub release
64+
uses: softprops/action-gh-release@v1
65+
if: startsWith(github.ref, 'refs/tags/')
66+
with:
67+
files: create-comit-app_*.tar.gz
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
4671
npm_build:
4772
name: NPM Project
4873
runs-on: ubuntu-latest

.npm/download.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
const fs = require("fs");
22
const util = require("util");
3-
const exec = util.promisify(require("child_process").exec);
43
const extract = util.promisify(require("targz").decompress);
54
const axios = require("axios");
65
const path = require("path");
7-
8-
async function getSystem() {
9-
const { stdout } = await exec("uname -s");
10-
return stdout.trim();
11-
}
12-
13-
async function getArch() {
14-
const { stdout } = await exec("uname -m");
15-
return stdout.trim();
16-
}
6+
const makeArchiveName = require("./makeArchiveName").default;
177

188
async function download(version, binTarget) {
19-
const system = await getSystem();
20-
const arch = await getArch();
21-
if (!version || !system || !arch) {
22-
throw new Error("Could not retrieve needed information.");
23-
}
24-
259
const targetDir = path.dirname(binTarget);
2610

27-
const archiveName = `create-comit-app_${version}_${system}_${arch}.tar.gz`;
11+
const archiveName = makeArchiveName(version);
2812
const archivePath = targetDir + "/" + archiveName;
2913

3014
if (!fs.existsSync(targetDir)) {

.npm/makeArchiveName.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const os = require("os");
2+
3+
exports.default = function makeArchiveName(version) {
4+
const kernel = os.type();
5+
const arch = os.arch();
6+
7+
return `create-comit-app_${version}_${kernel}_${arch}.tar.gz`;
8+
};

.npm/printArchiveName.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const makeArchiveName = require("./makeArchiveName").default;
2+
3+
const version = process.argv[2];
4+
5+
if (!version) {
6+
console.error("Please pass the version as the first argument.");
7+
process.exit(1);
8+
}
9+
10+
const archiveName = makeArchiveName(version);
11+
12+
console.log(archiveName);

0 commit comments

Comments
 (0)