Automatically release to crates.io & NPM (#38)

This commit is contained in:
folex 2020-12-16 21:59:11 +03:00 committed by GitHub
parent 88ef4526ff
commit bf78530156
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 366 additions and 25 deletions

View File

@ -1,7 +1,7 @@
# run locally like this:
# act -b -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j npm-publish -s "NPM_TOKEN=uuid-uuid-uuid-uuid"
# act -b -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j publish-interpreter -s "NPM_TOKEN=uuid-uuid-uuid-uuid"
name: "publish-base64-npm"
name: "publish-interpreter"
on:
push:
@ -20,22 +20,52 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
### Install rust & wasm-pack
- name: Install Rust toolchain
### Prepare cargo & toolchains
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain with wasm32-unknown-unknown
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Install wasm32-wasi
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-wasi
profile: minimal
### Calculate MAX_VERSION
- name: Install jq & sponge
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq moreutils
- name: Install cargo-show
run: cargo install cargo-show || true
- name: Get versions from npm & crates.io, and take the highest one
run: |
yarn global add semver
PATH="$(yarn global bin):$PATH"
JS_VERSION="$(yarn info --silent @fluencelabs/aquamarine-stepper version || true)"
RS_VERSION="$((cargo show --json air-interpreter-wasm | jq -r .crate.max_version) 2>/dev/null || true)"
MAX_VERSION="$(semver "$JS_VERSION" "$RS_VERSION" "0.0.0" | tail -n1)"
echo "MAX_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
### === JavaScript package release ===
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
### Build aquamarine.wasm
- run: wasm-pack build $GITHUB_WORKSPACE/stepper --no-typescript --release -d $(pwd)/pkg
- name: Build aquamarine.wasm for JS clients
run: wasm-pack build $GITHUB_WORKSPACE/stepper --no-typescript --release -d $(pwd)/pkg
### Generate aquamarine.wasm.base64.js
- run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
- name: Generate aquamarine.wasm.base64.js
run: |
cat << EOF > pkg/aquamarine.wasm.base64.js
@ -57,7 +87,6 @@ jobs:
cat << EOF > aquamarine.wasm.base64.d.ts
export const wasmBs64: string;
EOF
working-directory: pkg
- name: Prepare package.json for publishing
@ -79,8 +108,8 @@ jobs:
cat pkg/package_new.json
mv pkg/package_new.json pkg/package.json
### Get version from NPM registry
- run: yarn version --new-version $(yarn info --silent @fluencelabs/aquamarine-stepper version) --no-git-tag-version
### Set version
- run: yarn version --new-version ${{ env.MAX_VERSION }} --no-git-tag-version
working-directory: pkg
### Increment patch component of the version
- run: yarn version --patch --no-git-tag-version
@ -100,3 +129,27 @@ jobs:
access: public
check-version: false
token: ${{ secrets.NPM_TOKEN }}
### === Rust package release ===
- name: Install fcli toml-cli
run: cargo install fcli toml-cli || true
- name: Build aquamarine.wasm for node
run: fce build --release -p aquamarine --features fce
working-directory: stepper
- name: Copy aquamarine.wasm to air-interpreter-wasm
run: cp target/wasm32-wasi/release/aquamarine.wasm crates/air-interpreter-wasm/aquamarine.wasm
- name: Set project version to MAX_VERSION
run: |
PATH="~/.cargo/bin:$PATH"
toml set Cargo.toml package.version "${{ env.MAX_VERSION }}" | sponge Cargo.toml
working-directory: crates/air-interpreter-wasm
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
run: cargo publish --allow-dirty
working-directory: crates/air-interpreter-wasm

View File

@ -1,7 +1,7 @@
# run locally like this:
# act -b -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j npm-publish-dev -s "NPM_TOKEN=uuid-uuid-uuid-uuid"
# act -b -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j publish-interpreter-branch -s "NPM_TOKEN=uuid-uuid-uuid-uuid"
name: "publish-base64-npm-dev"
name: "publish-interpreter-branch"
on:
push:
@ -10,7 +10,7 @@ on:
jobs:
npm-publish-dev:
name: "Publish Aquamarine to NPM"
name: "Publish AIR interpreter .wasm to NPM & crates.io"
runs-on: ubuntu-latest
defaults:
run:
@ -30,22 +30,52 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
### Install rust & wasm-pack
- name: Install Rust toolchain
### Prepare cargo & toolchains
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain with wasm32-unknown-unknown
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
profile: minimal
override: true
- name: Install wasm32-wasi
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-wasi
profile: minimal
### Calculate MAX_VERSION
- name: Install jq & sponge
run: sudo apt-get update && sudo apt-get --yes --force-yes install jq moreutils
- name: Install cargo-show
run: cargo install cargo-show || true
- name: Get versions from npm & crates.io, and take the highest one
run: |
yarn global add semver
PATH="$(yarn global bin):$PATH"
JS_VERSION="$(yarn info --silent @fluencelabs/aquamarine-stepper-${{ env.BRANCH_NAME }} version || true)"
RS_VERSION="$((cargo show --json air-interpreter-wasm-${{ env.BRANCH_NAME }} | jq -r .crate.max_version) 2>/dev/null || true)"
MAX_VERSION="$(semver "$JS_VERSION" "$RS_VERSION" "0.0.0" | tail -n1)"
echo "MAX_VERSION=$MAX_VERSION" | tee -a $GITHUB_ENV
### === JavaScript package release ===
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
continue-on-error: true
### Build aquamarine.wasm
- run: wasm-pack build $GITHUB_WORKSPACE/stepper --no-typescript --release -d $(pwd)/pkg
- name: Build aquamarine.wasm for JS clients
run: wasm-pack build $GITHUB_WORKSPACE/stepper --no-typescript --debug -d $(pwd)/pkg
### Generate aquamarine.wasm.base64.js
- run: sudo apt-get update && sudo apt-get --yes --force-yes install jq
- name: Generate aquamarine.wasm.base64.js
run: |
cat << EOF > pkg/aquamarine.wasm.base64.js
@ -69,8 +99,6 @@ jobs:
EOF
working-directory: pkg
- run: cat pkg/package.json
- name: Prepare package.json for publishing
run: |
cat pkg/package.json | jq --arg name aquamarine.wasm.base64.js \
@ -96,8 +124,8 @@ jobs:
- run: yarn version --new-version 0.0.0 --no-git-tag-version
working-directory: pkg
### Maybe get version from NPM registry
- run: yarn version --new-version $(yarn info --silent @fluencelabs/aquamarine-stepper-${{ env.BRANCH_NAME }} version) --no-git-tag-version || true
### Set version to MAX_VERSION
- run: yarn version --new-version ${{ env.MAX_VERSION }} --no-git-tag-version || true
working-directory: pkg
### Increment patch component of the version
@ -115,10 +143,40 @@ jobs:
### Publish to NPM registry
- uses: actions/setup-node@v1
with:
node-version: '15'
node-version: '14'
registry-url: 'https://registry.npmjs.org'
- run: npm publish --access public
working-directory: pkg
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
### === Rust package release ===
- name: Install fcli toml-cli
run: cargo install fcli toml-cli || true
- name: Build aquamarine.wasm for node (note this is a DEBUG build)
run: fce build -p aquamarine --features fce
working-directory: stepper
- name: Copy aquamarine.wasm to air-interpreter-wasm
run: cp target/wasm32-wasi/debug/aquamarine.wasm crates/air-interpreter-wasm/aquamarine.wasm
- name: Set project version to MAX_VERSION & add branch to its name
run: |
PATH="~/.cargo/bin:$PATH"
toml set Cargo.toml package.version "${{ env.MAX_VERSION }}" | sponge Cargo.toml
NAME=$(toml get Cargo.toml package.name | jq -r .)
toml set Cargo.toml package.name "${NAME}_${BRANCH_NAME}" | sponge Cargo.toml
cat Cargo.toml
working-directory: crates/air-interpreter-wasm
- name: Login to crates.io
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish to crates.io
run: cargo publish --allow-dirty
working-directory: crates/air-interpreter-wasm

View File

@ -7,6 +7,8 @@ members = [
"stepper-lib",
]
exclude = [ "crates/air-interpreter-wasm" ]
[profile.release]
opt-level = 3
debug = false

187
crates/air-interpreter-wasm/Cargo.lock generated Normal file
View File

@ -0,0 +1,187 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "air-interpreter-wasm"
version = "0.0.8"
dependencies = [
"built",
]
[[package]]
name = "built"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8f1b029cb3929cb0c99780b0c10fe512f60be5438adf5f757e4afa1bc75a984"
dependencies = [
"cargo-lock",
]
[[package]]
name = "cargo-lock"
version = "4.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8504b63dd1249fd1745b7b4ef9b6f7b107ddeb3c95370043c7dbcc38653a2679"
dependencies = [
"semver",
"serde",
"toml",
"url",
]
[[package]]
name = "form_urlencoded"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00"
dependencies = [
"matches",
"percent-encoding",
]
[[package]]
name = "idna"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
dependencies = [
"matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "matches"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]]
name = "percent-encoding"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2",
]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
"serde",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.118"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "syn"
version = "1.0.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "tinyvec"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f"
dependencies = [
"tinyvec_macros",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "toml"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645"
dependencies = [
"serde",
]
[[package]]
name = "unicode-bidi"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
dependencies = [
"matches",
]
[[package]]
name = "unicode-normalization"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606"
dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "url"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e"
dependencies = [
"form_urlencoded",
"idna",
"matches",
"percent-encoding",
]

View File

@ -0,0 +1,15 @@
[package]
name = "air-interpreter-wasm"
version = "0.0.8"
authors = ["Fluence Labs"]
description = "Distribution of AIR interpreter as .wasm"
license = "Apache-2.0"
edition = "2018"
include = [
"**/*.rs",
"Cargo.toml",
"aquamarine.wasm"
]
[build-dependencies]
built = "0.4.4"

View File

@ -0,0 +1,19 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
fn main() {
built::write_built_file().expect("Failed to acquire build-time information")
}

View File

@ -0,0 +1,7 @@
pub const INTERPRETER_WASM: &'static [u8] = include_bytes!("../aquamarine.wasm");
pub mod build_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
pub use build_info::PKG_VERSION as VERSION;