From fa700aab95caa0e044eb8561ccdecfcfda2bdac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Zwoli=C5=84ski?= Date: Tue, 24 Sep 2024 12:30:01 +0200 Subject: [PATCH] chore: fix lumina-node npm version bump on ci (#386) --- .github/workflows/release-plz.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-plz.yml b/.github/workflows/release-plz.yml index 941d78c4..55a544c3 100644 --- a/.github/workflows/release-plz.yml +++ b/.github/workflows/release-plz.yml @@ -44,18 +44,24 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} run: | - pr_branch_name=${{ steps.release-plz.outputs.pr.head_branch }} + 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" - # Update the version of lumina-node-wasm dependency node_wasm_version="$(cargo pkgid --manifest-path=node-wasm/Cargo.toml | cut -d@ -f 2)" cd node-wasm/js - npm pkg set "dependencies[lumina-node-wasm]=$node_wasm_version" + # Update lumina-node version - npm version $node_wasm_version + if ! npm version $node_wasm_version >/dev/null; then + echo "Version up to date" + exit + fi + # 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 @@ -81,11 +87,18 @@ jobs: { commit { commitUrl } } }"}' # create new commit with changes - curl https://api.github.com/graphql \ + 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')" + --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 - name: Release to npm env: