chore: release v1.0.0 (#951) #392
This file contains hidden or 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 PR | |
| 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 }} | |
| 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/release-plz-action@v0.5 | |
| id: release-plz | |
| with: | |
| command: release-pr | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_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 | |
| # this disables default behavior of `setup-rust-toolchain` to put `-D warnings` which overwrites `.cargo/config.toml` | |
| rustflags: "" | |
| - name: Install dependencies | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-pack@0.13.1 | |
| - 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: \"celestiaorg/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 |