-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
380: Mechanized Release Process r=pathunstrom a=astronouth7303 Implements a mechanized release process. Under this, the release process would be: 1. Go to GitHub Release pages 2. Look at the diff since last version, compile changelog 3. On the GitHub site, create a tag/release with the changelog and any other release notes 4. Cirrus CI is responsible for building and uploading to PyPI and GitHub Additionally, dev releases are uploaded to PyPI test every time `master` is updated. Version numbers are no longer explicitly listed in the repo, instead being calculated based on the git tags. This code is a pretty direct copy from https://github.com/gqlmod/gqlmod (which is in part based on code that @duckinator wrote). @nbraud originally proposed this for PPB. Co-authored-by: Jamie Bliss <jamie@ivyleav.es>
- Loading branch information
Showing
7 changed files
with
163 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import glob | ||
import io | ||
import os | ||
import ssl | ||
import subprocess | ||
from urllib.request import urlopen | ||
import zipfile | ||
|
||
CIRRUS_BUILD_ID = os.environ['CIRRUS_BUILD_ID'] | ||
ARTIFACTS_URL = "https://api.cirrus-ci.com/v1/artifact/build/{}/build/dist.zip".format(CIRRUS_BUILD_ID) | ||
|
||
# Windows certificate validation fails. This is per PEP476 | ||
with urlopen(ARTIFACTS_URL, context=ssl._create_unverified_context()) as resp: | ||
zipdata = resp.read() | ||
|
||
with zipfile.ZipFile(io.BytesIO(zipdata)) as zf: | ||
zf.extractall() | ||
|
||
subprocess.run( | ||
['pip', 'install'] + glob.glob('dist/*.whl'), | ||
check=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/xonsh | ||
import io | ||
import sys | ||
import tempfile | ||
from urllib.request import urlopen, Request | ||
from urllib.error import HTTPError | ||
import zipfile | ||
|
||
$RAISE_SUBPROC_ERROR = True | ||
|
||
ARTIFACTS_URL = f"https://api.cirrus-ci.com/v1/artifact/build/{$CIRRUS_BUILD_ID}/build/dist.zip" | ||
PYPI_TEST_REPO = "https://test.pypi.org/legacy/" | ||
|
||
|
||
with tempfile.TemporaryDirectory() as td: | ||
cd @(td) | ||
|
||
with urlopen(ARTIFACTS_URL) as resp: | ||
zipdata = resp.read() | ||
|
||
with zipfile.ZipFile(io.BytesIO(zipdata)) as zf: | ||
# nl = zf.namelist() | ||
# print(f"Found {len(nl)} files from build:", *nl) | ||
zf.extractall() | ||
|
||
dists = [f for f in pg`**` if '+' not in f.name and f.is_file()] | ||
|
||
if not dists: | ||
print("No uploadable dists found, skipping upload") | ||
sys.exit(0) | ||
else: | ||
print("Found dists:", *dists) | ||
|
||
print("Uploading to test repo...") | ||
|
||
twine upload --repository-url @(PYPI_TEST_REPO) --username __token__ --password $TWINE_TEST_TOKEN @(dists) | ||
|
||
print("") | ||
|
||
if 'CIRRUS_RELEASE' in ${...}: | ||
print("Uploading to GitHub...") | ||
for dist in dists: | ||
print(f"\t{dist.name}...") | ||
dest_url = f"https://uploads.github.com/repos/{$CIRRUS_REPO_FULL_NAME}/releases/{$CIRRUS_RELEASE}/assets?name={dist.name}" | ||
with dist.open('rb') as fobj: | ||
buff = fobj.read() | ||
try: | ||
resp = urlopen(Request( | ||
url=dest_url, | ||
method='POST', | ||
data=buff, | ||
headers={ | ||
"Authorization": f"token {$GITHUB_TOKEN}", | ||
"Content-Type": "application/octet-stream", | ||
}, | ||
)) | ||
except HTTPError as exc: | ||
print(exc.headers) | ||
print(exc.read()) | ||
raise | ||
|
||
print("") | ||
|
||
print("Uploading to PyPI...") | ||
twine upload --username __token__ --password $TWINE_PROD_TOKEN @(dists) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[build-system] | ||
# Minimum requirements for the build system to execute. | ||
requires = ["setuptools", "wheel"] # PEP 508 specifications. | ||
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"] | ||
|
||
# Actually tell PEP517 tools to call setuptools | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters