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
{ "name": "temp", "version": "0.0.0-development", "repository": { "type": "git", "url": "git+https://github.com/my-organization/temp.git" } }
- Setup semantic-release
npm install semantic-release -D npm install @semantic-release/git -D npm install @semantic-release/changelog -D
- Create a .releaserc.json
{ "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/changelog", "@semantic-release/git" ] }
- Create a new Github workflow release.yml
name: Release on push on main branch on: push: branches: - main jobs: release-on-push-on-main-branch: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 with: fetch-depth: 0 - name: Setup Node uses: actions/setup-node@v2 with: node-version: 16.x - name: Install dependencies run: npm install - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release --branches main
- 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)
.
{ "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git" ] }