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

ci: add an action to update versions and changelogs #380

Merged
merged 6 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Update versions and changelogs

on:
create:
branches:
- rc/v*

jobs:
default:
name: Update versions and changelogs
runs-on: ubuntu-latest
permissions:
pull-requests: write # for opening PR
contents: write # for commit
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x

# this is a patch for incompatibility between lerna@7 and npm@9 https://github.com/lerna/lerna/issues/3418#issuecomment-1337756237
- name: Remove lock file
run: rm package-lock.json

- name: Get version number
id: version-number
run: |
branch_name=${{ github.ref_name }}

version_number=${branch_name#rc/v}
echo "version_number=${version_number}" >> $GITHUB_OUTPUT

- name: Update versions and changelogs
id: changelog
run: |
npm run bump-version ${{ steps.version-number.outputs.version_number }}

git add CHANGELOG.md
changelog=$(git diff HEAD CHANGELOG.md | tail -n +7 | cut -c 2-)
echo -e "changelog<<EOF"$'\n'"$changelog"$'\n'EOF >> $GITHUB_OUTPUT

- name: Set GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Open PR to rc branch
uses: peter-evans/create-pull-request@v5
with:
title: Update versions and changelogs for ${{ steps.version-number.outputs.version_number }}
commit-message: 'chore: update versions and changelogs'
body: ${{ steps.changelog.outputs.changelog }}
committer: Chen Yu <[email protected]>
branch: chore-update-version-for-${{ github.ref_name }}
add-paths: ':!package-lock.json'
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"command": {
"version": {
"message": "chore: update versions and changelogs",
"conventionalCommits": true,
"exact": true
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"lint": "eslint 'packages/*/{src,__tests__}/**/*.ts'",
"prepare": "husky install",
"format:check": "prettier -cu packages/**/src/*",
"format:write": "prettier -wu packages/**/src/*"
"format:write": "prettier -wu packages/**/src/*",
"bump-version": "npx lerna version --no-git-tag-version --no-private --no-push --sign-git-commit --yes"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "6.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/samples/mvp-dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "kuai-mvp-dapp",
"private": true,
"scripts": {
"dev": "ts-node src/main.ts",
"build": "tsc",
Expand Down
1 change: 1 addition & 0 deletions packages/typeorm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Inject TypeOrm by InversifyJs",
"author": "felicityin <[email protected]>",
"homepage": "https://github.com/ckb-js/kuai#readme",
"private": true,
"license": "MIT",
"main": "lib/index.js",
"directories": {
Expand Down