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

Commit fc1c0dd

Browse files
bors[bot]thomaseizingerda-kami
authored
Merge #266
266: Make it work on windows 🎉 r=mergify[bot] a=thomaseizinger Fixes #105. Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Co-authored-by: Daniel Karzel <daniel.karzel@coblox.tech>
2 parents 05ff59b + 24481d1 commit fc1c0dd

File tree

25 files changed

+541
-167
lines changed

25 files changed

+541
-167
lines changed

.github/workflows/CI.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ jobs:
5555
toolchain: ${{ env.RUST_TOOLCHAIN }}
5656
override: true
5757

58+
- name: Install OpenSSL and configure it to link statically
59+
run: |
60+
vcpkg install openssl:x64-windows-static
61+
vcpkg integrate install
62+
echo "::set-env name=RUSTFLAGS::-Ctarget-feature=+crt-static"
63+
if: matrix.os == 'windows'
64+
5865
- name: Build ${{ matrix.os }} binary
5966
run: make build
6067

@@ -103,4 +110,4 @@ jobs:
103110
cd .npm
104111
yarn install
105112
yarn list
106-
yarn test
113+
yarn test

.github/workflows/release-bin.yml

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,71 @@ on:
77
- '[0-9]+.[0-9]+.[0-9]+'
88

99
jobs:
10-
build:
11-
name: Rust project
12-
runs-on: ${{ matrix.os }}
10+
rust_build:
1311
strategy:
1412
matrix:
15-
os: [ubuntu-latest, macOS-latest]
13+
os: [macos, windows, ubuntu]
14+
include:
15+
- os: windows
16+
binary: create-comit-app.exe
17+
- os: ubuntu
18+
binary: create-comit-app
19+
- os: macos
20+
binary: create-comit-app
21+
runs-on: ${{ matrix.os }}-latest
1622
steps:
17-
- uses: actions/checkout@master
18-
# Workaround until actions/virtual-environments#6 is fixed
19-
- name: Get Toolchain version
20-
if: startsWith(matrix.os, 'macOS')
21-
run: |
22-
echo ::set-env name=TOOLCHAIN::$(cat rust-toolchain|head -n1)
23-
- name: Install Rust
24-
if: startsWith(matrix.os, 'macOS')
23+
- name: Checkout sources
24+
uses: actions/checkout@v1
25+
26+
- name: Extract toolchain version from rust-toolchain
27+
run: echo "::set-env name=RUST_TOOLCHAIN::$(cat rust-toolchain)"
28+
29+
- name: Install ${{ env.RUST_TOOLCHAIN }} toolchain
2530
uses: actions-rs/toolchain@v1
2631
with:
27-
toolchain: ${{ env.TOOLCHAIN }}
28-
- name: Build release
29-
uses: actions-rs/cargo@v1
32+
profile: minimal
33+
toolchain: ${{ env.RUST_TOOLCHAIN }}
34+
override: true
35+
36+
- name: Install OpenSSL and configure it to link statically
37+
run: |
38+
vcpkg install openssl:x64-windows-static
39+
vcpkg integrate install
40+
echo "::set-env name=RUSTFLAGS::-Ctarget-feature=+crt-static"
41+
if: matrix.os == 'windows'
42+
43+
- name: Build ${{ matrix.os }} release binary
44+
run: make release
45+
46+
- name: Use Node.js 10.x
47+
uses: actions/setup-node@v1
3048
with:
31-
command: build
32-
args: --release --all-features
49+
node-version: 10.x
50+
3351
- name: Create archive
3452
if: startsWith(github.ref, 'refs/tags/')
53+
shell: bash
3554
run: |
36-
VERSION=${GITHUB_REF##*/};
37-
(cd ./target/release; tar czvf ~/create-comit-app_${VERSION}_$(uname -s)_$(uname -m).tar.gz create-comit-app;)
38-
mv ~/create-comit-app_*.tar.gz .
39-
- name: Upload asset
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
4064
uses: softprops/action-gh-release@v1
4165
if: startsWith(github.ref, 'refs/tags/')
4266
with:
4367
files: create-comit-app_*.tar.gz
4468
env:
4569
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
4671
npm_build:
4772
name: NPM Project
4873
runs-on: ubuntu-latest
49-
needs: build # Do not publish if the build failed
74+
needs: rust_build # Do not publish if the build failed
5075
steps:
5176
- uses: actions/checkout@v1
5277
- name: Use Node.js 10.x
@@ -66,4 +91,4 @@ jobs:
6691
cd .npm
6792
yarn publish
6893
env:
69-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
94+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.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);

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
## Added
10+
- Windows support :tada:.
11+
912
## [0.5.2] - 2019-12-06
1013

1114
## Changed

0 commit comments

Comments
 (0)