Skip to content

Commit 778b130

Browse files
authored
feat: Add convenient method to create apache release resource (#66)
After this patch merge, we can create apache release resource by `python setup.py sdist`, it will create tarball and sign it for us
1 parent ca5b00a commit 778b130

3 files changed

Lines changed: 38 additions & 22 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
__pycache__/
77
.tox/
88
.pytest_cache/
9+
MANIFEST
910

1011
# Build
1112
build/

RELEASE.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,8 @@ REMOTE=<REMOTE> # The git remote name, we usually use `origin` or `remote`
5252
git tag -a "${VERSION}" -m "Release v${VERSION}"
5353
git push "${REMOTE}" --tags
5454

55-
# Build
56-
python setup.py clean && python -m build
57-
58-
# Sign
59-
cd dist
60-
gpg --batch --yes --armor --detach-sig apache-dolphinscheduler-"${VERSION}".tar.gz
61-
gpg --batch --yes --armor --detach-sig apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl
62-
shasum -a 512 apache-dolphinscheduler-"${VERSION}".tar.gz > apache-dolphinscheduler-"${VERSION}".tar.gz.sha512
63-
shasum -b -a 512 apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl > apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.sha512
55+
# Build and sign according to the Apache requirements
56+
python setup.py clean && python setup.py sdist
6457
```
6558

6659
## Create Draft Release
@@ -75,7 +68,7 @@ based to the specific tag, and set it as pre-release.
7568
```shell
7669
svn co https://dist.apache.org/repos/dist/dev/dolphinscheduler/ release/dolphinscheduler
7770
mkdir -p release/dolphinscheduler/python/"${VERSION}"
78-
cp apache*dolphinscheduler-"${VERSION}"* release/dolphinscheduler/python/"${VERSION}"
71+
cp dolphinscheduler-python-src-"${VERSION}"* release/dolphinscheduler/python/"${VERSION}"
7972

8073
cd release/dolphinscheduler && svn add python && svn commit python -m "Release Apache DolphinScheduler-SDK-Python version ${VERSION}"
8174
```
@@ -99,7 +92,7 @@ The release candidates: https://dist.apache.org/repos/dist/dev/dolphinscheduler/
9992
10093
Git tag for the release: https://github.com/apache/dolphinscheduler-sdk-python/tree/<VERSION>
10194
102-
Release Commit ID: https://github.com/apache/dolphinscheduler-sdk-python/commit/02bc4f44cdd136622e403506f6474da0c7fa36fb
95+
Release Commit ID: https://github.com/apache/dolphinscheduler-sdk-python/commit/<commit-SHA>
10396
10497
Keys to verify the Release Candidate: https://dist.apache.org/repos/dist/dev/dolphinscheduler/KEYS
10598
@@ -130,22 +123,16 @@ Checklist for reference:
130123
```shell
131124
VERSION=<VERSION> # The version of the package you want to release, e.g. 1.2.3
132125
# Download source code
133-
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/apache-dolphinscheduler-"${VERSION}".tar.gz > apache-dolphinscheduler-"${VERSION}".tar.gz
134-
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/apache-dolphinscheduler-"${VERSION}".tar.gz.asc > apache-dolphinscheduler-"${VERSION}".tar.gz.asc
135-
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/apache-dolphinscheduler-"${VERSION}".tar.gz.sha512 > apache-dolphinscheduler-"${VERSION}".tar.gz.sha512
136-
# Download binary code
137-
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl > apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl
138-
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.asc > apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.asc
139-
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.sha512 > apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.sha512
126+
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/dolphinscheduler-python-src-"${VERSION}".tar.gz > dolphinscheduler-python-src-"${VERSION}".tar.gz
127+
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/dolphinscheduler-python-src-"${VERSION}".tar.gz.asc > dolphinscheduler-python-src-"${VERSION}".tar.gz.asc
128+
curl https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}"/dolphinscheduler-python-src-"${VERSION}".tar.gz.sha512 > dolphinscheduler-python-src-"${VERSION}".tar.gz.sha512
140129

141130
# Verify sha512
142-
sha512sum --check apache-dolphinscheduler-"${VERSION}".tar.gz.sha512
143-
sha512sum --check apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.sha512
131+
sha512sum --check dolphinscheduler-python-src-"${VERSION}".tar.gz.sha512
144132
# Verify gpg signature
145133
curl https://dist.apache.org/repos/dist/release/dolphinscheduler/KEYS > KEYS
146134
gpg --import KEYS
147-
gpg --verify apache-dolphinscheduler-"${VERSION}".tar.gz.asc
148-
gpg --verify apache_dolphinscheduler-"${VERSION}"-py3-none-any.whl.asc
135+
gpg --verify dolphinscheduler-python-src-"${VERSION}".tar.gz.asc
149136
```
150137

151138
Vote result should follow these:
@@ -176,7 +163,10 @@ Vote result should follow these:
176163
- Move source codes tar balls and distributions to https://dist.apache.org/repos/dist/release/dolphinscheduler/, **you can do this only if you are a PMC member**.
177164
178165
```shell
166+
# Move from dev to release
179167
svn mv https://dist.apache.org/repos/dist/dev/dolphinscheduler/python/"${VERSION}" https://dist.apache.org/repos/dist/release/dolphinscheduler/python/"${VERSION}"
168+
# Delete the old version
169+
svn delete -m "remove old release Python SDK" https://dist.apache.org/repos/dist/release/dolphinscheduler/python/<PREVIOUS-RELEASE-VERSION>
180170
```
181171
182172
- Update [GitHub release page](https://github.com/apache/dolphinscheduler-sdk-python/releases) and set it as formal release.

setup.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import logging
2020
import os
2121
import sys
22+
from distutils.command.sdist import sdist
2223
from distutils.dir_util import remove_tree
24+
from distutils.errors import DistutilsExecError
2325
from typing import List
2426

2527
from setuptools import Command, setup
@@ -63,8 +65,31 @@ def run(self) -> None:
6365
logger.info("Finish clean process.")
6466

6567

68+
class ApacheRelease(sdist):
69+
"""Command to make Apache release by running `python setup.py sdist`.
70+
71+
This command will make a tarball and also sign the tarball with gpg and sha512.
72+
"""
73+
74+
def run(self):
75+
"""Run and build tarball and sign."""
76+
super().run()
77+
version = self.distribution.metadata.get_version()
78+
target_name = f"dolphinscheduler-python-src-{version}.tar.gz"
79+
try:
80+
os.system(
81+
f"cd dist && "
82+
f"mv apache-dolphinscheduler-{version}.tar.gz {target_name} && "
83+
f"gpg --batch --yes --armor --detach-sig {target_name} && "
84+
f"shasum -a 512 {target_name} > {target_name}.sha512"
85+
)
86+
except DistutilsExecError as e:
87+
self.warn("Make dist and sign failed: %s" % e)
88+
89+
6690
setup(
6791
cmdclass={
6892
"clean": CleanCommand,
93+
"sdist": ApacheRelease,
6994
},
7095
)

0 commit comments

Comments
 (0)