ci: add ci workflow to manage lib release with semantic-release #80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR needs a few configs to be done on the base repository. These steps NEED to be done before merging!
Steps
1. Generate an API Key on your Pypi.org account; log to PyPi and go to account settings
2. Generate an environment on you Github repository. Call it "development":
and a secret called PYPI_TOKEN with the value of the generated token
3. Create a tag from main with the latest version published without this new feature.
E.g. if version was 2.6.0 tag name will be v2.6.0. Using the Github UI, you should create a new release on main with a new tag
4. Create a branch pre/beta from main and make it as protected branch.
To protect the branch you should add a protection rule:
4. Merge the PR and start using semantic commit messages
Understanding the workflow:
To develop a new feature or fix a bug
Create a child branch of pre/beta (eg: feat/x or fix/x or a name that you like). Do you development on this branch, create a pull request that will merge this branch intro pre/beta. Do your code review! Merge the PR: semantic will release a new version according to the LATEST commit message used and it will publish the lib on PyPi for you using a special "beta" label (Pypi use naming convention like b1, b2 etc for each beta release improvement leaving the version number untouched. This is due to the fact that your are working on a future version that is not yet ready to be released (so it's a beta1, beta2, beta3 etc). Please remember to use semantic commit message and BE SURE that the LAST COMMIT msg use release keywords like "fix:" or "feat:", otherwise no new release will be triggered but your commits will be just added to the changelog.md
To release a version to the public
You have to make the latest beta on pre/beta to be a stable version: make a pull request that merge pre/beta into main! Semantic will release a version of the library, just removing the beta-x extension.
To start a new development just after a release has been done on main
Are you ready to start developing a new future version? Make a Pull Request that merges main into pre/beta. Semantic will generate a new minor version with a new beta-1 label. Now update and switch to pre/beta and create a new child branch to start developing your new feature or fix.
Some links:
https://www.conventionalcommits.org/en/v1.0.0/
https://semantic-release.gitbook.io/semantic-release/recipes/release-workflow/pre-releases