2024-07-31 16:56:06 +00:00
# Releasing
2024-06-05 16:48:47 +00:00
## Requirements
* [github client ](https://github.com/cli/cli#installation )
* [gitchub_changelog_generator ](https://github.com/github-changelog-generator )
* [github access token ](https://github.com/github-changelog-generator/github-changelog-generator#github-token )
## Export changelog token
2020-07-28 14:55:56 +00:00
```bash
2024-06-05 16:48:47 +00:00
export CHANGELOG_GITHUB_TOKEN=token
2020-07-28 14:55:56 +00:00
```
2024-06-05 16:48:47 +00:00
## Set release information
0.3.5 should always be the previous release as it's the last pyhs100 release in HISTORY.md which is the changelog prior to github release notes.
```bash
export NEW_RELEASE=x.x.x.devx
```
2024-07-31 16:56:06 +00:00
## Normal releases from master
### Create a branch for the release
2024-06-05 16:48:47 +00:00
```bash
git checkout master
git fetch upstream master
git rebase upstream/master
git checkout -b release/$NEW_RELEASE
```
2024-07-31 16:56:06 +00:00
### Update the version number
2020-07-28 14:55:56 +00:00
```bash
poetry version $NEW_RELEASE
```
2024-07-31 16:56:06 +00:00
### Update dependencies
2022-04-24 22:13:24 +00:00
2024-06-05 16:48:47 +00:00
```bash
poetry install --all-extras --sync
poetry update
```
2022-04-24 22:13:24 +00:00
2024-07-31 16:56:06 +00:00
### Run pre-commit and tests
2024-06-05 16:48:47 +00:00
```bash
pre-commit run --all-files
pytest kasa
```
2024-07-31 16:56:06 +00:00
### Create release summary (skip for dev releases)
2024-06-05 16:48:47 +00:00
Write a short and understandable summary for the release. Can include images.
2024-07-31 16:56:06 +00:00
#### Create $NEW_RELEASE milestone in github
2024-06-05 16:48:47 +00:00
If not already created
2024-07-31 16:56:06 +00:00
#### Create new issue linked to the milestone
2024-06-05 16:48:47 +00:00
```bash
2024-08-30 17:55:36 +00:00
gh issue create --label "release-summary" --milestone $NEW_RELEASE --title "$NEW_RELEASE Release Summary" --body "**Release summary:**"
2024-06-05 16:48:47 +00:00
```
2024-06-07 12:25:17 +00:00
You can exclude the --body option to get an interactive editor or go into the issue on github and edit there.
2024-06-05 16:48:47 +00:00
2024-07-31 16:56:06 +00:00
#### Close the issue
2024-06-05 16:48:47 +00:00
Either via github or:
```bash
gh issue close ISSUE_NUMBER
```
2024-07-31 16:56:06 +00:00
### Generate changelog
2024-06-05 16:48:47 +00:00
2024-07-02 11:30:43 +00:00
Configuration settings are in `.github_changelog_generator`
2024-07-31 16:56:06 +00:00
#### For pre-release
2024-06-05 16:48:47 +00:00
EXCLUDE_TAGS will exclude all dev tags except for the current release dev tags.
Regex should be something like this `^((?!0\.7\.0)(.*dev\d))+` . The first match group negative matches on the current release and the second matches on releases ending with dev.
```bash
EXCLUDE_TAGS=${NEW_RELEASE%.dev*}; EXCLUDE_TAGS=${EXCLUDE_TAGS//"."/"\."}; EXCLUDE_TAGS="^((?!"$EXCLUDE_TAGS")(.*dev\d))+"
2024-06-07 12:25:17 +00:00
echo "$EXCLUDE_TAGS"
2024-07-02 11:30:43 +00:00
github_changelog_generator --future-release $NEW_RELEASE --exclude-tags-regex "$EXCLUDE_TAGS"
2024-06-05 16:48:47 +00:00
```
2024-07-31 16:56:06 +00:00
#### For production
2020-07-28 14:55:56 +00:00
```bash
2024-07-02 11:30:43 +00:00
github_changelog_generator --future-release $NEW_RELEASE --exclude-tags-regex 'dev\d$'
2020-07-28 14:55:56 +00:00
```
2024-06-05 16:48:47 +00:00
You can ignore warnings about missing PR commits like below as these relate to PRs to branches other than master:
```
Warning: PR 908 merge commit was not found in the release branch or tagged git history and no rebased SHA comment was found
```
Release 0.6.0 (#653)
This major brings major changes to the library by adding support for devices that require authentication for communications, all of this being possible thanks to the great work by @sdb9696!
This release adds support to a large range of previously unsupported devices, including:
* Newer kasa-branded devices, including Matter-enabled devices like KP125M
* Newer hardware/firmware versions on some models, like EP25, that suddenly changed the used protocol
* Tapo-branded devices like plugs (P110), light bulbs (KL530), LED strips (L900, L920), and wall switches (KS205, KS225)
* UK variant of HS110, which was the first device using the new protocol
If your device that is not currently listed as supported is working, please consider contributing a test fixture file.
Special thanks goes to @SimonWilkinson who created the initial PR for the new communication protocol!
2024-01-19 00:36:57 +00:00
2024-06-05 16:48:47 +00:00
2024-07-31 16:56:06 +00:00
### Export new release notes to variable
2024-06-05 16:48:47 +00:00
```bash
export RELEASE_NOTES=$(grep -Poz '(?< =\# Changelog\n\n)(.|\n)+?(?=\#\#)' CHANGELOG.md | tr '\0' '\n' )
echo "$RELEASE_NOTES" # Check the output and copy paste if neccessary
```
2024-07-31 16:56:06 +00:00
### Commit and push the changed files
2020-07-28 14:55:56 +00:00
```bash
2024-06-05 16:48:47 +00:00
git commit --all --verbose -m "Prepare $NEW_RELEASE"
git push upstream release/$NEW_RELEASE -u
2020-07-28 14:55:56 +00:00
```
2024-07-31 16:56:06 +00:00
### Create a PR for the release, merge it, and re-fetch the master
2024-06-05 16:48:47 +00:00
2024-07-31 16:56:06 +00:00
#### Create the PR
2024-06-05 16:48:47 +00:00
```
gh pr create --title "Prepare $NEW_RELEASE" --body "$RELEASE_NOTES" --label release-prep --base master
```
2020-07-28 14:55:56 +00:00
2024-07-31 16:56:06 +00:00
#### Merge the PR once the CI passes
2024-06-05 16:48:47 +00:00
Create a squash commit and add the markdown from the PR description to the commit description.
```bash
gh pr merge --squash --body "$RELEASE_NOTES"
```
### Rebase local master
2020-07-28 14:55:56 +00:00
```bash
git checkout master
2024-06-05 16:48:47 +00:00
git fetch upstream master
2020-07-28 14:55:56 +00:00
git rebase upstream/master
```
2024-07-31 16:56:06 +00:00
### Create a release tag
2024-06-05 16:48:47 +00:00
Note, add changelog release notes as the tag commit message so `gh release create --notes-from-tag` can be used to create a release draft.
2020-07-28 14:55:56 +00:00
```bash
2024-06-05 16:48:47 +00:00
git tag --annotate $NEW_RELEASE -m "$RELEASE_NOTES"
2020-07-28 14:55:56 +00:00
git push upstream $NEW_RELEASE
```
2024-07-31 16:56:06 +00:00
### Create release
2024-06-05 16:48:47 +00:00
2024-07-31 16:56:06 +00:00
#### Pre-releases
2024-06-05 16:48:47 +00:00
```bash
gh release create "$NEW_RELEASE" --verify-tag --notes-from-tag --title "$NEW_RELEASE" --draft --latest=false --prerelease
```
2024-07-31 16:56:06 +00:00
#### Production release
2024-06-05 16:48:47 +00:00
```bash
gh release create "$NEW_RELEASE" --verify-tag --notes-from-tag --title "$NEW_RELEASE" --draft --latest=true
```
2024-07-31 16:56:06 +00:00
### Manually publish the release
2020-07-28 14:55:56 +00:00
2024-06-05 16:48:47 +00:00
Go to the linked URL, verify the contents, and click "release" button to trigger the release CI.
2024-07-31 16:56:06 +00:00
## Patch releases
This requires git commit signing to be enabled.
https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification
### Create release branch
#### For the first patch release since a new release only
```bash
export NEW_RELEASE=x.x.x.x
export CURRENT_RELEASE=x.x.x
```
```bash
git fetch upstream $CURRENT_RELEASE
git checkout patch
git fetch upstream patch
git rebase upstream/patch
git fetch upstream $CURRENT_RELEASE
git merge $CURRENT_RELEASE --ff-only
git push upstream patch -u
git checkout -b release/$NEW_RELEASE
```
#### For subsequent patch releases
```bash
export NEW_RELEASE=x.x.x.x
```
```bash
git checkout patch
git fetch upstream patch
git rebase upstream/patch
git checkout -b release/$NEW_RELEASE
```
### Cherry pick required commits
```bash
git cherry-pick commitSHA1 -S
git cherry-pick commitSHA2 -S
```
### Update the version number
```bash
poetry version $NEW_RELEASE
```
### Manually edit the changelog
github_changlog generator_does not work with patch releases so manually add the section for the new release to CHANGELOG.md.
### Export new release notes to variable
```bash
export RELEASE_NOTES=$(grep -Poz '(?< =\# Changelog\n\n)(.|\n)+?(?=\#\#)' CHANGELOG.md | tr '\0' '\n' )
echo "$RELEASE_NOTES" # Check the output and copy paste if neccessary
```
### Commit and push the changed files
```bash
git commit --all --verbose -m "Prepare $NEW_RELEASE" -S
git push upstream release/$NEW_RELEASE -u
```
### Create a PR for the release, merge it, and re-fetch patch
#### Create the PR
```
gh pr create --title "$NEW_RELEASE" --body "$RELEASE_NOTES" --label release-prep --base patch
```
#### Merge the PR once the CI passes
Create a **merge** commit and add the markdown from the PR description to the commit description.
```bash
gh pr merge --merge --body "$RELEASE_NOTES"
```
### Rebase local patch
```bash
git checkout patch
git fetch upstream patch
git rebase upstream/patch
```
### Create a release tag
```bash
git tag -s --annotate $NEW_RELEASE -m "$RELEASE_NOTES"
git push upstream $NEW_RELEASE
```
### Create release
```bash
gh release create "$NEW_RELEASE" --verify-tag --notes-from-tag --title "$NEW_RELEASE" --draft --latest=true
```
Then go into github, review and release
### Merge patch back to master
```bash
git checkout master
git fetch upstream master
git rebase upstream/master
git checkout -b janitor/merge_patch
git fetch upstream patch
git merge upstream/patch --no-commit
git diff --name-only --diff-filter=U | xargs git checkout upstream/master
git diff --staged
# The only diff should be the version in pyproject.toml and CHANGELOG.md
# unless a change made on patch that was not part of a cherry-pick commit
# If there are any other unexpected diffs `git checkout upstream/master [thefilename]`
git commit -m "Merge patch into local master" -S
git push upstream janitor/merge_patch -u
gh pr create --title "Merge patch into master" --body '' --label release-prep --base master
```
#### Temporarily allow merge commits to master
1. Open [repository settings ](https://github.com/python-kasa/python-kasa/settings )
2. From the left select `Rules` > `Rulesets`
3. Open `master` ruleset, under `Bypass list` select `+ Add bypass`
4. Check `Repository admin` > `Add selected` , select `Save changes`
#### Merge commit the PR
```bash
gh pr merge --merge --body ""
```
#### Revert allow merge commits
1. Under `Bypass list` select `...` next to `Repository admins`
2. `Delete bypass` , select `Save changes`