Skip to content

Commit 048a36a

Browse files
authored
Rebase and atomically push commit with tag in publish workflow (#48)
1 parent 2e5f725 commit 048a36a

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

.github/workflows/publish.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ jobs:
2020
contains(github.event.pull_request.labels.*.name, 'major') ) }}
2121
steps:
2222
- name: Checkout the repository
23-
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
23+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
2424
with:
2525
token: ${{ secrets.RELEASE_PAT }}
26+
fetch-depth: 0
2627

2728
- name: Setup git user
2829
run: |
2930
git config user.name "neetobot"
3031
git config user.email "neetobot.github@neeto.com"
3132
3233
- name: Setup NodeJS LTS version
33-
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
34+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
3435
with:
3536
node-version-file: ".nvmrc"
3637

@@ -63,15 +64,19 @@ jobs:
6364
id: package-version
6465

6566
- name: Create a new version release commit
66-
uses: EndBug/add-and-commit@v9
67+
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10
6768
with:
6869
message: "New version release"
70+
push: false
6971

70-
- name: Push the commit to main
71-
uses: ad-m/github-push-action@master
72-
with:
73-
github_token: ${{ secrets.RELEASE_PAT }}
74-
branch: main
72+
- name: Rebase on latest main and push commit and tag
73+
working-directory: ${{ github.workspace }}
74+
run: |
75+
VERSION=$(node -p "require('./js/package.json').version")
76+
git fetch origin main
77+
git rebase origin/main
78+
git tag -f "v${VERSION}"
79+
git push --atomic origin HEAD:main "refs/tags/v${VERSION}"
7580
7681
- name: Publish the package on NPM
7782
run: |

0 commit comments

Comments
 (0)