Skip to content

Commit a13956d

Browse files
fix: version defaulting to 0.0.0.dev0 (#40)
* Update the release process * clean up changes * Fix tests * Improve based on feedback * Update .github/maintainers_guide.md Co-authored-by: Fil Maj <maj.fil@gmail.com> * Update maintainers_guide.md --------- Co-authored-by: Fil Maj <maj.fil@gmail.com>
1 parent fa4bb57 commit a13956d

File tree

5 files changed

+119
-74
lines changed

5 files changed

+119
-74
lines changed

.github/maintainers_guide.md

Lines changed: 75 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -108,33 +108,47 @@ If you want to test the package locally you can.
108108

109109
#### test.pypi.org deployment
110110

111-
[TestPyPI](https://test.pypi.org/) is a separate instance of the
112-
Python Package Index that allows you to try distribution tools and
113-
processes without affecting the real index. This is useful with changes that
114-
relate to the package itself, example the contents of the `pyproject.toml`
111+
[TestPyPI](https://test.pypi.org/) is a separate instance of the Python Package
112+
Index that allows you to try distribution tools and processes without affecting
113+
the real index. This is useful with changes that relate to the package itself,
114+
example the contents of the `pyproject.toml`
115115

116116
The following can be used to deploy this project on <https://test.pypi.org/>.
117117

118118
```zsh
119-
# Set the new version with SLACK_CLI_HOOKS_VERSION
120-
SLACK_CLI_HOOKS_VERSION="1.2.3" ./scripts/deploy_to_test_pypi.sh
119+
120+
./scripts/deploy_to_test_pypi.sh
121121
```
122122

123123
#### Development Deployment
124124

125-
Releases for this library are automatically generated off of git releases. Before
126-
creating a new release, ensure that everything on a stable branch has landed, then
127-
[run the tests](#run-all-the-unit-tests).
128-
129-
1. Create a new GitHub Release from the
125+
Deploying a new version of this library to Pypi is triggered by publishing a Github Release.
126+
Before creating a new release, ensure that everything on a stable branch has
127+
landed, then [run the tests](#run-all-the-unit-tests).
128+
129+
1. Create a branch in which the development release will live:
130+
- Bump the version number in adherence to
131+
[Semantic Versioning](http://semver.org/) and
132+
[Developmental Release](https://peps.python.org/pep-0440/#developmental-releases)
133+
in `slack_bolt/version.py`
134+
- Example the current version is `1.2.3` a proper development bump would be
135+
`1.2.3.dev0`
136+
- `.dev` will indicate to pip that this is a
137+
[Development Release](https://peps.python.org/pep-0440/#developmental-releases)
138+
- Note that the `dev` version can be bumped in development releases:
139+
`1.2.3.dev0` -> `1.2.3.dev1`
140+
- Commit with a message including the new version number. For example
141+
`1.2.3.dev0` & Push the commit to a branch where the development release
142+
will live (create it if it does not exist)
143+
- `git checkout -b future-release`
144+
- `git commit -m 'version 1.2.3.dev0'`
145+
- `git push -u origin future-release`
146+
2. Create a new GitHub Release from the
130147
[Releases page](https://github.com/slackapi/python-slack-hooks/releases) by
131148
clicking the "Draft a new release" button.
132-
2. Input a new version manually into the "Choose a tag" input. You can start off
133-
by incrementing the version to reflect a patch. (i.e. 1.16.0 -> 1.16.1.dev0)
149+
3. Input the version manually into the "Choose a tag" input. You must use the
150+
same version found in `slack_bolt/version.py`
134151

135-
- Example the current version is `1.2.3` a proper development bump would be `1.3.0.dev0`
136-
- `.dev` will indicate to pip that this is a [Development Release](https://peps.python.org/pep-0440/#developmental-releases)
137-
- Note that the `dev` version can be bumped in development releases: `1.3.0.dev0` -> `1.3.0.dev1`
138152
- After you input the new version, click the "Create a new tag: x.x.x on
139153
publish" button. This won't create your tag immediately.
140154
- Auto-generate the release notes by clicking the "Auto-generate release
@@ -143,74 +157,70 @@ creating a new release, ensure that everything on a stable branch has landed, th
143157
- Edit the resulting notes to ensure they have decent messaging that are
144158
understandable by non-contributors, but each commit should still have it's
145159
own line.
146-
- Flip to the preview mode and review the pull request labels of the changes
147-
included in this release (i.e. `semver:minor` `semver:patch`,
148-
`semver:major`). Tip: Your release version should be based on the tag of
149-
the largest change, so if this release includes a `semver:minor`, the
150-
release version in your tag should be upgraded to reflect a minor.
151-
- Ensure that this version adheres to [semantic versioning](http://semver.org/) and
160+
- Ensure that this version adheres to
161+
[semantic versioning](http://semver.org/) and
152162
[Developmental Release](https://peps.python.org/pep-0440/#developmental-releases).
153-
See [Versioning](#versioning-and-tags) for correct version format. Version tags
154-
should match the following pattern: `1.0.1` (no `v` preceding the number).
155-
156-
3. Set the "Target" input to the feature branch with the development changes.
157-
4. Name the release title after the version tag. The release title is what will
158-
be used by the pipeline to populate the value in `slack_cli_hooks/version.py`
159-
and the Pypi package version!
160-
5. Make any adjustments to generated release notes to make sure they are
163+
See [Versioning](#versioning-and-tags) for correct version format.
164+
165+
4. Set the "Target" input to the feature branch with the development changes.
166+
5. Name the release title after the version tag. It should match the updated
167+
value from `slack_cli_hooks/version.py`!
168+
6. Make any adjustments to generated release notes to make sure they are
161169
accessible and approachable and that an end-user with little context about
162170
this project could still understand.
163-
6. Select "Set as a pre-release"
164-
7. Publish the release by clicking the "Publish release" button!
165-
8. After a few minutes, the corresponding version will be available on
171+
7. Select "Set as a pre-release"
172+
8. Publish the release by clicking the "Publish release" button!
173+
9. After a few minutes, the corresponding version will be available on
166174
<https://pypi.org/project/slack-cli-hooks/>.
167-
9. (Slack Internal) Communicate the release internally
175+
10. (Slack Internal) Communicate the release internally
168176

169177
#### Production Deployment
170178

171-
Releases for this library are automatically generated off of git releases. Before
172-
creating a new release, ensure that everything on the `main` branch since the
173-
last tag is in a releasable state! At a minimum,
179+
Deploying a new version of this library to Pypi is triggered by publishing a Github Release.
180+
Before creating a new release, ensure that everything on the `main` branch since
181+
the last tag is in a releasable state! At a minimum,
174182
[run the tests](#run-all-the-unit-tests).
175183

176-
1. Create a new GitHub Release from the
184+
1. Create the commit for the release
185+
- Bump the version number in adherence to
186+
[Semantic Versioning](http://semver.org/) in `slack_bolt/version.py`
187+
- Commit with a message including the new version number. For example `1.2.3`
188+
& Push the commit to a branch and create a PR to sanity check.
189+
- `git checkout -b 1.2.3-release`
190+
- `git commit -m 'version 1.2.3'`
191+
- `git push {your-fork} 1.2.3-release`
192+
- Merge in release PR after getting an approval from at least one maintainer.
193+
2. Create a new GitHub Release from the
177194
[Releases page](https://github.com/slackapi/python-slack-hooks/releases) by
178195
clicking the "Draft a new release" button.
179-
2. Input a new version manually into the "Choose a tag" input. You can start off
180-
by incrementing the version to reflect a patch. (i.e. 1.16.0 -> 1.16.1)
196+
3. Input the version manually into the "Choose a tag" input. You must use the
197+
same version found in `slack_bolt/version.py`
181198

182-
- After you input the new version, click the "Create a new tag: x.x.x on
183-
publish" button. This won't create your tag immediately.
184-
- Auto-generate the release notes by clicking the "Auto-generate release
185-
notes" button. This will pull in changes that will be included in your
186-
release.
199+
- After you input the version, click the "Create a new tag: x.x.x on publish"
200+
button. This won't create your tag immediately.
201+
- Click the "Auto-generate release notes" button. This will pull in changes
202+
that will be included in your release.
187203
- Edit the resulting notes to ensure they have decent messaging that are
188204
understandable by non-contributors, but each commit should still have it's
189205
own line.
190-
- Flip to the preview mode and review the pull request labels of the changes
191-
included in this release (i.e. `semver:minor` `semver:patch`,
192-
`semver:major`). Tip: Your release version should be based on the tag of
193-
the largest change, so if this release includes a `semver:minor`, the
194-
release version in your tag should be upgraded to reflect a minor.
195-
- Ensure that this version adheres to [semantic versioning](http://semver.org/). See
196-
[Versioning](#versioning-and-tags) for correct version format. Version tags
197-
should match the following pattern: `1.0.1` (no `v` preceding the number).
198-
199-
3. Set the "Target" input to the "main" branch.
200-
4. Name the release title after the version tag. The release title is what will
201-
be used by the pipeline to populate the value in `slack_cli_hooks/version.py`
202-
and the Pypi package version!
203-
5. Make any adjustments to generated release notes to make sure they are
206+
- Ensure that this version adheres to
207+
[semantic versioning](http://semver.org/). See
208+
[Versioning](#versioning-and-tags) for correct version format.
209+
210+
4. Set the "Target" input to the "main" branch.
211+
5. Name the release title after the version tag. It should match the updated
212+
value from `slack_cli_hooks/version.py`!
213+
6. Make any adjustments to generated release notes to make sure they are
204214
accessible and approachable and that an end-user with little context about
205215
this project could still understand.
206-
6. Publish the release by clicking the "Publish release" button!
207-
7. After a few minutes, the corresponding version will be available on
216+
7. Publish the release by clicking the "Publish release" button!
217+
8. After a few minutes, the corresponding version will be available on
208218
<https://pypi.org/project/slack-cli-hooks/>.
209-
8. (Slack Internal) Communicate the release internally
219+
9. (Slack Internal) Communicate the release internally
210220
- Include a link to the GitHub release
211-
9. (Slack Internal) Tweet by @SlackAPI
212-
- Not necessary for patch updates, might be needed for minor updates,
213-
definitely needed for major updates. Include a link to the GitHub release
221+
10. (Slack Internal) Tweet by @SlackAPI
222+
- Not necessary for patch updates, might be needed for minor updates,
223+
definitely needed for major updates. Include a link to the GitHub release
214224

215225
## Workflow
216226

.github/workflows/release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
run: |
2323
python -m build
2424
twine check dist/*
25-
env:
26-
SLACK_CLI_HOOKS_VERSION: ${{ github.event.release.name }}
2725
- name: Publish package
2826
run: twine upload dist/*
2927
env:

slack_cli_hooks/hooks/check_update.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def __init__(
3030
):
3131
self.name = name
3232
if current and latest:
33-
self.current = current.base_version
34-
self.latest = latest.base_version
33+
self.current = str(current)
34+
self.latest = str(latest)
3535
self.update = current < latest
36-
self.breaking = (current.major - latest.major) != 0
36+
self.breaking = (latest.major - current.major) > 0
3737
if error:
3838
self.error = error
3939
if message:

slack_cli_hooks/version.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
"""Check the latest version at https://pypi.org/project/slack-cli-hooks/"""
22

3-
import os
4-
5-
__version__ = os.environ.get("SLACK_CLI_HOOKS_VERSION", "0.0.0.dev0")
3+
__version__ = "0.0.0"

tests/slack_cli_hooks/hooks/test_check_update.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
import pytest
55

6+
from packaging.version import Version
67
from slack_cli_hooks.error import PypiError
78
from slack_cli_hooks.hooks import check_update
89
from slack_cli_hooks.hooks.check_update import (
10+
Release,
911
build_output,
1012
build_release,
1113
extract_latest_version,
@@ -16,7 +18,44 @@
1618
from tests.utils import build_fake_dependency, build_fake_pypi_urlopen
1719

1820

19-
class TestGetManifest:
21+
class TestRelease:
22+
test_project = "test_proj"
23+
24+
def setup_method(self):
25+
check_update.PROTOCOL = DefaultProtocol()
26+
27+
def test_release_with_same_version(self):
28+
release = Release(name=self.test_project, current=Version("0.0.0"), latest=Version("0.0.0"))
29+
assert release.current == release.latest
30+
assert release.breaking is False
31+
assert release.update is False
32+
33+
def test_release_with_diff_version(self):
34+
release = Release(name=self.test_project, current=Version("0.0.0"), latest=Version("0.0.1"))
35+
assert release.current == "0.0.0"
36+
assert release.latest == "0.0.1"
37+
assert release.breaking is False
38+
assert release.update is True
39+
40+
def test_release_with_dev(self):
41+
release = Release(name=self.test_project, current=Version("0.0.0"), latest=Version("0.0.0.dev0"))
42+
assert release.current == "0.0.0"
43+
assert release.latest == "0.0.0.dev0"
44+
assert release.breaking is False
45+
assert release.update is False
46+
47+
def test_release_with_downgrades(self):
48+
release = Release(name=self.test_project, current=Version("1.0.0"), latest=Version("0.0.0"))
49+
assert release.breaking is False
50+
assert release.update is False
51+
52+
def test_release_with_major_upgrade(self):
53+
release = Release(name=self.test_project, current=Version("0.0.0"), latest=Version("1.0.0"))
54+
assert release.breaking is True
55+
assert release.update is True
56+
57+
58+
class TestCheckUpdate:
2059
def setup_method(self):
2160
check_update.PROTOCOL = DefaultProtocol()
2261

0 commit comments

Comments
 (0)