feat(node)!: Implement NodeBuilder
and remove NodeConfig
(#472)
#166
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release-plz | |
permissions: | |
pull-requests: write | |
contents: write | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release-plz: | |
name: Release-plz | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.RELEASE_PLZ_TOKEN }} | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
version: "23.3" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install wasm-pack | |
uses: jetli/[email protected] | |
- name: Run release-plz | |
uses: MarcoIeni/[email protected] | |
id: release-plz | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Bump lumina-node npm version | |
if: steps.release-plz.outputs.prs_created == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} | |
run: | | |
set -eu | |
pr_branch_name="${{ fromJSON(steps.release-plz.outputs.pr).head_branch }}" | |
# switch to the branch created by release-plz | |
git fetch | |
git checkout "$pr_branch_name" | |
node_wasm_version="$(cargo pkgid --manifest-path=node-wasm/Cargo.toml | cut -d@ -f 2)" | |
cd node-wasm/js | |
# Update lumina-node version | |
if ! npm version $node_wasm_version >/dev/null; then | |
echo "Version up to date" | |
exit | |
fi | |
# Update the types definition for lumina-node | |
npm i | |
npm run tsc | |
# Update the readme for lumina-node | |
wasm-pack build .. | |
npm run update-readme | |
# Update the version of lumina-node-wasm dependency | |
npm pkg set "dependencies[lumina-node-wasm]=$node_wasm_version" | |
# push a commit to release-plz's pr | |
# prepare graphql query | |
branch_sha="$(git rev-parse "$pr_branch_name")" | |
package_json="$(base64 --wrap 0 package.json)" | |
readme="$(base64 --wrap 0 README.md)" | |
types_definitions="$(base64 --wrap 0 index.d.ts)" | |
query='{"query": "mutation { | |
createCommitOnBranch(input: { | |
branch: { | |
repositoryNameWithOwner: \"eigerco/lumina\", | |
branchName: \"'"$pr_branch_name"'\" | |
}, | |
message: { | |
headline: \"update lumina-node npm package\" | |
}, | |
expectedHeadOid: \"'"$branch_sha"'\", | |
fileChanges: { | |
additions: [ | |
{ | |
path: \"node-wasm/js/package.json\", | |
contents: \"'"$package_json"'\" | |
}, | |
{ | |
path: \"node-wasm/js/README.md\", | |
contents: \"'"$readme"'\" | |
}, | |
{ | |
path: \"node-wasm/js/index.d.ts\", | |
contents: \"'"$types_definitions"'\" | |
} | |
] | |
} | |
}) | |
{ commit { commitUrl } } | |
}"}' | |
# create new commit with changes | |
result=$(curl -sS https://api.github.com/graphql \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | |
--data "$(echo "$query" | tr -d '\n')") | |
if echo "$result" | jq -e '.errors | length != 0' >/dev/null; then | |
echo "Commit failed: $(echo "$result" | jq '.errors')" >&2 | |
exit 1 | |
else | |
echo "Version updated: ${node_wasm_version}" | |
fi | |
release-npm: | |
name: Release-npm | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.RELEASE_PLZ_TOKEN }} | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
version: "23.3" | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install wasm-pack | |
uses: jetli/[email protected] | |
- name: Release to npm | |
env: | |
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} | |
run: | | |
published_version=$(npm show lumina-node-wasm version) | |
local_version="$(cargo pkgid --manifest-path=node-wasm/Cargo.toml | cut -d@ -f 2)" | |
if [ "$published_version" == "$local_version" ] ; then | |
echo Latest version already in npm, exiting | |
exit | |
fi | |
# publish lumina-node-wasm | |
wasm-pack build node-wasm | |
wasm-pack publish --access public node-wasm | |
# publish lumina-node | |
cd node-wasm/js | |
npm publish --access public |