From cecdb85320abd81b528b03f88fff672703fa9c94 Mon Sep 17 00:00:00 2001 From: Nijanthan <6072170+nijanthanvijayakumar@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:46:17 +1000 Subject: [PATCH 1/3] Add configuration files for release-please and update contributing guide * **release-please-config.json**: Add configuration file with release type set to `python`, changelog path to `CHANGELOG.md`, and packages to include `quinn`. * **.release-please-manifest.json**: Add manifest file with `quinn` version set to `1.0.0`. * **.github/workflows/release-please.yml**: Add workflow file for release-please action * **CONTRIBUTING.md**: Add a section for the "Release Process" --- .github/workflows/release-please.yml | 19 +++++++++++++++++++ .release-please-manifest.json | 3 +++ CONTRIBUTING.md | 23 +++++++++++++++++++++++ release-please-config.json | 14 ++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..8ca09760 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,19 @@ +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +name: release-please + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..37fcefaa --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.0.0" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7827d2d2..77711fa8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -222,3 +222,26 @@ When you're finished with the changes, create a pull request, also known as a PR - Don't forget to link PR to the issue if you are solving one. - As you update your PR and apply changes, mark each conversation as resolved. - If you run into any merge issues, checkout this [git tutorial](https://github.com/skills/resolve-merge-conflicts) to help you resolve merge conflicts and other issues. + +### Release Process + +#### How to create a release + +If the latest release on GitHub is 1.0.0, and the latest pre-release is 1.1.0-rc, and if we want to create a release of 1.1.0 then the `release-please-config.json` should be updated by removing the `"versioning":"prerelease"` and setting the `"prerelease": false`. Otherwise, the GitHub Actions will not create a release and it would rather create a pre-release again. + +For this whole release process to work seamlessly, lets say the latest release on GitHub is 1.0.0, and the latest pre-release is 1.1.0-rc, and if we want to create a release of 1.1.0, then we will have to set `"bump-minor-pre-major": true,` in the `release-please-config.json` and we should change the version in the `.release-please-manifest.json` from `1.1.0-rc` to `1.0.0` before pushing changes to the remote branch. + +Improper configs: +If the config is `"bump-minor-pre-major": false,` and the `.release-please-manifest.json` contains the version as `1.1.0-rc`, then the automated GH Actions will bump the major version creating a release of 2.0.0. + +If the config is `"bump-minor-pre-major": true,` and the `.release-please-manifest.json` contains the version as `1.1.0-rc`, then the automated GH Actions will create a version of `1.2.0`. Either of those above improper configs will lead to a gap in the release. Hence, it's important to downgrade the version in the version file and set the `"bump-minor-pre-major": true,` if we are creating a minor release. If we are creating a major release, then perhaps use the config `"bump-minor-pre-major": false,` and then set the version in the version file to the latest release version. + +#### How to create a pre-release + +In order to create a pre-release, the user should just update the `release-please-config.json` in the root. They should set the `"prerelease"` to `true` and the `"versioning"` to `"prerelease"`. Otherwise, a pre-release will not be created. In this case, since the pre-release-type is set to `rc`, if the current version is `1.0.0`, and the following configs are set as `"bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false,`, then the pre-release version will be bumped to as `1.1.0-rc`. + +If the configs are as follows `"bump-minor-pre-major": false, "bump-patch-for-minor-pre-major": false,`, then the pre-release version will be `2.0.0-rc`, i.e., the major version will be bumped. + +#### Conventional commit messages tips + +- diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..69deeb83 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,14 @@ +{ + "packages": { + ".": { + "changelog-path": "CHANGELOG.md", + "release-type": "python", + "prerelease-type": "rc", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "draft": false, + "prerelease": true, + "versioning": "prerelease" + } + } +} \ No newline at end of file From 1403347651034d223613952de10ac0f087f53d15 Mon Sep 17 00:00:00 2001 From: Niju Vijayakumar Date: Mon, 16 Sep 2024 11:04:05 +1000 Subject: [PATCH 2/3] feat: Update the documentation to elaborate the release process --- .release-please-manifest.json | 2 +- CONTRIBUTING.md | 57 ++++++++++++++++++++++++++++------- release-please-config.json | 2 +- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 37fcefaa..8c7bf663 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.0.0" + ".": "0.10.3" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77711fa8..7f212715 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -225,23 +225,58 @@ When you're finished with the changes, create a pull request, also known as a PR ### Release Process -#### How to create a release +#### How to Create a Release -If the latest release on GitHub is 1.0.0, and the latest pre-release is 1.1.0-rc, and if we want to create a release of 1.1.0 then the `release-please-config.json` should be updated by removing the `"versioning":"prerelease"` and setting the `"prerelease": false`. Otherwise, the GitHub Actions will not create a release and it would rather create a pre-release again. +- **Update `release-please-config.json`:** + - Remove `"versioning": "prerelease"`. + - Set `"prerelease": false`. -For this whole release process to work seamlessly, lets say the latest release on GitHub is 1.0.0, and the latest pre-release is 1.1.0-rc, and if we want to create a release of 1.1.0, then we will have to set `"bump-minor-pre-major": true,` in the `release-please-config.json` and we should change the version in the `.release-please-manifest.json` from `1.1.0-rc` to `1.0.0` before pushing changes to the remote branch. +- **Ensure correct version bump:** + - If the latest release is `1.0.0` and the latest pre-release is `1.1.0-rc`, and you want to create a release with the version `1.1.0`: + - Set `"bump-minor-pre-major": true` in `release-please-config.json`. + - Change the version in `.release-please-manifest.json` from `1.1.0-rc` to `1.0.0`. -Improper configs: -If the config is `"bump-minor-pre-major": false,` and the `.release-please-manifest.json` contains the version as `1.1.0-rc`, then the automated GH Actions will bump the major version creating a release of 2.0.0. +- **Avoid configurations that cause version/release gaps:** + - If `"bump-minor-pre-major": false` and `.release-please-manifest.json` is `1.1.0-rc`, it will create a major release `2.0.0`. + - If `"bump-minor-pre-major": true` and `.release-please-manifest.json` is `1.1.0-rc`, it will create a minor release `1.2.0`. -If the config is `"bump-minor-pre-major": true,` and the `.release-please-manifest.json` contains the version as `1.1.0-rc`, then the automated GH Actions will create a version of `1.2.0`. Either of those above improper configs will lead to a gap in the release. Hence, it's important to downgrade the version in the version file and set the `"bump-minor-pre-major": true,` if we are creating a minor release. If we are creating a major release, then perhaps use the config `"bump-minor-pre-major": false,` and then set the version in the version file to the latest release version. +- **Key points:** + - Downgrade the version in the version file for minor releases. + - Use `"bump-minor-pre-major": true` for minor releases. + - Use `"bump-minor-pre-major": false` for major releases and set the version to the latest release version. -#### How to create a pre-release +#### How to Create a Pre-Release -In order to create a pre-release, the user should just update the `release-please-config.json` in the root. They should set the `"prerelease"` to `true` and the `"versioning"` to `"prerelease"`. Otherwise, a pre-release will not be created. In this case, since the pre-release-type is set to `rc`, if the current version is `1.0.0`, and the following configs are set as `"bump-minor-pre-major": true, "bump-patch-for-minor-pre-major": false,`, then the pre-release version will be bumped to as `1.1.0-rc`. +- Update the `release-please-config.json` in the root. + - Set `"prerelease"` to `true`. + - Add the line `"versioning": "prerelease"`. +- Ensure the pre-release type is set to `rc`. + - For example, if the current version is `1.0.0` and the following configs are set: + - `"bump-minor-pre-major": true` + - `"bump-patch-for-minor-pre-major": false` + - The pre-release version will be bumped to `1.1.0-rc`. + - If the configs are set as: + - `"bump-minor-pre-major": false` + - `"bump-patch-for-minor-pre-major": false` + - The pre-release version will be `2.0.0-rc`, i.e., the major version will be bumped. -If the configs are as follows `"bump-minor-pre-major": false, "bump-patch-for-minor-pre-major": false,`, then the pre-release version will be `2.0.0-rc`, i.e., the major version will be bumped. -#### Conventional commit messages tips +### Conventional Commit Messages -- +- **Format**: `[optional scope]: ` +- **Type**: Specifies the nature of the change (e.g., `feat`, `fix`, `docs`). +- **Scope**: Optional part that specifies the section of the codebase affected. +- **Description**: A brief summary of the change. +- **Body**: Optional detailed explanation of the change. +- **Footer**: Optional additional information, such as breaking changes or issue references. + +#### Example + +```plaintext +feat(parser): add support for new data format + +Added a new parser to handle the VARIANT data format. This change includes updates to the parser module and corresponding tests. + +Closes #123 +``` +For more information on conventional commit messages, check this site: https://www.conventionalcommits.org/en/v1.0.0/ \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json index 69deeb83..af27e83f 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,7 +4,7 @@ "changelog-path": "CHANGELOG.md", "release-type": "python", "prerelease-type": "rc", - "bump-minor-pre-major": true, + "bump-minor-pre-major": false, "bump-patch-for-minor-pre-major": false, "draft": false, "prerelease": true, From cb74e630c5d8a8faa857a34da56b1c57e33ce9e9 Mon Sep 17 00:00:00 2001 From: Niju Vijayakumar Date: Fri, 27 Sep 2024 20:19:24 +1000 Subject: [PATCH 3/3] feat: Update the release GH action to publish the package to PyPI --- .github/workflows/release-please.yml | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 8ca09760..385ef908 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -17,3 +17,41 @@ jobs: with: config-file: release-please-config.json manifest-file: .release-please-manifest.json + + # Following GH step is created based on the following article and the credits to the same + # https://johnfraney.ca/blog/how-to-publish-a-python-package-with-poetry-and-github-actions/ + publish-to-pypi: + needs: release-please + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/quinn/ + permissions: + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ">=3.9,<4.0" + + - name: Install Poetry + run: | + curl -sSL https://install.python-poetry.org | python - -y + + - name: Update PATH + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Update Poetry configuration + run: poetry config virtualenvs.create false + + - name: Install dependencies + run: poetry install --sync --no-interaction + + - name: Package project + run: poetry build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1