What I want to do
Based on the FAQ
I want to update the package.json version number on a new release.
What I did
- Create a new empty private Github repository for an organization
temp
with a README.md and .gitignore for node - Clone the repository
- Fix the first commit message via git
rebase -i --root
and change it tofeat: initial commit
- Create a package.json with the content
JavaScript
x
9
1
{
2
"name": "temp",
3
"version": "0.0.0-development",
4
"repository": {
5
"type": "git",
6
"url": "git+https://github.com/my-organization/temp.git"
7
}
8
}
9
- Setup semantic-release
JavaScript
1
4
1
npm install semantic-release -D
2
npm install @semantic-release/git -D
3
npm install @semantic-release/changelog -D
4
- Create a .releaserc.json
JavaScript
1
9
1
{
2
"plugins": [
3
"@semantic-release/commit-analyzer",
4
"@semantic-release/release-notes-generator",
5
"@semantic-release/changelog",
6
"@semantic-release/git"
7
]
8
}
9
- Create a new Github workflow release.yml
JavaScript
1
30
30
1
name: Release on push on main branch
2
3
on:
4
push:
5
branches:
6
- main
7
8
jobs:
9
release-on-push-on-main-branch:
10
runs-on: ubuntu-latest
11
12
steps:
13
- name: Checkout repository
14
uses: actions/checkout@v2
15
with:
16
fetch-depth: 0
17
18
- name: Setup Node
19
uses: actions/setup-node@v2
20
with:
21
node-version: 16.x
22
23
- name: Install dependencies
24
run: npm install
25
26
- name: Release
27
env:
28
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29
run: npx semantic-release --branches main
30
- Commit everything with the message
feat: next commit
- Force push to origin
The problem
The package.json file won’t get updated by the semantic-release-bot.
Even after modifying the README.md file and pushing with feat: this should trigger a new release
.
How can I tell semantic-release to push the new package version?
Advertisement
Answer
Based on this issue
https://github.com/semantic-release/semantic-release/issues/1593
you also need the npm module.
npm install @semantic-release/npm -D
- add
"private": true,
to your package.json if you don’t want to publish to npm - add the npm plugin to the release configuration file (the order matters)
.
JavaScript
1
10
10
1
{
2
"plugins": [
3
"@semantic-release/commit-analyzer",
4
"@semantic-release/release-notes-generator",
5
"@semantic-release/changelog",
6
"@semantic-release/npm",
7
"@semantic-release/git"
8
]
9
}
10