I've been upgrading our workflow to add an automatic version bump. The problem is that I accidentally added these steps with a typo in the .bumpversion.cfg
file and from that moment, the workflow is sure that the releases start at tag 1.0.0
. I've created 2 releases with this scenario (1.0.0 and 1.0.1). Once I was on to this, I deleted the two releases (and tags), but now the workflow can't find the latest release tag.
One important piece of info is that the repo is a Node app, so there is already a package.json
and such there.
I tried:
- bumping manually the versions in my files
- bumping with
bump2version
to the version I expected - bumping with
bump2version
to the next version
As you'll see, the command is missing the current version. The error in the workflow is:
An error occurred while running semantic-release: Error: Command failed with exit code 2: bump2version --allow-dirty --current-version --new-version 1.0.0 patch
the create release
step is:
name: Create new release
on:
workflow_dispatch:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'chore')"
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.ADMIN_TOKEN }}
- name: setup nodejs
uses: actions/setup-node@v3
with:
node-version: '16'
- name: release using semantic-release
env:
GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }}
GIT_AUTHOR_NAME: secrets.automation.dev
GIT_AUTHOR_EMAIL: secrets.automation.dev@il.ibm.com
GIT_COMMITTER_NAME: secrets.automation.dev
GIT_COMMITTER_EMAIL: secrets.automation.dev@il.ibm.com
run: |
sudo apt-get update
sudo apt-get install python
pip install --user bumpversion
npm install @semantic-release/changelog
npm install @semantic-release/exec
npm install @semantic-release/git
npm install @semantic-release/github
npx semantic-release
The .bumpversion.cfg
is:
[bumpversion]
current_version = 1.0.40
commit = True
message = Update version {current_version} -> {new_version}
[bumpversion:file:package.json]
search = {current_version}
replace = {new_version}
The .releaserc
file is:
{
"debug": true,
"branches": [ "main" ],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"type": "release","release": "patch"}
]}],
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "bump2version --allow-dirty --current-version ${lastRelease.version} --new-version ${nextRelease.version} patch"
}
],
[
"@semantic-release/git",
{
"message": "chore(release): ${nextRelease.version} [skip ci] release notes\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}