Skip to content

Commit 3d283fc

Browse files
committed
Add a step that will create a new PR when tag is bumped
1 parent 7a68235 commit 3d283fc

File tree

3 files changed

+67
-9
lines changed

3 files changed

+67
-9
lines changed

.github/workflows/generate-changelog.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name: Generate Changelog PR
33

44
# runs on
55
# * pushing new tag with 'v' prefix
6-
# * manual trigger
6+
# * for 'main' branch
77
on:
88
push:
9+
branches:
10+
- main
911
tags:
1012
- 'v*'
1113

@@ -28,8 +30,10 @@ jobs:
2830
- name: Version bump PR
2931
uses: peter-evans/create-pull-request@v7
3032
with:
31-
token: ${GITHUB_TOKEN}
33+
token: ${{ secrets.GITHUB_TOKEN }}
3234
commit-message: "Update changelog for a new version release"
3335
title: "Update changelog for a new version release"
3436
branch-suffix: "short-commit-hash"
35-
base: "main"
37+
base: "main"
38+
env:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# @author Madhavan Sridharan
22
name: Publish to npm
33

4+
# runs on
5+
# * pushing new tag with 'v' prefix
6+
# * for 'main' branch
47
on:
58
push:
9+
branches:
10+
- main
611
tags:
712
- 'v*.*.*' # Trigger only on version tags like v1.0.0
813

.github/workflows/tag-release.yml

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# @author Madhavan Sridharan
2-
name: Prepare Version Tag
2+
name: Prepare new tag & changelog PR
33

4+
# runs on
5+
# * manually triggered
46
on:
57
workflow_dispatch:
68
inputs:
@@ -14,13 +16,22 @@ on:
1416
- minor
1517
- major
1618

19+
# global env vars, available in all jobs and steps
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
1723
jobs:
18-
tag:
24+
new_tag_and_changelog:
1925
runs-on: ubuntu-latest
26+
permissions:
27+
contents: write
28+
pull-requests: write
2029

2130
steps:
2231
- name: Checkout repo
2332
uses: actions/checkout@v4
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
2435

2536
- name: Set up Node.js
2637
uses: actions/setup-node@v4
@@ -32,10 +43,48 @@ jobs:
3243
git config user.name "GitHub Actions"
3344
git config user.email "[email protected]"
3445
35-
- name: Create version bump branch
46+
- name: Bump the tag version
3647
id: create_branch
48+
# --no-git-tag-version ensures we control when tags are pushed
49+
# git fetch origin main
50+
# git checkout -b release/bump-tag-version origin/main
3751
run: |
38-
git fetch origin main
39-
git checkout -b release/bump-tag-version origin/main
4052
npm version ${{ github.event.inputs.release_type }} -m "chore(release): bump tag version to %s"
41-
git push origin -u release/bump-tag-version --follow-tags
53+
# --follow-tags is not used when pushing the branch in the next step since we're using --no-git-tag-version here
54+
55+
# - name: Commit version bump
56+
# run: |
57+
# git add package.json
58+
# git commit -m "chore(release): bump tag version to $(jq -r .version package.json)" || echo "No changes to commit"
59+
# git push origin release/bump-tag-version
60+
61+
# Duplicate
62+
# - name: Configure Git credentials
63+
# run: |
64+
# git config --global url."https://github.com/".insteadOf "[email protected]:"
65+
# git config --global credential.helper store
66+
67+
# - name: Debug Git state
68+
# run: |
69+
# git remote -v
70+
# git branch
71+
# git config --list
72+
73+
- name: Generate changelog
74+
continue-on-error: true
75+
run: ./update_changelog.sh
76+
77+
- name: Create pull request
78+
uses: peter-evans/create-pull-request@v7
79+
env:
80+
GITHUB_TOKEN:
81+
with:
82+
token: ${{ secrets.GITHUB_TOKEN }}
83+
branch: "release/bump-tag-version"
84+
#branch-suffix: "short-commit-hash"
85+
base: "main"
86+
title: "chore(release): Bump tag version and update changelog"
87+
commit-message: "chore(release): Bump tag version and update changelog"
88+
body: |
89+
This pull request bumps the tag version to $(jq -r .version package.json) and updates changelog as part of the release process.
90+
Please review and merge.

0 commit comments

Comments
 (0)