Skip to content

Commit 07400fb

Browse files
authored
Fix artifact filenames (#67)
1 parent 00eba6e commit 07400fb

File tree

4 files changed

+53
-35
lines changed

4 files changed

+53
-35
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,25 @@ jobs:
6161
- name: Test
6262
run: esy test
6363

64-
- name: Get binary path
65-
id: print_binary_path
64+
- name: (release only) Get artifact filenames
65+
id: get_filenames
66+
# if: github.event_name != 'pull_request'
67+
run: node .github/workflows/get_filenames.js
68+
69+
- name: (release only) Get exe
70+
# if: github.event_name != 'pull_request'
6671
shell: bash
6772
run: |
6873
# from https://stackoverflow.com/a/24848739/617787
6974
s=$(pwd); d=$(dirname $(esy x which Extract.exe));
7075
while [ "${d#$s/}" == "${d}" ]
71-
do s=$(dirname $s);b="../${b}"; done;
76+
do s=$(dirname $s);b="../${b}"; done;
7277
ESY__BINARY_PATH=${b}${d#$s/}/Extract.exe
73-
echo "ESY__BINARY_PATH: $ESY__BINARY_PATH"
74-
echo "##[set-output name=path;]$ESY__BINARY_PATH"
78+
mv "$ESY__BINARY_PATH" ${{ steps.get_filenames.outputs.exe_name }}
7579
76-
- name: (only on release) Upload artifacts ${{ matrix.os }}
77-
if: github.event_name != 'pull_request'
80+
- name: (release only) Upload artifact ${{ matrix.os }}
81+
# if: github.event_name != 'pull_request'
7882
uses: actions/upload-artifact@v2
7983
with:
80-
name: ${{ matrix.os }}
81-
path: ${{ steps.print_binary_path.outputs.path }}
84+
name: ${{ steps.get_filenames.outputs.artifact_name }}
85+
path: ${{ steps.get_filenames.outputs.exe_name }}

.github/workflows/get_filenames.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const fs = require("fs");
2+
const os = require("os");
3+
4+
const packageJson = fs.readFileSync("package.json");
5+
const { version } = JSON.parse(packageJson);
6+
7+
const exeName = getExeName();
8+
const platform = getPlatformName();
9+
const artifactName = `bs-react-intl-extractor-${version}-${platform}`;
10+
11+
// For passing output to subsequent GitHub actions
12+
console.log(`::set-output name=exe_name::${exeName}`);
13+
console.log(`::set-output name=artifact_name::${artifactName}`);
14+
15+
function getPlatformName() {
16+
const platform = os.platform();
17+
18+
switch (platform) {
19+
case "linux":
20+
return "linux";
21+
case "darwin":
22+
return "macos";
23+
case "win32":
24+
return "windows";
25+
default:
26+
throw new Error(`Unexepected platform ${platform}`);
27+
}
28+
}
29+
30+
function getExeName() {
31+
const platform = os.platform();
32+
33+
switch (platform) {
34+
case "win32":
35+
return "bs-react-intl-extractor.exe";
36+
default:
37+
return "bs-react-intl-extractor";
38+
}
39+
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"scripts": {
1616
"test": "esy x RunTests.exe",
1717
"format": "scripts/format.sh",
18-
"setVersion": "node scripts/setVersion.js",
19-
"zip": "esy build && node scripts/createZip.js"
18+
"setVersion": "node scripts/setVersion.js"
2019
},
2120
"dependencies": {
2221
"@esy-ocaml/reason": "^3.6.0",

scripts/createZip.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)