-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: add workflow for creating pull request for release * ci: remove function for generating changelog from check_pr * ci: changed to include change log in release notes
- Loading branch information
Showing
4 changed files
with
168 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,25 @@ jobs: | |
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/[email protected] | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Generate changelog | ||
run: | | ||
pnpm run changelog -c github | ||
pnpm exec prettier --write CHANGELOG.md | ||
- name: Create Release | ||
id: create_release | ||
|
@@ -91,3 +110,4 @@ jobs: | |
release_name: ${{ github.ref_name }} | ||
draft: true | ||
prerelease: false | ||
body_path: CHANGELOG.md |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
name: Bump Version | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version-type: | ||
description: 'Select version type' | ||
required: true | ||
default: 'patch' | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
|
||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com' | ||
GH_USER: 'github-actions[bot]' | ||
|
||
jobs: | ||
bump-version: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
env: | ||
VERSION_TYPE: ${{ github.event.inputs.version-type }} | ||
steps: | ||
- run: | | ||
git config --global user.name "${GH_USER}" | ||
git config --global user.email "${GH_EMAIL}" | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/[email protected] | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Display selected version type | ||
run: echo "Selected version type-> ${VERSION_TYPE}" | ||
|
||
# You can add your own logic here based on the selected version type | ||
- name: Bump version based on input | ||
run: | | ||
case "${VERSION_TYPE}" in | ||
major) | ||
echo "Bumping major version" | ||
pnpm version major --no-commit-hooks --no-git-tag-version | ||
;; | ||
minor) | ||
echo "Bumping minor version" | ||
pnpm version minor --no-commit-hooks --no-git-tag-version | ||
;; | ||
patch) | ||
echo "Bumping patch version" | ||
pnpm version minor --no-commit-hooks --no-git-tag-version | ||
;; | ||
esac | ||
- name: Parse package.json | ||
id: identify-version | ||
run: | | ||
APP_VERSION="$(cat ./package.json |jq .version|sed -e 's/"//g'| head -n1)" | ||
if [ ! -n "${APP_VERSION}" ]; then | ||
exit 255 | ||
fi | ||
echo "Detected the version: ${APP_VERSION}" | ||
echo "app-version=${APP_VERSION}" >>"${GITHUB_OUTPUT}" | ||
echo "app-version-text=v${APP_VERSION}" >>"${GITHUB_OUTPUT}" | ||
- name: Check if there are any changes | ||
run: | | ||
git add -N . | ||
if git diff --exit-code --quiet; then | ||
echo "No changes detected." | ||
echo "ERROR: could not update the package.json" | ||
exit 1 | ||
else | ||
echo "Changes detected." | ||
fi | ||
- name: Checkout new repository | ||
env: | ||
APP_VERSION: ${{steps.identify-version.outputs.app-version}} | ||
APP_VERSION_TEXT: ${{steps.identify-version.outputs.app-version-text}} | ||
run: | | ||
BRANCH_NAME="release/${APP_VERSION_TEXT}" | ||
git checkout -b "${BRANCH_NAME}" | ||
- name: Update the changelog | ||
env: | ||
APP_VERSION: ${{steps.identify-version.outputs.app-version}} | ||
APP_VERSION_TEXT: ${{steps.identify-version.outputs.app-version-text}} | ||
run: | | ||
pnpm run changelog --tag "${APP_VERSION_TEXT}" | ||
pnpm exec prettier --write CHANGELOG.md | ||
git add CHANGELOG.md | ||
git commit -F-<<EOF | ||
chore: update the CHANGELOG.md for ${APP_VERSION_TEXT} | ||
[AUTO] this commit is created by github actions automatialy. | ||
EOF | ||
- name: Commit package.json | ||
env: | ||
APP_VERSION: ${{steps.identify-version.outputs.app-version}} | ||
APP_VERSION_TEXT: ${{steps.identify-version.outputs.app-version-text}} | ||
run: | | ||
git add package.json | ||
git commit -F-<<EOF | ||
chore: update version of package.json for ${APP_VERSION_TEXT} | ||
[AUTO] this commit is created by github actions automatialy. | ||
EOF | ||
- name: Push commits | ||
run: | | ||
git push -u origin "${BRANCH_NAME}" | ||
- name: Create pull request | ||
env: | ||
APP_VERSION_TEXT: ${{steps.identify-version.outputs.app-version-text}} | ||
run: | | ||
gh pr create --title "chore(release): ${APP_VERSION_TEXT}" --body "**Preparations for ${APP_VERSION_TEXT}**" |
This file contains 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