Skip to content

Commit f2cd9a5

Browse files
authored
Build musl release (#31)
* Add docker builds for alpine releases * Pre1 for release * Retry on 0.6.0-pre1 * Fix cd for fmt * push node vars up to build script * After getting Travis working, bump to 0.6 * Code review fixes. * Add musl to readme. * Comment about what sleep does with detach
1 parent d813d09 commit f2cd9a5

File tree

7 files changed

+127
-48
lines changed

7 files changed

+127
-48
lines changed

.travis.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ language: rust
22
rust:
33
- 1.36.0
44

5+
services:
6+
- docker
7+
58
# all unlabeled jobs run at test. Only if all "test" jobs finish, will the publish job run
69
stages:
710
- test
@@ -11,36 +14,57 @@ jobs:
1114
include:
1215
# PRs, pushes to master, and tags build on all target arches
1316
# if this is release tag, the resultant binary will be uploaded to github
14-
- name: "Linux - Node 8"
17+
- name: "Linux - Node 8 - glibc"
1518
os: linux
1619
env:
1720
- TRAVIS_NODE_VERSION="8"
1821
- SKIP_DEPLOY=0
1922
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
23+
- name: "Linux - Node 8 - musl"
24+
os: linux
25+
env:
26+
- SKIP_DEPLOY=0
27+
- IMAGE=8-alpine
28+
- INDOCKER="docker exec target"
29+
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
2030
- name: "OSX - Node 8"
2131
os: osx
2232
env:
2333
- TRAVIS_NODE_VERSION="8"
2434
- SKIP_DEPLOY=0
2535
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
26-
- name: "Linux - Node 10"
36+
- name: "Linux - Node 10 - glibc"
2737
os: linux
2838
env:
2939
- TRAVIS_NODE_VERSION="10"
3040
- SKIP_DEPLOY=0
3141
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
42+
- name: "Linux - Node 10 - musl"
43+
os: linux
44+
env:
45+
- SKIP_DEPLOY=0
46+
- IMAGE=10-alpine
47+
- INDOCKER="docker exec target"
48+
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
3249
- name: "OSX - Node 10"
3350
os: osx
3451
env:
3552
- TRAVIS_NODE_VERSION="10"
3653
- SKIP_DEPLOY=0
3754
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
38-
- name: "Linux - Node 12"
55+
- name: "Linux - Node 12 - glibc"
3956
os: linux
4057
env:
4158
- TRAVIS_NODE_VERSION="12"
4259
- SKIP_DEPLOY=0
4360
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
61+
- name: "Linux - Node 12 - musl"
62+
os: linux
63+
env:
64+
- SKIP_DEPLOY=0
65+
- IMAGE=12-alpine
66+
- INDOCKER="docker exec target"
67+
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
4468
- name: "OSX - Node 12"
4569
os: osx
4670
env:
@@ -65,13 +89,11 @@ jobs:
6589
- echo "Deploying to NPM..."
6690
- node publish.js --publish
6791

68-
install:
69-
# install our own yarn to make things work on osx
70-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.10.1
71-
- export PATH=$HOME/.yarn/bin:$PATH
92+
before_install:
93+
- ./.travis_scripts/maybe-start-docker.sh
7294

73-
# install our own nodejs to get a reasonable version
74-
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
95+
install:
96+
- source .travis_scripts/maybe-install-node.sh
7597

7698
notifications:
7799
email:
@@ -83,11 +105,11 @@ cache:
83105
directories:
84106
- node_modules
85107
before_script:
86-
- rustup component add rustfmt-preview
87-
- yarn install --ignore-scripts
108+
- ${INDOCKER} rustup component add rustfmt-preview
109+
- ${INDOCKER} yarn --ignore-scripts
88110
script:
89-
- pushd native/ && cargo fmt -- --check && popd
90-
- node publish.js
111+
- ${INDOCKER} /bin/sh -c "cd native/ && cargo fmt -- --check"
112+
- ${INDOCKER} node publish.js
91113

92114
# deploy the node-pre-gyp binary to github releases so it's there when the npm package is installed
93115
deploy:

.travis_scripts/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ARG IMAGE
2+
FROM node:${IMAGE}
3+
4+
RUN wget https://sh.rustup.rs -O - | sh -s -- -y
5+
RUN ln -s "${HOME}"/.cargo/bin/* /usr/local/bin
6+
# hack to get dynlibs working with musl
7+
# https://github.com/rust-lang/rust/pull/55163#issuecomment-436631090
8+
ENV RUSTFLAGS="-C target-feature=-crt-static"
9+
RUN apk add --no-cache build-base musl-dev python2
10+
11+
CMD ["sh"]

.travis_scripts/maybe-install-node.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
# Installs correct node and yarn versions if we aren't doing a docker build.
4+
5+
if [ -z "${IMAGE}" ] ; then
6+
# install our own yarn to make things work on osx
7+
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.10.1
8+
export PATH=$HOME/.yarn/bin:$PATH
9+
10+
# install our own nodejs to get a reasonable version if outside docker
11+
rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
12+
fi

.travis_scripts/maybe-start-docker.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
# Starts our build image inside docker, if we're doing a docker build.
4+
5+
set -ex
6+
7+
if [ -z "${IMAGE}" ] ; then
8+
exit 0
9+
fi
10+
11+
docker build -t node-rust:"${IMAGE}" -f ".travis_scripts/Dockerfile" --build-arg IMAGE="$IMAGE" .
12+
13+
# sleep so our detached container with no long running process sits around to accept commands for a bit
14+
docker run --detach --name target -v "$(pwd)":/src -w /src node-rust:"${IMAGE}" sleep 999999999

CHANGELOG.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1+
## 0.6.0
2+
3+
### Added
4+
5+
- Added binaries dynamically linked to musl-libc to support Alpine Linux
6+
7+
### Breaking Changes
8+
9+
None
10+
11+
### Changed
12+
13+
None
14+
115
## 0.5.2
216

3-
+ Depend on official release of Neon 0.3.
17+
- Depend on official release of Neon 0.3.
418

519
## 0.5.1
620

721
### Breaking Changes
822

9-
+ Added support for Node 12
10-
+ Removed support for Node 9 and 11
11-
+ Removed the `hash256` method from the API. Use the `deriveSymmetricKey` method instead.
23+
- Added support for Node 12
24+
- Removed support for Node 9 and 11
25+
- Removed the `hash256` method from the API. Use the `deriveSymmetricKey` method instead.
1226

1327
### Changed
1428

15-
+ Updated all dependencies to their latest versions, including Recrypt to 0.8.
29+
- Updated all dependencies to their latest versions, including Recrypt to 0.8.
1630

1731
## 0.4.2
1832

@@ -26,41 +40,42 @@ None
2640

2741
### Changed
2842

29-
+ Added support to build artifacts for Node 9 and Node 11.
43+
- Added support to build artifacts for Node 9 and Node 11.
3044

3145
## 0.4.1
3246

3347
### Added
34-
+ `Api256.hash256(hashable_buffer: Buffer): Buffer;` Note that the returned `Buffer` will always be _exactly_ 32 bytes.
48+
49+
- `Api256.hash256(hashable_buffer: Buffer): Buffer;` Note that the returned `Buffer` will always be _exactly_ 32 bytes.
3550

3651
## 0.4.0
3752

3853
### Breaking Changes
3954

40-
+ Renamed the `transformKeyToBytes` method to `transformKeyToBytes256` to specify that it only works with 256 bit TransformKeys.
41-
+ Removed incorrect empty array from TransformKey objects.
55+
- Renamed the `transformKeyToBytes` method to `transformKeyToBytes256` to specify that it only works with 256 bit TransformKeys.
56+
- Removed incorrect empty array from TransformKey objects.
4257

4358
### Added
4459

4560
None
4661

4762
### Changed
4863

49-
+ Added `engines`, `os`, and `cpu` keys to `package.json` to specify which Node version and architectures this library will work on.
64+
- Added `engines`, `os`, and `cpu` keys to `package.json` to specify which Node version and architectures this library will work on.
5065

5166
## 0.3.0
5267

5368
### Breaking Changes
5469

55-
+ The `Api256.encrypt`, `Api256.generateTransformKey`, `Api256.transform` functions now only take a private signing key and no longer need to provide a public signing key.
70+
- The `Api256.encrypt`, `Api256.generateTransformKey`, `Api256.transform` functions now only take a private signing key and no longer need to provide a public signing key.
5671

5772
### Added
5873

59-
+ Added new `transformKeyToBytes` top level method to convert a `TransformKey` object into a Buffer in a consistent order. Useful for being able to sign over the bytes of a `TransformKey`.
74+
- Added new `transformKeyToBytes` top level method to convert a `TransformKey` object into a Buffer in a consistent order. Useful for being able to sign over the bytes of a `TransformKey`.
6075

6176
### Changed
6277

63-
+ Updated to `recrypt-rs` 0.3.0.
78+
- Updated to `recrypt-rs` 0.3.0.
6479

6580
## 0.2.0
6681

@@ -70,19 +85,18 @@ None
7085

7186
### Added
7287

73-
* Added methods for [Schnorr signing](https://en.wikipedia.org/wiki/Schnorr_signature).
74-
+ `Api256::schnorrSign(privateKey: Buffer, publicKey: PublicKey, message: Buffer): Signature;`
75-
+ `Api256::schnorrVerify(publicKey: PublicKey, augmentedPrivateKey: Buffer | undefined, message: Buffer, signature: Signature): boolean;`
76-
* Exposed methods to perform ed25519 signing and verification as well as method to compute an ed25519 public key given it's matching private key.
77-
+ `Api256::ed25519Sign(privateKey: PrivateSigningKey, message: Buffer): Signature;`
78-
+ `Api256::ed25519Verify(publicKey: PublicSigningKey, message: Buffer, signature: Signature): boolean;`
79-
+ `Api256::computeEd25519PublicKey(privateKey: PrivateSigningKey): PublicSigningKey;`
88+
- Added methods for [Schnorr signing](https://en.wikipedia.org/wiki/Schnorr_signature).
89+
- `Api256::schnorrSign(privateKey: Buffer, publicKey: PublicKey, message: Buffer): Signature;`
90+
- `Api256::schnorrVerify(publicKey: PublicKey, augmentedPrivateKey: Buffer | undefined, message: Buffer, signature: Signature): boolean;`
91+
- Exposed methods to perform ed25519 signing and verification as well as method to compute an ed25519 public key given it's matching private key.
92+
- `Api256::ed25519Sign(privateKey: PrivateSigningKey, message: Buffer): Signature;`
93+
- `Api256::ed25519Verify(publicKey: PublicSigningKey, message: Buffer, signature: Signature): boolean;`
94+
- `Api256::computeEd25519PublicKey(privateKey: PrivateSigningKey): PublicSigningKey;`
8095

8196
### Changed
8297

83-
* Consumed changes from [`recrypt-rs`](https://github.com/IronCoreLabs/recrypt-rs)([#1](https://github.com/IronCoreLabs/recrypt-rs/issues/1)) to zero secret bytes after use
84-
* Moved `benchmark` and `test` repos to the root of the repo
85-
98+
- Consumed changes from [`recrypt-rs`](https://github.com/IronCoreLabs/recrypt-rs)([#1](https://github.com/IronCoreLabs/recrypt-rs/issues/1)) to zero secret bytes after use
99+
- Moved `benchmark` and `test` repos to the root of the repo
86100

87101
## 0.1.0
88102

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ This library uses the [Neon Bindings](https://www.neon-bindings.com) toolchain t
99

1010
## Supported Platforms
1111

12-
| | Node 8 | Node 10 | Node 12 |
13-
| --------- | ------ | ------- | ------ |
14-
| Linux x64 ||||
15-
| OSX x64 ||||
12+
| | Node 8 | Node 10 | Node 12 |
13+
| --------------------- | ------ | ------- | ------- |
14+
| Linux x64 - glibc ||||
15+
| Linux x64 - musl-libc ||||
16+
| OSX x64 ||||
1617

1718
## Install
1819

@@ -35,6 +36,7 @@ This library contains a [TypeScript definitions](index.d.ts) file which shows th
3536
The following examples show how to use this library from a NodeJS application
3637

3738
#### Basic Encrypt/Decrypt Example
39+
3840
```js
3941
const assert = require("assert");
4042
const Recrypt = require("@ironcorelabs/recrypt-node-binding");
@@ -57,6 +59,7 @@ assert.equal(decryptedValue, plaintext);
5759
```
5860

5961
#### Single-hop Transform Encryption Example
62+
6063
```js
6164
const assert = require("assert");
6265
const Recrypt = require("@ironcorelabs/recrypt-node-binding");
@@ -99,7 +102,9 @@ Once all of those dependencies are installed, the following can be run.
99102
```
100103
npm run compile
101104
```
105+
102106
or
107+
103108
```
104109
yarn run compile
105110
```
@@ -112,15 +117,15 @@ const recrypt = require('index.node');
112117

113118
### Benchmarks
114119

115-
+ From this repos root, run `npm i` or `yarn`.
116-
+ Run `npm/yarn run compile` to compile the Rust source into a `native/index.node` module.
117-
+ Run `npm/yarn run benchmark`.
120+
- From this repos root, run `npm i` or `yarn`.
121+
- Run `npm/yarn run compile` to compile the Rust source into a `native/index.node` module.
122+
- Run `npm/yarn run benchmark`.
118123

119124
### Unit Tests
120125

121-
+ From this repos root, run `npm i` or `yarn`.
122-
+ Run `npm/yarn run compile` to compile the Rust source into a `native/index.node` module.
123-
+ Run `npm/yarn run test`.
126+
- From this repos root, run `npm i` or `yarn`.
127+
- Run `npm/yarn run compile` to compile the Rust source into a `native/index.node` module.
128+
- Run `npm/yarn run test`.
124129

125-
Copyright (c) 2018-present IronCore Labs, Inc.
130+
Copyright (c) 2018-present IronCore Labs, Inc.
126131
All rights reserved.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ironcorelabs/recrypt-node-binding",
3-
"version": "0.5.2",
3+
"version": "0.6.0",
44
"description": "Bindings to allow the recrypt-rs library to work via NodeJS.",
55
"repository": {
66
"type": "git",
@@ -56,6 +56,7 @@
5656
"module_name": "index",
5757
"module_path": "./bin-package",
5858
"host": "https://github.com/IronCoreLabs/recrypt-node-binding/releases/download/",
59+
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}-{libc}.tar.gz",
5960
"remote_path": "{version}"
6061
}
6162
}

0 commit comments

Comments
 (0)