-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): Automatic release to npmjs (#378)
Signed-off-by: Mikołaj Florkiewicz <[email protected]> Co-authored-by: Maciej Zwoliński <[email protected]>
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,80 @@ jobs: | |
- 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 }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} | ||
run: | | ||
node_wasm_version="$(cargo pkgid --manifest-path=node-wasm/Cargo.toml | cut -d@ -f 2)" | ||
cd node-wasm/js | ||
# Update the version of lumina-node-wasm dependency | ||
npm pkg set "dependencies[lumina-node-wasm]=$node_wasm_version" | ||
# Update lumina-node version | ||
npm version $node_wasm_version | ||
# push a commit to release-plz's pr | ||
# fetch the branch created by release-plz | ||
git fetch | ||
# prepare graphql query | ||
branch_name=${{ steps.release-plz.outputs.pr.head_branch }} | ||
branch_sha="$(git rev-parse "$branch_name")" | ||
package_json="$(base64 --wrap 0 package.json)" | ||
query='{"query": "mutation { | ||
createCommitOnBranch(input: { | ||
branch: { | ||
repositoryNameWithOwner: \"eigerco/lumina\", | ||
branchName: \"'"$branch_name"'\" | ||
}, | ||
message: { | ||
headline: \"update lumina-node npm package\" | ||
}, | ||
expectedHeadOid: \"'"$branch_sha"'\", | ||
fileChanges: { | ||
additions: [{ | ||
path: \"node-wasm/js/package.json\", | ||
contents: \"'"$package_json"'\" | ||
}] | ||
} | ||
}) | ||
{ commit { commitUrl } } | ||
}"}' | ||
# create new commit with changes | ||
curl 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')" | ||
- 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 --target web node-wasm | ||
# todo: uncomment on first release-plz pr | ||
# wasm-pack publish --target web --access public node-wasm | ||
# publish lumina-node | ||
cd node-wasm/js | ||
# todo: uncomment on first release-plz pr | ||
# npm publish --access public |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
/package-lock.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//registry.npmjs.org/:_authToken=${NPM_REGISTRY_TOKEN} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//registry.npmjs.org/:_authToken=${NPM_REGISTRY_TOKEN} |