Skip to content

feat(node)!: Replace Store::remove_tail with Store::remove_height #206

feat(node)!: Replace Store::remove_tail with Store::remove_height

feat(node)!: Replace Store::remove_tail with Store::remove_height #206

Workflow file for this run

name: Release-plz
permissions:
pull-requests: write
contents: write
on:
push:
branches:
- main
jobs:
release-plz:
name: Release-plz
runs-on: ubuntu-latest
outputs:
pr: ${{ steps.release-plz.outputs.pr }}
prs_created: ${{ steps.release-plz.outputs.prs_created }}
releases: ${{ steps.release-plz.outputs.releases }}
releases_created: ${{ steps.release-plz.outputs.releases_created }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- 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 }}
release-plz-pr-npm-update:
name: Update release PR for npm
runs-on: ubuntu-latest
needs:
- release-plz
if: success() && needs.release-plz.outputs.prs_created == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
- name: Install dependencies
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Bump lumina-node npm version
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
run: |
set -xeuo pipefail
pr_branch_name="${{ fromJSON(needs.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
wasm-pack build ..
# Update lockfile with new node-wasm version
npm install --save ../pkg
npm clean-install
# Update the types definition for lumina-node
npm run tsc
# Update the readme for lumina-node
npm run update-readme
# 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)"
package_lock_json="$(base64 --wrap 0 package-lock.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/package-lock.json\",
contents: \"'"$package_lock_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=$(echo "$query" | tr -d '\n' |
curl -sS https://api.github.com/graphql \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
--data @-)
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
needs:
- release-plz
if: success() && needs.release-plz.outputs.releases_created == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: wasm32-unknown-unknown
- name: Install dependencies
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Release to npm
env:
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
run: |
set -xeuo pipefail
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
# replace dependency on node-wasm from path based to version in npm
npm pkg set "dependencies[lumina-node-wasm]=$local_version"
npm publish --access public
release-uniffi:
name: Release-uniffi
runs-on: macos-latest
needs:
- release-plz
if: >-
${{
success()
&& contains(
fromJSON(needs.release-plz.outputs.releases).*.package_name,
'lumina-node-uniffi'
)
}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: "\
aarch64-apple-ios,\
aarch64-apple-ios-sim,\
aarch64-linux-android,\
armv7-linux-androideabi,\
x86_64-linux-android,\
i686-linux-android"
- name: Install cargo-ndk
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: [email protected]
- name: Build node-uniffi for ios
run: |
set -xeuo pipefail
./node-uniffi/build-ios.sh
tar -cvzf lumina-node-uniffi-ios.tar.gz -C node-uniffi ios
- name: Build node-uniffi for android
run: |
set -xeuo pipefail
./node-uniffi/build-android.sh
tar -cvzf lumina-node-uniffi-android.tar.gz -C node-uniffi app
- name: Publish artifacts to release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
RELEASES: ${{ needs.release-plz.outputs.releases }}
run: |
set -xeuo pipefail
tag="$(echo "$RELEASES" | jq '.[] | select(.package_name == "lumina-node-uniffi").tag')"
brew install coreutils
sha256sum lumina-node-uniffi-* > lumina-node-uniffi-sha256-checksums.txt
gh release upload "$tag" lumina-node-uniffi-*