go-semantic-release / semantic-release

πŸ“¦πŸš€ semantic-release written in Go
https://go-semantic-release.xyz
MIT License
409 stars 43 forks source link

How to create a prerelease tag x.x.x-rc.0 in default branch #119

Closed jeraldsm closed 2 years ago

jeraldsm commented 2 years ago

Hi,

I wanted to implement, a prerelease tag ( x.x.x-rc.0) for UAT environment and later create main tag (x.x.x) in production environment as a part of cicd pipeline.

I tried using the "--prerelease" flag, but it bumped the version as it would normally and did not create a special pre-release tag, as shown below.

$ semantic-release --token ${GL_TOKEN} --version-file --prerelease go-semantic-release: version: 2.17.0 go-semantic-release: ci-condition plugin: GitLab CI@1.4.0 go-semantic-release: provider plugin: GitLab@1.6.0 go-semantic-release: getting default branch... go-semantic-release: found default branch: master go-semantic-release: repo is private go-semantic-release: found current branch: master go-semantic-release: found current sha: c693286f4dc409c2dca473cc8698e362c1aa0000 go-semantic-release: running CI condition... go-semantic-release: getting latest release... go-semantic-release: found version: 1.5.1 go-semantic-release: getting commits... go-semantic-release: analyzing commits... go-semantic-release: commit-analyzer plugin: default@1.5.0 go-semantic-release: calculating new version... go-semantic-release: new version: 1.6.0 go-semantic-release: generating changelog... go-semantic-release: changelog-generator plugin: default@1.7.0 go-semantic-release: creating release... go-semantic-release: warning: file update plugins found but no files marked for update. You may be missing the update flag, e.g. --update package.json

go-semantic-release: stopping plugins...

I've also tried the "--maintained-version rc-1" flag for creating an rc tag however this flag only works in non-default branches. I want an rc tag to be created in main (default) branch.

How can I achieve this using this semantic version tool ?

KoduIsGreat commented 2 years ago

I have a simliar question, I have two branches, main and dev on dev i want maintained version semver i.e develop-v1.0.0-3 and on main normal development versions, i've tried simply adding a .semrelrc with the contents

{
  "maintainedVersion": "develop"
}

but got the following error in my ci environment when it ran on my default branch:

running semantic-release...
/home/runner/work/_temp/4cfdf371-917f-4d80-877b-efdb9d3925b4 --version-file --changelog .generated-go-semantic-release-changelog.md --token *** --allow-initial-development-versions --changelog-generator-opt emojis=true
[go-semantic-release]: version: 2.17.0
[go-semantic-release]: ci-condition plugin: GitHub Actions@1.4.0
[go-semantic-release]: provider plugin: GitHub@1.8.0
[go-semantic-release]: getting default branch...
[go-semantic-release]: found default branch: main
[go-semantic-release]: found current branch: main
[go-semantic-release]: maintained version not allowed on default branch
[go-semantic-release]: stopping plugins...

I would expect the build to bump versions the way it always does on main, and not worry about the maintained version unless it matches the branch specified in the .semrel file.

can someone clarify what i'm doing wrong?

christophwitzko commented 2 years ago

Hi @jeraldsm and @KoduIsGreat,

thanks for using semantic-release and raising this issue. You are absolutely right, this is currently not possible and I am happy to add a flag that allows prereleases on the default branch. πŸ‘

jeraldsm commented 2 years ago

Thanks for the quick response @christophwitzko. Waiting for the new prelease flag :)

KoduIsGreat commented 2 years ago

@christophwitzko thanks for the quick response, however i think my need is slightly different I just want to beable to create pre-releases on dev and normal releases on main and i had thought maintainedVersion was the way to do that is this the case?

jeraldsm commented 2 years ago

Hi @christophwitzko ,

Do we have an ETC when the pre-release flag will be available on default branch ? Just wanted to plan accordingly :)

christophwitzko commented 2 years ago

Hey @jeraldsm, I just pushed the feature and version v2.18.0 was released. You can now use the --allow-maintained-version-on-default-branch flag to disable the default branch check.