Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to automatically create new node release #485

Merged
merged 20 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/node-version-up.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Node Version Up

on:
workflow_dispatch:
inputs:
versioning:
description: "node version up: major, minor, or patch"
ebma marked this conversation as resolved.
Show resolved Hide resolved
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 [email protected]
- 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
ebma marked this conversation as resolved.
Show resolved Hide resolved
- 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 '[email protected]/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"
31 changes: 31 additions & 0 deletions .github/workflows/release-node.yml
Original file line number Diff line number Diff line change
@@ -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') }}
ebma marked this conversation as resolved.
Show resolved Hide resolved
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 }}
30 changes: 30 additions & 0 deletions script/get_commit.sh
Original file line number Diff line number Diff line change
@@ -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
Loading