From 720923cc60d9efbf43fd185559a138dca8ea3365 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:59:16 +0800 Subject: [PATCH 01/17] manual node version-up --- .github/workflows/node-version-up.yml | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/node-version-up.yml diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml new file mode 100644 index 000000000..f1d6d781d --- /dev/null +++ b/.github/workflows/node-version-up.yml @@ -0,0 +1,55 @@ +name: Node Version Up + +on: + workflow_dispatch: + inputs: + versioning: + description: "node version up: major, minor, or patch" + required: true + default: "patch" + +jobs: + bump-version: + runs-on: ubuntu-latest + name: bump version + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup user + run: | + git config user.name github-actions + git config user.email github-actions@github.com + - name: install cargo-edit + run: | + cargo install cargo-edit + - name: set new version ${{ github.event.inputs.versioning }} + continue-on-error: false + run: | + cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node + - name: save updated version + id: new-version + run: | + cd node + echo "version=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')" >> "$GITHUB_OUTPUT" + cd .. + - name: save branch name + id: branch-name + run: | + echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" + - name: checkout to new version + run: | + git checkout -b ${{ steps.branch-name.outputs.branch_name }} + git add node/Cargo.toml + git commit -m "upgrade node to ${{ steps.new-version.outputs.version }}" + git push --set-upstream origin ${{ steps.branch-name.outputs.branch_name }} +# - name: Create Pull Request +# uses: peter-evans/create-pull-request@v6.1.0 +# with: +# base: "main" +# title: "release: upgrade node to ${{ steps.new-version.outputs.version }}" +# branch: "${{ steps.branch-name.outputs.branch_name }}" +# body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/main...release/upgrade-node-to-${{ steps.new-version.outputs.version}})" +# token: ${{ secrets.GITHUB_TOKEN }} + From 3d6f62a997fc55583266f3e3ffad462e03bffca6 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 14:01:55 +0800 Subject: [PATCH 02/17] test on PR first --- .github/workflows/node-version-up.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index f1d6d781d..44f0d4a96 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -7,6 +7,12 @@ on: description: "node version up: major, minor, or patch" required: true default: "patch" + pull_request: + branches: + - main + push: + branches: + - main jobs: bump-version: From 34c34722540f95cb798f1e97eb03e68df5f26bb2 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 14:07:40 +0800 Subject: [PATCH 03/17] test on PR first --- .github/workflows/node-version-up.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index 44f0d4a96..abafed234 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -30,10 +30,12 @@ jobs: - name: install cargo-edit run: | cargo install cargo-edit - - name: set new version ${{ github.event.inputs.versioning }} +# - name: set new version ${{ github.event.inputs.versioning }} + - name: set new version continue-on-error: false run: | - cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node + cargo set-version --bump patch --package pendulum-node +# cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node - name: save updated version id: new-version run: | From 2cc3608358b86334d081e058d0c82dd32392e96e Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:11:39 +0800 Subject: [PATCH 04/17] test signing of commit --- .github/workflows/node-version-up.yml | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index abafed234..bf44b2bdf 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -46,18 +46,24 @@ jobs: id: branch-name run: | echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" - - name: checkout to new version + git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} + - name: commit new version up + uses: swinton/commit@v2.x + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: + node/Cargo.toml + commit-message: "upgrade node to ${{ steps.new-version.outputs.version }}" + id: commit + - name: push commit run: | - git checkout -b ${{ steps.branch-name.outputs.branch_name }} - git add node/Cargo.toml - git commit -m "upgrade node to ${{ steps.new-version.outputs.version }}" git push --set-upstream origin ${{ steps.branch-name.outputs.branch_name }} -# - name: Create Pull Request -# uses: peter-evans/create-pull-request@v6.1.0 -# with: -# base: "main" -# title: "release: upgrade node to ${{ steps.new-version.outputs.version }}" -# branch: "${{ steps.branch-name.outputs.branch_name }}" -# body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/main...release/upgrade-node-to-${{ steps.new-version.outputs.version}})" -# token: ${{ secrets.GITHUB_TOKEN }} - + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6.1.0 + with: + base: "main" + title: "release: upgrade node to ${{ steps.new-version.outputs.version }}" + branch: "${{ steps.branch-name.outputs.branch_name }}" + body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/main...release/upgrade-node-to-${{ steps.new-version.outputs.version}})" + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 313320d544ea27ecbab9adb21945c25918f12f55 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:28:46 +0800 Subject: [PATCH 05/17] use chromeq/commit@v2.x --- .github/workflows/node-version-up.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index bf44b2bdf..8eff555e5 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -48,14 +48,13 @@ jobs: echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} - name: commit new version up - uses: swinton/commit@v2.x + uses: chromeq/commit@v2.x env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - files: + files: | node/Cargo.toml commit-message: "upgrade node to ${{ steps.new-version.outputs.version }}" - id: commit - name: push commit run: | git push --set-upstream origin ${{ steps.branch-name.outputs.branch_name }} From 4a68274d4948c95fe5e0942b8820f73489313692 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:51:11 +0800 Subject: [PATCH 06/17] revert to use swinton/commit --- .github/workflows/node-version-up.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index 8eff555e5..d13be5314 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -48,7 +48,8 @@ jobs: echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} - name: commit new version up - uses: chromeq/commit@v2.x + id: commit + uses: swinton/commit@v2.x env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From 7d064d23dcbb358e13d1a906fface35f3f068add Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:42:10 +0800 Subject: [PATCH 07/17] use back chromeq, but without the env --- .github/workflows/node-version-up.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index d13be5314..231cffee8 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -49,13 +49,14 @@ jobs: git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} - name: commit new version up id: commit - uses: swinton/commit@v2.x - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: chromeq/commit@v2.x +# env: +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: | node/Cargo.toml commit-message: "upgrade node to ${{ steps.new-version.outputs.version }}" + ref: refs/head/main - name: push commit run: | git push --set-upstream origin ${{ steps.branch-name.outputs.branch_name }} From 251509a82e1fa71a964d461fef50fced5dba3e68 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 4 Jul 2024 21:13:07 +0800 Subject: [PATCH 08/17] use graphql instead --- .github/workflows/node-version-up.yml | 43 +++++++++++---------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index 231cffee8..dc9ca846e 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -7,12 +7,6 @@ on: description: "node version up: major, minor, or patch" required: true default: "patch" - pull_request: - branches: - - main - push: - branches: - - main jobs: bump-version: @@ -30,12 +24,10 @@ jobs: - name: install cargo-edit run: | cargo install cargo-edit -# - name: set new version ${{ github.event.inputs.versioning }} - - name: set new version + - name: set new version ${{ github.event.inputs.versioning }} continue-on-error: false run: | - cargo set-version --bump patch --package pendulum-node -# cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node + cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node - name: save updated version id: new-version run: | @@ -47,24 +39,23 @@ jobs: run: | echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} + git push --set-upstream origin release/upgrade-node-to-${{ steps.new-version.outputs.version }} - name: commit new version up - id: commit - uses: chromeq/commit@v2.x -# env: -# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: | - node/Cargo.toml - commit-message: "upgrade node to ${{ steps.new-version.outputs.version }}" - ref: refs/head/main - - name: push commit run: | - git push --set-upstream origin ${{ steps.branch-name.outputs.branch_name }} + gh api graphql \ + -F githubRepository=${{ github.repository }} \ + -F branchName=${{ steps.branch-name.outputs.branch_name }} \ + -F expectedHeadOid=$(git rev-parse HEAD) \ + -F commitMessage="chore: node upgrade to ${{ steps.new-version.outputs.version }}" \ + -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ + -F 'query=@.github/api/createCommitOnBranch.gql' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ steps.branch-name.outputs.branch_name }} - name: Create Pull Request - uses: peter-evans/create-pull-request@v6.1.0 + uses: thomaseizinger/create-pull-request@master with: - base: "main" + github_token: ${{ secrets.GITHUB_TOKEN }} title: "release: upgrade node to ${{ steps.new-version.outputs.version }}" - branch: "${{ steps.branch-name.outputs.branch_name }}" - body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/main...release/upgrade-node-to-${{ steps.new-version.outputs.version}})" - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + head: ${{ steps.branch-name.outputs.branch_name }} + base: main \ No newline at end of file From acfe8b2360f0ecaa3f7b3de284fe57730118f1ed Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:08:58 +0800 Subject: [PATCH 09/17] add reviewers --- .github/workflows/node-version-up.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index dc9ca846e..638541d14 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -17,14 +17,14 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup user + - name: Setup User run: | git config user.name github-actions git config user.email github-actions@github.com - name: install cargo-edit run: | cargo install cargo-edit - - name: set new version ${{ github.event.inputs.versioning }} + - name: Set New Version ${{ github.event.inputs.versioning }} continue-on-error: false run: | cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node @@ -34,13 +34,13 @@ jobs: cd node echo "version=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')" >> "$GITHUB_OUTPUT" cd .. - - name: save branch name + - name: Create Release Branch for version ${{ steps.new-version.outputs.version }} id: branch-name run: | echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} git push --set-upstream origin release/upgrade-node-to-${{ steps.new-version.outputs.version }} - - name: commit new version up + - name: Commit New Changes to New Branch run: | gh api graphql \ -F githubRepository=${{ github.repository }} \ @@ -58,4 +58,5 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} title: "release: upgrade node to ${{ steps.new-version.outputs.version }}" head: ${{ steps.branch-name.outputs.branch_name }} - base: main \ No newline at end of file + base: main + reviewers: "ebma, TorstenStueber, bogdanS98, gianfra-t, b-yap" \ No newline at end of file From b208fa4de618cd598fc87b991336a1475d113562 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 20 Sep 2024 23:46:19 +0800 Subject: [PATCH 10/17] add commit list and release node workflow --- .github/workflows/node-version-up.yml | 5 +++-- .github/workflows/release-node.yml | 31 +++++++++++++++++++++++++++ script/get_commit.sh | 30 ++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release-node.yml create mode 100644 script/get_commit.sh diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml index 638541d14..4f4138f3f 100644 --- a/.github/workflows/node-version-up.yml +++ b/.github/workflows/node-version-up.yml @@ -32,7 +32,7 @@ jobs: id: new-version run: | cd node - echo "version=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version')" >> "$GITHUB_OUTPUT" + echo "version=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"')" >> "$GITHUB_OUTPUT" cd .. - name: Create Release Branch for version ${{ steps.new-version.outputs.version }} id: branch-name @@ -56,7 +56,8 @@ jobs: uses: thomaseizinger/create-pull-request@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - title: "release: upgrade node to ${{ steps.new-version.outputs.version }}" + title: "release: upgrade node to v${{ steps.new-version.outputs.version }}" + body: ${{ steps.new-version.outputs.version }} head: ${{ steps.branch-name.outputs.branch_name }} base: main reviewers: "ebma, TorstenStueber, bogdanS98, gianfra-t, b-yap" \ No newline at end of file diff --git a/.github/workflows/release-node.yml b/.github/workflows/release-node.yml new file mode 100644 index 000000000..f802edcc3 --- /dev/null +++ b/.github/workflows/release-node.yml @@ -0,0 +1,31 @@ +# This action triggers a GitLab CI job that generates the release notes +name: Node Release + +on: + pull_request: + types: + - closed + branches: + - 'main' + +jobs: + release_check: +# This job will only run if: +# * the pull request is closed and merged to main branch; +# * the pull request has the "release:" and "node" in its title + if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') && contains(github.event.pull_request.title, 'node') }} + name: Need new release + strategy: + fail-fast: true + runs-on: ubuntu-latest + + steps: + - name: trigger gitlab + uses: eic/trigger-gitlab-ci@v3 + with: + url: https://gitlab.com + project_id: + token: ${{ secrets.GITLABAPI }} + ref_name: main + variables: | + version= ${{ github.event.pull_request.body }} diff --git a/script/get_commit.sh b/script/get_commit.sh new file mode 100644 index 000000000..862c07366 --- /dev/null +++ b/script/get_commit.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + +versionNumber=$1 + +tagNamePrefix="node-release" +## get the latest tag of this node +lastVersionName=$(git describe --abbrev=0 --tags --always `git rev-list --tags` | grep -i "$tagNamePrefix" -m 1) + +## get the commits since the last tag +latestCommitOfLastVersion=$(git log $lastVersionName --oneline --max-count=1 | cut -c1-7) + + +logs=( $(git log $latestCommitOfLastVersion..origin/main --oneline -- node/ | cut -c1-7) ) + if (( ${#logs[@]} == 0 )); then + echo "Error: Repo is up to date. No new release required". + exit 1 + fi + +echo -e "## What's Changed\n" >> Commits.txt +## output the relevant commits, and save to file +echo "relevant commits:" +for commit in "${logs[@]}"; do + link="$(git log --format="[%h](https://github.com/pendulum-chain/pendulum/commit/%h) %s" -n 1 $commit)" + echo $link + echo -e "* "$link"\n" >> Commits.txt +done + +$newVersionName +echo "new version: "$tagNamePrefix"-"$versionNumber From 1869b0b9a80884fd095e1ad36420f60f71a2d8d0 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:10:03 +0800 Subject: [PATCH 11/17] add api and commit on: all, node, or all but the node --- .github/api/createCommitOnBranch.gql | 26 ++++ .github/workflows/node-version-up.yml | 63 --------- .github/workflows/version-up.yml | 186 ++++++++++++++++++++++++++ 3 files changed, 212 insertions(+), 63 deletions(-) create mode 100644 .github/api/createCommitOnBranch.gql delete mode 100644 .github/workflows/node-version-up.yml create mode 100644 .github/workflows/version-up.yml diff --git a/.github/api/createCommitOnBranch.gql b/.github/api/createCommitOnBranch.gql new file mode 100644 index 000000000..42dac31fb --- /dev/null +++ b/.github/api/createCommitOnBranch.gql @@ -0,0 +1,26 @@ +mutation ( + $githubRepository: String!, + $branchName: String!, + $expectedHeadOid: GitObjectID! + $commitMessage: String! + $files: [FileAddition!]! +) { + createCommitOnBranch( + input: { + branch: + { + repositoryNameWithOwner: $githubRepository, + branchName: $branchName + }, + message: {headline: $commitMessage}, + fileChanges: { + additions: $files + } + expectedHeadOid: $expectedHeadOid + } + ){ + commit { + url + } + } +} \ No newline at end of file diff --git a/.github/workflows/node-version-up.yml b/.github/workflows/node-version-up.yml deleted file mode 100644 index 4f4138f3f..000000000 --- a/.github/workflows/node-version-up.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Node Version Up - -on: - workflow_dispatch: - inputs: - versioning: - description: "node version up: major, minor, or patch" - required: true - default: "patch" - -jobs: - bump-version: - runs-on: ubuntu-latest - name: bump version - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup User - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - name: install cargo-edit - run: | - cargo install cargo-edit - - name: Set New Version ${{ github.event.inputs.versioning }} - continue-on-error: false - run: | - cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node - - name: save updated version - id: new-version - run: | - cd node - echo "version=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"')" >> "$GITHUB_OUTPUT" - cd .. - - name: Create Release Branch for version ${{ steps.new-version.outputs.version }} - id: branch-name - run: | - echo "branch_name=release/upgrade-node-to-${{ steps.new-version.outputs.version }}" >> "$GITHUB_OUTPUT" - git checkout -b release/upgrade-node-to-${{ steps.new-version.outputs.version }} - git push --set-upstream origin release/upgrade-node-to-${{ steps.new-version.outputs.version }} - - name: Commit New Changes to New Branch - run: | - gh api graphql \ - -F githubRepository=${{ github.repository }} \ - -F branchName=${{ steps.branch-name.outputs.branch_name }} \ - -F expectedHeadOid=$(git rev-parse HEAD) \ - -F commitMessage="chore: node upgrade to ${{ steps.new-version.outputs.version }}" \ - -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ - -F 'query=@.github/api/createCommitOnBranch.gql' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: ${{ steps.branch-name.outputs.branch_name }} - - name: Create Pull Request - uses: thomaseizinger/create-pull-request@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - title: "release: upgrade node to v${{ steps.new-version.outputs.version }}" - body: ${{ steps.new-version.outputs.version }} - head: ${{ steps.branch-name.outputs.branch_name }} - base: main - reviewers: "ebma, TorstenStueber, bogdanS98, gianfra-t, b-yap" \ No newline at end of file diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml new file mode 100644 index 000000000..cf3fd70e1 --- /dev/null +++ b/.github/workflows/version-up.yml @@ -0,0 +1,186 @@ +name: Version Up + +on: + workflow_dispatch: + inputs: + versioning: + type: choice + description: "choose versioning:" + required: true + options: + - major + - minor + - patch + - release + - rc + - beta + - alpha + default: "patch" + packages: + type: choice + description: "Version up the node only; other packages(except node), or ALL" + required: true + options: + - node + - others + - all + default: others + +jobs: + bump-version: + runs-on: ubuntu-latest + name: bump version + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup User + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + - name: install cargo-edit + run: | + cargo install cargo-edit + + - name: ${{ github.event.inputs.versioning }} version up for all + if: github.event.inputs.packages == 'all' + continue-on-error: false + run: | + cargo set-version --bump ${{ github.event.inputs.versioning }} &> changes.txt + cat changes.txt + + - name: ${{ github.event.inputs.versioning }} version up for all except the node + if: github.event.inputs.packages == 'others' + continue-on-error: false + run: | + cargo set-version --bump ${{ github.event.inputs.versioning }} --exclude pendulum-node &> changes.txt + cat changes.txt + + - name: ${{ github.event.inputs.versioning }} version up for node + if: github.event.inputs.packages == 'node' + continue-on-error: false + run: | + cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node &> changes.txt + cat changes.txt + + - name: "Read file contents" + id: read_file + uses: juliangruber/read-file-action@v1 + with: + path: ./changes.txt + + - name: Set Chosen Package + id: set-pkg + run: | + if [ ${{ github.event.inputs.packages }} == 'all' ]; then + echo "name=all" >> "$GITHUB_OUTPUT" + elif [ ${{ github.event.inputs.packages }} == 'node' ]; then + echo "name=node" >> "$GITHUB_OUTPUT" + else + echo "name=all-except-node" >> "$GITHUB_OUTPUT" + fi + + - name: Put current date into a variable + id: date-now + uses: Kaven-Universe/github-action-current-date-time@v1 + with: + format: "yyyy-MM-dd" + + - name: Create Release Branch + id: new-branch + run: | + name=${{ steps.set-pkg.outputs.name }} + now="${{ steps.date-now.outputs.day }}-${{ steps.date-now.outputs.month }}-${{ steps.date-now.outputs.year }}" + vers=${{ github.event.inputs.versioning }} + + branch_name="release/$vers-version-up-$name-$now" + echo "name=${branch_name}" >> "$GITHUB_OUTPUT" + + git checkout -b ${branch_name} + git push --set-upstream origin ${branch_name} + + # todo: make this simpler. + # from https://github.com/0xdbe/0xdbe.github.io/blob/main/_posts/2024-04-04-GitHub-SignCommitWorkflow.md + - name: Commit New Changes to New Branch (all) + if: github.event.inputs.packages == 'all' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ steps.new-branch.outputs.name }} + run: | + gh api graphql \ + -F githubRepository=${{ github.repository }} \ + -F branchName=${{ env.BRANCH }} \ + -F expectedHeadOid=$(git rev-parse HEAD) \ + -F commitMessage="$(cat changes.txt)" \ + -F files[][path]="chain-extensions/common/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/common/Cargo.toml) \ + -F files[][path]="chain-extensions/price/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/price/Cargo.toml) \ + -F files[][path]="chain-extensions/token/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/token/Cargo.toml) \ + -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ + -F files[][path]="pallets/orml-currencies-allowance-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-currencies-allowance-extension/Cargo.toml) \ + -F files[][path]="pallets/orml-tokens-management-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-tokens-management-extension/Cargo.toml) \ + -F files[][path]="pallets/parachain-staking/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/Cargo.toml) \ + -F files[][path]="pallets/parachain-staking/rpc/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/Cargo.toml) \ + -F files[][path]="pallets/parachain-staking/rpc/runtime-api/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/runtime-api/Cargo.toml) \ + -F files[][path]="pallets/treasury-buyout-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/treasury-buyout-extension/Cargo.toml) \ + -F files[][path]="pallets/vesting-manager/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/vesting-manager/Cargo.toml) \ + -F files[][path]="runtime/amplitude/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/amplitude/Cargo.toml) \ + -F files[][path]="runtime/common/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/common/Cargo.toml) \ + -F files[][path]="runtime/foucoco/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/foucoco/Cargo.toml) \ + -F files[][path]="runtime/integration-tests/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/integration-tests/Cargo.toml) \ + -F files[][path]="runtime/pendulum/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/pendulum/Cargo.toml) \ + -F 'query=@.github/api/createCommitOnBranch.gql' + + - name: Commit New Changes to New Branch (all except Node) + if: github.event.inputs.packages == 'others' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ steps.new-branch.outputs.name }} + run: | + gh api graphql \ + -F githubRepository=${{ github.repository }} \ + -F branchName=${{ env.BRANCH }} \ + -F expectedHeadOid=$(git rev-parse HEAD) \ + -F commitMessage="$(cat changes.txt)" \ + -F files[][path]="chain-extensions/common/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/common/Cargo.toml) \ + -F files[][path]="chain-extensions/price/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/price/Cargo.toml) \ + -F files[][path]="chain-extensions/token/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/token/Cargo.toml) \ + -F files[][path]="pallets/orml-currencies-allowance-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-currencies-allowance-extension/Cargo.toml) \ + -F files[][path]="pallets/orml-tokens-management-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-tokens-management-extension/Cargo.toml) \ + -F files[][path]="pallets/parachain-staking/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/Cargo.toml) \ + -F files[][path]="pallets/parachain-staking/rpc/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/Cargo.toml) \ + -F files[][path]="pallets/parachain-staking/rpc/runtime-api/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/runtime-api/Cargo.toml) \ + -F files[][path]="pallets/treasury-buyout-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/treasury-buyout-extension/Cargo.toml) \ + -F files[][path]="pallets/vesting-manager/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/vesting-manager/Cargo.toml) \ + -F files[][path]="runtime/amplitude/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/amplitude/Cargo.toml) \ + -F files[][path]="runtime/common/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/common/Cargo.toml) \ + -F files[][path]="runtime/foucoco/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/foucoco/Cargo.toml) \ + -F files[][path]="runtime/integration-tests/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/integration-tests/Cargo.toml) \ + -F files[][path]="runtime/pendulum/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/pendulum/Cargo.toml) \ + -F 'query=@.github/api/createCommitOnBranch.gql' + + - name: Commit New Changes to New Branch (node) + if: github.event.inputs.packages == 'node' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ steps.new-branch.outputs.name }} + run: | + gh api graphql \ + -F githubRepository=${{ github.repository }} \ + -F branchName=${{ env.BRANCH }} \ + -F expectedHeadOid=$(git rev-parse HEAD) \ + -F commitMessage="$(cat changes.txt)" \ + -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ + -F 'query=@.github/api/createCommitOnBranch.gql' + + - name: Create Pull Request + uses: thomaseizinger/create-pull-request@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + title: "release: ${{ github.event.inputs.versioning }} version up ${{ steps.set-pkg.outputs.name }}" + body: "${{ steps.read_file.outputs.content }}" + head: ${{ steps.new-branch.outputs.name }} + base: main + reviewers: "ebma, TorstenStueber, bogdanS98, gianfra-t, b-yap" \ No newline at end of file From 1fa7676aa85b0a0dc5bd86b9b0bfe3e59e4e57b8 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 3 Oct 2024 01:16:12 +0800 Subject: [PATCH 12/17] add a script to specify a specifiv version number to upgrade the crates --- .github/scripts/specific_version_up.sh | 12 +++ .github/workflows/version-up.yml | 108 +++++++++++-------------- 2 files changed, 60 insertions(+), 60 deletions(-) create mode 100755 .github/scripts/specific_version_up.sh diff --git a/.github/scripts/specific_version_up.sh b/.github/scripts/specific_version_up.sh new file mode 100755 index 000000000..edc544a7b --- /dev/null +++ b/.github/scripts/specific_version_up.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +# define the version number we want to set +newVersion=$1 + +# Find all Cargo.toml files in the current directory and its subdirectories +for file in $(find . -name "Cargo.toml") +do + # Use awk to change the version number of the package + awk -v newVersion="$newVersion" -F'=' '/\[package\]/,/version =/ { if($0 ~ /version =/ && $0 !~ /#/) {print $1 "= ""\""newVersion"\""; next} }1' $file > temp && mv temp $file +done \ No newline at end of file diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml index cf3fd70e1..9e544ef18 100644 --- a/.github/workflows/version-up.yml +++ b/.github/workflows/version-up.yml @@ -6,7 +6,6 @@ on: versioning: type: choice description: "choose versioning:" - required: true options: - major - minor @@ -15,16 +14,14 @@ on: - rc - beta - alpha - default: "patch" - packages: - type: choice - description: "Version up the node only; other packages(except node), or ALL" - required: true - options: - - node - - others - - all - default: others + specific_version: + type: string + description: "specific version to bump to" + packages-all: + description: "Check if you want ALL packages to be updated. Else, only pendulum-node" + required: false + type: boolean + default: true jobs: bump-version: @@ -45,22 +42,25 @@ jobs: run: | cargo install cargo-edit - - name: ${{ github.event.inputs.versioning }} version up for all - if: github.event.inputs.packages == 'all' - continue-on-error: false + - name: Check For Specific Version + if: github.event.inputs.specific_version != '' run: | - cargo set-version --bump ${{ github.event.inputs.versioning }} &> changes.txt - cat changes.txt + bash .github/scripts/specific_version_up ${{ github.event.inputs.specific_version }} + if ${{ github.event.inputs.packages-all }} == 'true'; then + echo "Upgrading crates to ${{ github.event.inputs.specific_version }}" &> changes.txt + else + echo "Upgrading node to ${{ github.event.inputs.specific_version }}" &> changes.txt + fi - - name: ${{ github.event.inputs.versioning }} version up for all except the node - if: github.event.inputs.packages == 'others' + - name: ${{ github.event.inputs.versioning }} Version Up for all + if: github.event.inputs.specific_version == '' && github.event.inputs.packages-all == 'true' continue-on-error: false run: | - cargo set-version --bump ${{ github.event.inputs.versioning }} --exclude pendulum-node &> changes.txt + cargo set-version --bump ${{ github.event.inputs.versioning }} &> changes.txt cat changes.txt - - name: ${{ github.event.inputs.versioning }} version up for node - if: github.event.inputs.packages == 'node' + - name: ${{ github.event.inputs.versioning }} Version Up for node + if: github.event.inputs.specific_version == '' && github.event.inputs.packages-all == 'false' continue-on-error: false run: | cargo set-version --bump ${{ github.event.inputs.versioning }} --package pendulum-node &> changes.txt @@ -75,12 +75,10 @@ jobs: - name: Set Chosen Package id: set-pkg run: | - if [ ${{ github.event.inputs.packages }} == 'all' ]; then + if [ ${{ github.event.inputs.packages-all }} == 'true' ]; then echo "name=all" >> "$GITHUB_OUTPUT" - elif [ ${{ github.event.inputs.packages }} == 'node' ]; then - echo "name=node" >> "$GITHUB_OUTPUT" else - echo "name=all-except-node" >> "$GITHUB_OUTPUT" + echo "name=node" >> "$GITHUB_OUTPUT" fi - name: Put current date into a variable @@ -94,18 +92,24 @@ jobs: run: | name=${{ steps.set-pkg.outputs.name }} now="${{ steps.date-now.outputs.day }}-${{ steps.date-now.outputs.month }}-${{ steps.date-now.outputs.year }}" - vers=${{ github.event.inputs.versioning }} - branch_name="release/$vers-version-up-$name-$now" + if [ '${{ github.event.inputs.specific_version }}' != '' ]; then + echo "specific version: ${{ github.event.inputs.specific_version }}" + branch_name="release/version-up-to-${{ github.event.inputs.specific_version }}-$name-$now" + else + vers=${{ github.event.inputs.versioning }} + echo "versioning: ${{ github.event.inputs.versioning }}" + branch_name="release/$vers-version-up-$name-$now" + fi + echo "name=${branch_name}" >> "$GITHUB_OUTPUT" git checkout -b ${branch_name} git push --set-upstream origin ${branch_name} - # todo: make this simpler. - # from https://github.com/0xdbe/0xdbe.github.io/blob/main/_posts/2024-04-04-GitHub-SignCommitWorkflow.md + # todo: make this simpler. - name: Commit New Changes to New Branch (all) - if: github.event.inputs.packages == 'all' + if: github.event.inputs.packages-all == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: ${{ steps.new-branch.outputs.name }} @@ -133,36 +137,8 @@ jobs: -F files[][path]="runtime/pendulum/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/pendulum/Cargo.toml) \ -F 'query=@.github/api/createCommitOnBranch.gql' - - name: Commit New Changes to New Branch (all except Node) - if: github.event.inputs.packages == 'others' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: ${{ steps.new-branch.outputs.name }} - run: | - gh api graphql \ - -F githubRepository=${{ github.repository }} \ - -F branchName=${{ env.BRANCH }} \ - -F expectedHeadOid=$(git rev-parse HEAD) \ - -F commitMessage="$(cat changes.txt)" \ - -F files[][path]="chain-extensions/common/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/common/Cargo.toml) \ - -F files[][path]="chain-extensions/price/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/price/Cargo.toml) \ - -F files[][path]="chain-extensions/token/Cargo.toml" -F files[][contents]=$(base64 -w0 chain-extensions/token/Cargo.toml) \ - -F files[][path]="pallets/orml-currencies-allowance-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-currencies-allowance-extension/Cargo.toml) \ - -F files[][path]="pallets/orml-tokens-management-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/orml-tokens-management-extension/Cargo.toml) \ - -F files[][path]="pallets/parachain-staking/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/Cargo.toml) \ - -F files[][path]="pallets/parachain-staking/rpc/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/Cargo.toml) \ - -F files[][path]="pallets/parachain-staking/rpc/runtime-api/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/parachain-staking/rpc/runtime-api/Cargo.toml) \ - -F files[][path]="pallets/treasury-buyout-extension/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/treasury-buyout-extension/Cargo.toml) \ - -F files[][path]="pallets/vesting-manager/Cargo.toml" -F files[][contents]=$(base64 -w0 pallets/vesting-manager/Cargo.toml) \ - -F files[][path]="runtime/amplitude/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/amplitude/Cargo.toml) \ - -F files[][path]="runtime/common/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/common/Cargo.toml) \ - -F files[][path]="runtime/foucoco/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/foucoco/Cargo.toml) \ - -F files[][path]="runtime/integration-tests/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/integration-tests/Cargo.toml) \ - -F files[][path]="runtime/pendulum/Cargo.toml" -F files[][contents]=$(base64 -w0 runtime/pendulum/Cargo.toml) \ - -F 'query=@.github/api/createCommitOnBranch.gql' - - name: Commit New Changes to New Branch (node) - if: github.event.inputs.packages == 'node' + if: github.event.inputs.packages-all == 'false' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: ${{ steps.new-branch.outputs.name }} @@ -175,7 +151,19 @@ jobs: -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ -F 'query=@.github/api/createCommitOnBranch.gql' + - name: Create Pull Request for Specific Version + if: github.event.inputs.specific_version != '' + uses: thomaseizinger/create-pull-request@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + title: "release: Force version up ${{ steps.set-pkg.outputs.name }}" + body: "${{ steps.read_file.outputs.content }}" + head: ${{ steps.new-branch.outputs.name }} + base: main + reviewers: "pendulum-chain/devs" + - name: Create Pull Request + if: github.event.inputs.specific_version == '' uses: thomaseizinger/create-pull-request@master with: github_token: ${{ secrets.GITHUB_TOKEN }} @@ -183,4 +171,4 @@ jobs: body: "${{ steps.read_file.outputs.content }}" head: ${{ steps.new-branch.outputs.name }} base: main - reviewers: "ebma, TorstenStueber, bogdanS98, gianfra-t, b-yap" \ No newline at end of file + reviewers: "pendulum-chain/devs" \ No newline at end of file From 7991442c25204fd2f310138aeb72d3c58321d31d Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Tue, 8 Oct 2024 17:24:11 +0800 Subject: [PATCH 13/17] https://github.com/pendulum-chain/pendulum/pull/485#discussion_r1787784475 --- .github/workflows/release-node.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-node.yml b/.github/workflows/release-node.yml index f802edcc3..454385e67 100644 --- a/.github/workflows/release-node.yml +++ b/.github/workflows/release-node.yml @@ -13,7 +13,7 @@ jobs: # This job will only run if: # * the pull request is closed and merged to main branch; # * the pull request has the "release:" and "node" in its title - if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release:') && contains(github.event.pull_request.title, 'node') }} + if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release node:') }} name: Need new release strategy: fail-fast: true From f8250f25a1141c4b667c18868364fc89a0fa0f6b Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:08:17 +0800 Subject: [PATCH 14/17] add label on newly created PR; use that label for triggering the release yml --- ...ic_version_up.sh => package_version_up.sh} | 0 .github/workflows/release-node.yml | 4 +- .github/workflows/version-up.yml | 37 +++++++++++-------- 3 files changed, 23 insertions(+), 18 deletions(-) rename .github/scripts/{specific_version_up.sh => package_version_up.sh} (100%) diff --git a/.github/scripts/specific_version_up.sh b/.github/scripts/package_version_up.sh similarity index 100% rename from .github/scripts/specific_version_up.sh rename to .github/scripts/package_version_up.sh diff --git a/.github/workflows/release-node.yml b/.github/workflows/release-node.yml index 454385e67..27b10fb74 100644 --- a/.github/workflows/release-node.yml +++ b/.github/workflows/release-node.yml @@ -12,8 +12,8 @@ jobs: release_check: # This job will only run if: # * the pull request is closed and merged to main branch; -# * the pull request has the "release:" and "node" in its title - if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.title, 'release node:') }} +# * the pull request has the label "release-node" + if: ${{ github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release-node') }} name: Need new release strategy: fail-fast: true diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml index 9e544ef18..8c176df57 100644 --- a/.github/workflows/version-up.yml +++ b/.github/workflows/version-up.yml @@ -39,13 +39,14 @@ jobs: git config user.email github-actions@github.com - name: install cargo-edit + if: github.event.inputs.specific_version != '' run: | cargo install cargo-edit - name: Check For Specific Version if: github.event.inputs.specific_version != '' run: | - bash .github/scripts/specific_version_up ${{ github.event.inputs.specific_version }} + bash .github/scripts/package_version_up ${{ github.event.inputs.specific_version }} if ${{ github.event.inputs.packages-all }} == 'true'; then echo "Upgrading crates to ${{ github.event.inputs.specific_version }}" &> changes.txt else @@ -67,7 +68,7 @@ jobs: cat changes.txt - name: "Read file contents" - id: read_file + id: read-file uses: juliangruber/read-file-action@v1 with: path: ./changes.txt @@ -151,24 +152,28 @@ jobs: -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ -F 'query=@.github/api/createCommitOnBranch.gql' - - name: Create Pull Request for Specific Version - if: github.event.inputs.specific_version != '' - uses: thomaseizinger/create-pull-request@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - title: "release: Force version up ${{ steps.set-pkg.outputs.name }}" - body: "${{ steps.read_file.outputs.content }}" - head: ${{ steps.new-branch.outputs.name }} - base: main - reviewers: "pendulum-chain/devs" + - name: Prepare Pull Request title and labels + id: pr-title-labels + run: | + if ${{ github.event.inputs.packages-all }} == 'true'; then + echo "label=release-node,release-amplitude,release-pendulum" >> "$GITHUB_OUTPUT" + else + echo "label=release-node" >> "$GITHUB_OUTPUT" + fi + + if ${{ github.event.inputs.specific_version }} == ''; then + echo "title=release: ${{ github.event.inputs.versioning }} version up ${{ steps.set-pkg.outputs.name }}" >> "$GITHUB_OUTPUT" + else + echo "title=release: Force version up ${{ steps.set-pkg.outputs.name }}" >> "$GITHUB_OUTPUT" + fi - name: Create Pull Request - if: github.event.inputs.specific_version == '' uses: thomaseizinger/create-pull-request@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - title: "release: ${{ github.event.inputs.versioning }} version up ${{ steps.set-pkg.outputs.name }}" - body: "${{ steps.read_file.outputs.content }}" + title: ${{ steps.pr-title-labels.outputs.title }} + body: ${{ steps.read-file.outputs.content }} head: ${{ steps.new-branch.outputs.name }} base: main - reviewers: "pendulum-chain/devs" \ No newline at end of file + reviewers: "pendulum-chain/devs" + labels: ${{ steps.pr-title-labels.outputs.label }} \ No newline at end of file From 853f31994eea2155f182f547316b38657967374a Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:22:53 +0800 Subject: [PATCH 15/17] add comments to easily understand the workflow --- .github/scripts/runtime_version_up.sh | 18 ++++++++++++++++++ .github/workflows/version-up.yml | 8 +++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 .github/scripts/runtime_version_up.sh diff --git a/.github/scripts/runtime_version_up.sh b/.github/scripts/runtime_version_up.sh new file mode 100755 index 000000000..a0735b5d5 --- /dev/null +++ b/.github/scripts/runtime_version_up.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +runtime=$1 +versionName=$2 + +if [ $runtime == "amplitude" ]; then + file="runtime/amplitude/src/lib.rs" +elif [ $runtime == "pendulum" ]; then + file="runtime/pendulum/src/lib.rs" +fi + +echo "increment: $versionName" +# Use awk to increment the version of the lib +awk -v pat="$versionName" -F':' '$0~pat { {print $1": " $2+1","; next} }1' $file > temp && mv temp $file + + + diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml index 8c176df57..85e9674ef 100644 --- a/.github/workflows/version-up.yml +++ b/.github/workflows/version-up.yml @@ -16,9 +16,9 @@ on: - alpha specific_version: type: string - description: "specific version to bump to" + description: "Specific version to bump to. If specified, the versioning input will be ignored" packages-all: - description: "Check if you want ALL packages to be updated. Else, only pendulum-node" + description: "Check if ALL packages will be updated. Else, only pendulum-node" required: false type: boolean default: true @@ -38,8 +38,9 @@ jobs: git config user.name github-actions git config user.email github-actions@github.com + # Install cargo-edit if specific version is NOT provided - name: install cargo-edit - if: github.event.inputs.specific_version != '' + if: github.event.inputs.specific_version == '' run: | cargo install cargo-edit @@ -154,6 +155,7 @@ jobs: - name: Prepare Pull Request title and labels id: pr-title-labels + # if all packages are updated, then add all labels run: | if ${{ github.event.inputs.packages-all }} == 'true'; then echo "label=release-node,release-amplitude,release-pendulum" >> "$GITHUB_OUTPUT" From 03b82aecd89d7c1d3122056c094bcedd2b7acc5a Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:41:08 +0800 Subject: [PATCH 16/17] https://github.com/pendulum-chain/pendulum/pull/485#discussion_r1793554632 --- .github/workflows/version-up.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/version-up.yml b/.github/workflows/version-up.yml index 85e9674ef..41a956471 100644 --- a/.github/workflows/version-up.yml +++ b/.github/workflows/version-up.yml @@ -153,16 +153,9 @@ jobs: -F files[][path]="node/Cargo.toml" -F files[][contents]=$(base64 -w0 node/Cargo.toml) \ -F 'query=@.github/api/createCommitOnBranch.gql' - - name: Prepare Pull Request title and labels - id: pr-title-labels - # if all packages are updated, then add all labels + - name: Prepare Pull Request title + id: pr-title run: | - if ${{ github.event.inputs.packages-all }} == 'true'; then - echo "label=release-node,release-amplitude,release-pendulum" >> "$GITHUB_OUTPUT" - else - echo "label=release-node" >> "$GITHUB_OUTPUT" - fi - if ${{ github.event.inputs.specific_version }} == ''; then echo "title=release: ${{ github.event.inputs.versioning }} version up ${{ steps.set-pkg.outputs.name }}" >> "$GITHUB_OUTPUT" else @@ -173,9 +166,9 @@ jobs: uses: thomaseizinger/create-pull-request@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - title: ${{ steps.pr-title-labels.outputs.title }} + title: ${{ steps.pr-title.outputs.title }} body: ${{ steps.read-file.outputs.content }} head: ${{ steps.new-branch.outputs.name }} base: main reviewers: "pendulum-chain/devs" - labels: ${{ steps.pr-title-labels.outputs.label }} \ No newline at end of file + labels: release-node \ No newline at end of file From e583182e41151af03acb4a07378646e7598b99ba Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:33:28 +0800 Subject: [PATCH 17/17] execute gitlab --- .github/workflows/release-node.yml | 24 ++++++++++++++++-------- Cargo.toml | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-node.yml b/.github/workflows/release-node.yml index 27b10fb74..a62eb4ac4 100644 --- a/.github/workflows/release-node.yml +++ b/.github/workflows/release-node.yml @@ -20,12 +20,20 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Get Node Version + id: get-version + run: | + vers=$( cargo metadata --format-version=1 --no-deps | jq '.packages[] | select(.name == "pendulum-node") | .version' | tr -d '"' ) + echo "version=${vers}" >> "$GITHUB_OUTPUT" + - name: trigger gitlab - uses: eic/trigger-gitlab-ci@v3 - with: - url: https://gitlab.com - project_id: - token: ${{ secrets.GITLABAPI }} - ref_name: main - variables: | - version= ${{ github.event.pull_request.body }} + run: | + ls ${{ github.workspace }} + curl -X POST -F token=${{ secrets.GITLAB_TRIGGER }} -F "ref=development" -F "variables[PREPCOMPILE]=Y" \ + -F "variables[COMPILE]=Y" -F "variables[COMPILEMOONBEAM]=N" -F "variables[DOCKER]=Y" \ + -F "variables[DOCKERAMP]=Y" -F "variables[DEBIAN]=Y" -F "variables[TEMPUPLOAD]=Y" \ + -F "variables[DOWNUPLOAD]=Y" -F "variables[PRODUPLOAD]=Y" -F "variables[VERSION]=${{ steps.get-version.outputs.version }}" \ + https://gitlab.com/api/v4/projects/${{ secrets.PROJECT_ID }}/trigger/pipeline diff --git a/Cargo.toml b/Cargo.toml index dc0ab9f75..e72ef1471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ panic = "unwind" inherits = "release" [workspace] +resolver = "2" members = [ "node", "pallets/parachain-staking",