Skip to content

Commit 902d583

Browse files
chore: automate release process (#1781)
1 parent 618808f commit 902d583

File tree

5 files changed

+219
-86
lines changed

5 files changed

+219
-86
lines changed

.github/maintainers_guide.md

Lines changed: 108 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ this project. If you use this package within your own software as is but don't p
1010

1111
We recommend using [pyenv](https://github.com/pyenv/pyenv) for Python runtime management. If you use macOS, follow the following steps:
1212

13-
```bash
14-
$ brew update
15-
$ brew install pyenv
13+
```sh
14+
brew update
15+
brew install pyenv
1616
```
1717

1818
You can hook `pyenv` into your shell automatically by running `pyenv init` and following the instructions.
@@ -23,7 +23,7 @@ GitHub Actions](https://github.com/slackapi/python-slack-sdk/blob/main/.github/w
2323
but make sure you are running at least one version that we execute our tests in
2424
locally so that you can run the tests yourself.
2525

26-
```bash
26+
```sh
2727
$ pyenv install -l | grep -v "-e[conda|stackless|pypy]"
2828

2929
$ pyenv install 3.9.6 # select the latest patch version
@@ -40,9 +40,9 @@ $ pyenv rehash
4040

4141
Then, you can create a new [Virtual Environment](https://docs.python.org/3/tutorial/venv.html) specific to the Python version you just installed by running:
4242

43-
```bash
44-
$ python -m venv env_3.9.6
45-
$ source env_3.9.6/bin/activate
43+
```sh
44+
python -m venv env_3.9.6
45+
source env_3.9.6/bin/activate
4646
```
4747

4848
At this point you have a clean, Python-version-specific environment "activated" for
@@ -55,8 +55,8 @@ run `source env_3.9.6/bin/activate` again.
5555

5656
The last step is to install this project's dependencies and run all unit tests; to do so, you can run
5757

58-
```bash
59-
$ ./scripts/run_validation.sh
58+
```sh
59+
./scripts/run_validation.sh
6060
```
6161

6262
Also check out [how
@@ -73,20 +73,20 @@ When you make changes to this SDK, please write unit tests verifying if the chan
7373

7474
Run all the unit tests, code formatter, and code analyzer:
7575

76-
```bash
77-
$ ./scripts/run_validation.sh
76+
```sh
77+
./scripts/run_validation.sh
7878
```
7979

8080
Run all the unit tests (no formatter nor code analyzer):
8181

82-
```bash
83-
$ ./scripts/run_unit_tests.sh
82+
```sh
83+
./scripts/run_unit_tests.sh
8484
```
8585

8686
Run a specific unit test:
8787

88-
```bash
89-
$ ./scripts/run_unit_tests.sh tests/web/test_web_client.py
88+
```sh
89+
./scripts/run_unit_tests.sh tests/web/test_web_client.py
9090
```
9191

9292
You can rely on GitHub Actions builds for running the tests on a variety of Python runtimes.
@@ -97,14 +97,14 @@ This project also has integration tests that verify the SDK works with the Slack
9797

9898
Run all integration tests:
9999

100-
```bash
101-
$ ./scripts/run_integration_tests.sh
100+
```sh
101+
./scripts/run_integration_tests.sh
102102
```
103103

104104
Run a specific integration test:
105105

106-
```bash
107-
$ ./scripts/run_integration_tests.sh integration_tests/web/test_async_web_client.py
106+
```sh
107+
./scripts/run_integration_tests.sh integration_tests/web/test_async_web_client.py
108108
```
109109

110110
#### Develop Locally
@@ -113,14 +113,14 @@ If you want to test the package locally you can.
113113

114114
1. Build the package locally
115115
- Run
116-
```bash
116+
```sh
117117
scripts/build_pypi_package.sh
118118
```
119119
- This will create a `.whl` file in the `./dist` folder
120120
2. Use the built package
121121
- Example `/dist/slack_sdk-1.2.3-py2.py3-none-any.whl` was created
122122
- From anywhere on your machine you can install this package to a project with
123-
```bash
123+
```sh
124124
pip install <project path>/dist/slack_sdk-1.2.3-py2.py3-none-any.whl
125125
```
126126
- It is also possible to include `slack_sdk @ file:///<project path>/dist/slack_sdk-1.2.3-py2.py3-none-any.whl` in a [requirements.txt](https://pip.pypa.io/en/stable/user_guide/#requirements-files) file
@@ -131,75 +131,109 @@ See [`/docs/README`](https://github.com/slackapi/python-slack-sdk/blob/main/docs
131131

132132
The API reference is generated from a script. You can generate and preview the **API _reference_ documents for `slack_sdk` package modules** by running:
133133

134-
```bash
135-
$ ./scripts/generate_api_docs.sh
134+
```sh
135+
./scripts/generate_api_docs.sh
136136
```
137137

138138
### Releasing
139139

140-
1. Create the commit for the release:
140+
#### test.pypi.org deployment
141141

142-
- Bump the version number in adherence to [Semantic Versioning](http://semver.org/) in `slack_sdk/version.py`.
143-
- Build the reference docs with `./scripts/generate_api_docs.sh`.
144-
- Create a branch for the release with `git checkout -b v2.5.0`
145-
- Make a commit that includes the new version number: `git commit -a -m 'version 2.5.0'`.
146-
- Open a PR and merge after receiving at least one approval from other maintainers.
142+
[TestPyPI](https://test.pypi.org/) is a separate instance of the Python Package
143+
Index that allows you to try distribution tools and processes without affecting
144+
the real index. This is particularly useful when making changes related to the
145+
package configuration itself, for example, modifications to the `pyproject.toml` file.
147146

148-
2. Distribute the release
147+
You can deploy this project to TestPyPI using GitHub Actions.
149148

150-
- Use the latest stable Python runtime
151-
- `python -m venv env`
152-
- `./scripts/deploy_to_prod_pypi_org.sh`
153-
- Create a new GitHub Release from the [Releases page](https://github.com/slackapi/python-slack-sdk/releases) by clicking the "Draft a new release" button.
154-
- Enter the new version number updated from the commit (e.g. `v2.5.0`) into the "Choose a tag" input.
155-
- Ensure the tag `Target` branch is `main` (e.g `Target:main`).
156-
- Click the "Create a new tag: x.x.x on publish" button. This won't create your tag immediately.
157-
- Name the release after the version number updated from the commit (e.g. `version 2.5.0`)
158-
- Auto-generate the release notes by clicking the "Auto-generate release
159-
notes" button. This will pull in changes that will be included in your
160-
release.
161-
- Edit the resulting notes to ensure they have decent messaging that are
162-
understandable by non-contributors, but each commit should still have it's
163-
own line.
164-
- Ensure that this version adheres to [semantic versioning][semver]. See
165-
[Versioning](#versioning-and-tags) for correct version format. Version tags
166-
should match the following pattern: `v2.5.0`.
149+
To deploy using GitHub Actions:
167150

168-
```markdown
169-
Refer to [v{version} milestone](https://github.com/slackapi/python-slack-sdk/milestone/{TODO}?closed=1) to know the complete list of the issues resolved by this release.
151+
1. Push your changes to a branch or tag
152+
2. Navigate to <https://github.com/slackapi/python-slack-sdk/actions/workflows/pypi-release.yml>
153+
3. Click on "Run workflow"
154+
4. Select your branch or tag from the dropdown
155+
5. Click "Run workflow" to build and deploy your branch to TestPyPI
170156

171-
**Updates**
157+
Alternatively, you can deploy from your local machine with:
172158

173-
1. [WebClient] #111 Make an awesome change - Thanks @SlackHQ
174-
2. [RTMClient] #222 Make an awesome change - Thanks @SlackAPI
175-
176-
**All Changes**
177-
178-
* All issues/pull requests: https://github.com/slackapi/python-slack-sdk/milestone/{milestone for the release}
179-
* All changes: https://github.com/slackapi/python-slack-sdk/compare/{the previous release version tag}...{the release version tag}
180-
```
181-
182-
- Close the milestone relating to the Release
183-
- Create the next patch version Milestone. To be used by the following release.
184-
185-
3. (Slack Internal) Communicate the release internally
186-
187-
- Include a link to the GitHub release
188-
189-
4. Make announcements
190-
191-
- #slack-api in dev4slack.slack.com
192-
- #lang-python in community.slack.com
193-
194-
5. (Slack Internal) Tweet by @SlackAPI
159+
```sh
160+
./scripts/deploy_to_test_pypi.sh
161+
```
195162

196-
- Not necessary for patch updates, might be needed for minor updates, definitely needed for major updates. Include a link to the GitHub release
163+
#### Development Deployment
164+
165+
Deploying a new version of this library to PyPI is triggered by publishing a GitHub Release.
166+
Before creating a new release, ensure that everything on a stable branch has
167+
landed, then [run the tests](#unit-tests).
168+
169+
1. Create the commit for the release
170+
1. In `slack_sdk/version.py` bump the version number in adherence to [Semantic Versioning](http://semver.org/) and [Developmental Release](https://peps.python.org/pep-0440/#developmental-releases).
171+
- Example: if the current version is `1.2.3`, a proper development bump would be `1.2.4.dev0`
172+
- `.dev` will indicate to pip that this is a [Development Release](https://peps.python.org/pep-0440/#developmental-releases)
173+
- Note that the `dev` version can be bumped in development releases: `1.2.4.dev0` -> `1.2.4.dev1`
174+
2. Build the docs with `./scripts/generate_api_docs.sh`.
175+
3. Commit with a message including the new version number. For example `1.2.4.dev0` & push the commit to a branch where the development release will live (create it if it does not exist)
176+
1. `git checkout -b future-release`
177+
2. `git commit -m 'chore(release): version 1.2.4.dev0'`
178+
3. `git push -u origin future-release`
179+
2. Create a new GitHub Release
180+
1. Navigate to the [Releases page](https://github.com/slackapi/python-slack-sdk/releases).
181+
2. Click the "Draft a new release" button.
182+
3. Set the "Target" to the feature branch with the development changes.
183+
4. Click "Tag: Select tag"
184+
5. Input a new tag name manually. The tag name must match the version in `slack_sdk/version.py` prefixed with "v" (e.g., if version is `1.2.4.dev0`, enter `v1.2.4.dev0`)
185+
6. Click the "Create a new tag" button. This won't create your tag immediately.
186+
7. Click the "Generate release notes" button.
187+
8. The release name should match the tag name!
188+
9. Edit the resulting notes to ensure they have decent messaging that is understandable by non-contributors, but each commit should still have its own line.
189+
10. Set this release as a pre-release.
190+
11. Publish the release by clicking the "Publish release" button!
191+
3. Navigate to the [release workflow run](https://github.com/slackapi/python-slack-sdk/actions/workflows/pypi-release.yml). You will need to approve the deployment!
192+
4. After a few minutes, the corresponding version will be available on <https://pypi.org/project/slack-sdk>.
193+
5. (Slack Internal) Communicate the release internally
194+
195+
#### Production Deployment
196+
197+
Deploying a new version of this library to PyPI is triggered by publishing a GitHub Release.
198+
Before creating a new release, ensure that everything on the `main` branch since
199+
the last tag is in a releasable state! At a minimum, [run the tests](#unit-tests).
200+
201+
1. Create the commit for the release
202+
1. In `slack_sdk/version.py` bump the version number in adherence to [Semantic Versioning](http://semver.org/) and the [Versioning](#versioning-and-tags) section.
203+
2. Build the docs with `./scripts/generate_api_docs.sh`.
204+
3. Commit with a message including the new version number. For example `1.2.3` & push the commit to a branch and create a PR to sanity check.
205+
1. `git checkout -b 1.2.3-release`
206+
2. `git commit -m 'chore(release): version 1.2.3'`
207+
3. `git push -u origin 1.2.3-release`
208+
4. Add relevant labels to the PR and add the PR to a GitHub Milestone.
209+
5. Merge in release PR after getting an approval from at least one maintainer.
210+
2. Create a new GitHub Release
211+
1. Navigate to the [Releases page](https://github.com/slackapi/python-slack-sdk/releases).
212+
2. Click the "Draft a new release" button.
213+
3. Set the "Target" to the `main` branch.
214+
4. Click "Tag: Select tag"
215+
5. Input a new tag name manually. The tag name must match the version in `slack_sdk/version.py` prefixed with "v" (e.g., if version is `1.2.3`, enter `v1.2.3`)
216+
6. Click the "Create a new tag" button. This won't create your tag immediately.
217+
7. Click the "Generate release notes" button.
218+
8. The release name should match the tag name!
219+
9. Edit the resulting notes to ensure they have decent messaging that is understandable by non-contributors, but each commit should still have its own line.
220+
10. Include a link to the current GitHub Milestone.
221+
11. Ensure the "latest release" checkbox is checked to mark this as the latest stable release.
222+
12. Publish the release by clicking the "Publish release" button!
223+
3. Navigate to the [release workflow run](https://github.com/slackapi/python-slack-sdk/actions/workflows/pypi-release.yml). You will need to approve the deployment!
224+
4. After a few minutes, the corresponding version will be available on <https://pypi.org/project/slack-sdk>.
225+
5. Close the current GitHub Milestone and create one for the next patch version.
226+
6. (Slack Internal) Communicate the release internally
227+
- Include a link to the GitHub release
228+
7. (Slack Internal) Tweet by @SlackAPI
229+
- Not necessary for patch updates, might be needed for minor updates,
230+
definitely needed for major updates. Include a link to the GitHub release
197231

198232
## Workflow
199233

200234
### Versioning and Tags
201235

202-
This project uses semantic versioning, expressed through the numbering scheme of
236+
This project uses [Semantic Versioning](http://semver.org/), expressed through the numbering scheme of
203237
[PEP-0440](https://www.python.org/dev/peps/pep-0440/).
204238

205239
### Branches

.github/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
2+
changelog:
3+
categories:
4+
- title: 🚀 Enhancements
5+
labels:
6+
- enhancement
7+
- title: 🐛 Bug Fixes
8+
labels:
9+
- bug
10+
- title: 📚 Documentation
11+
labels:
12+
- docs
13+
- title: 🤖 Build
14+
labels:
15+
- build
16+
- title: 🧪 Testing/Code Health
17+
labels:
18+
- code health
19+
- title: 🔒 Security
20+
labels:
21+
- security
22+
- title: 📦 Other changes
23+
labels:
24+
- "*"

.github/workflows/pypi-release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Upload A Release to pypi.org or test.pypi.org
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
inputs:
9+
dry_run:
10+
description: "Dry run (build only, do not publish)"
11+
required: false
12+
type: boolean
13+
14+
jobs:
15+
release-build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
20+
steps:
21+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22+
with:
23+
ref: ${{ github.event.release.tag_name || github.ref }}
24+
persist-credentials: false
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
28+
with:
29+
python-version: "3.x"
30+
31+
- name: Build release distributions
32+
run: |
33+
scripts/build_pypi_package.sh
34+
35+
- name: Persist dist folder
36+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
37+
with:
38+
name: release-dist
39+
path: dist/
40+
41+
test-pypi-publish:
42+
runs-on: ubuntu-latest
43+
needs:
44+
- release-build
45+
# Run this job for workflow_dispatch events when dry_run input is not 'true'
46+
# Note: The comparison is against a string value 'true' since GitHub Actions inputs are strings
47+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run != 'true'
48+
environment:
49+
name: testpypi
50+
permissions:
51+
id-token: write
52+
53+
steps:
54+
- name: Retrieve dist folder
55+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
56+
with:
57+
name: release-dist
58+
path: dist/
59+
60+
- name: Publish release distributions to test.pypi.org
61+
# Using OIDC for PyPI publishing (no API tokens needed)
62+
# See: https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-pypi
63+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
64+
with:
65+
repository-url: https://test.pypi.org/legacy/
66+
67+
pypi-publish:
68+
runs-on: ubuntu-latest
69+
needs:
70+
- release-build
71+
if: github.event_name == 'release'
72+
environment:
73+
name: pypi
74+
permissions:
75+
id-token: write
76+
77+
steps:
78+
- name: Retrieve dist folder
79+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
80+
with:
81+
name: release-dist
82+
path: dist/
83+
84+
- name: Publish release distributions to pypi.org
85+
# Using OIDC for PyPI publishing (no API tokens needed)
86+
# See: https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-pypi
87+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0

scripts/deploy_to_prod_pypi_org.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)