mirror of
https://github.com/espressif/esptool.git
synced 2025-10-16 23:06:31 +08:00
feat(ci): Publish development releases with custom pipeline
This commit is contained in:
@@ -6,6 +6,7 @@ stages:
|
||||
- report
|
||||
- build_docs
|
||||
- deploy_docs
|
||||
- deploy_development_package
|
||||
|
||||
# cache the pip download directory in all jobs
|
||||
variables:
|
||||
@@ -366,3 +367,26 @@ deploy_docs_production:
|
||||
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
|
||||
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
|
||||
DOCS_DEPLOY_URL_BASE: "https://docs.espressif.com/projects/esptool"
|
||||
|
||||
deploy_dev_package:
|
||||
<<: *test_template
|
||||
rules:
|
||||
- if: $CI_DEV_PUBLISH != null
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
variables:
|
||||
TWINE_NON_INTERACTIVE: "true"
|
||||
TWINE_USERNAME: __token__
|
||||
TWINE_PASSWORD: ${PYPI_ESPTOOL_TOKEN}
|
||||
stage: deploy_development_package
|
||||
dependencies: []
|
||||
script:
|
||||
- python -m pip install --upgrade pip
|
||||
- python -m pip install twine setuptools
|
||||
- python ci/patch_dev_release.py --dev-no ${CI_DEV_PUBLISH} esptool/__init__.py
|
||||
# check what has been changed with git
|
||||
- git diff
|
||||
- python setup.py sdist
|
||||
# skip release if it has already been released (with failure)
|
||||
- python -m pip download esptool==$(python setup.py -V) && exit 1
|
||||
- tar -ztvf dist/*
|
||||
- python -m twine upload dist/*
|
||||
|
43
ci/patch_dev_release.py
Normal file
43
ci/patch_dev_release.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import argparse
|
||||
import re
|
||||
|
||||
LINE_RE = re.compile(r"^__version__ = ['\"]([^'\"]*)['\"]")
|
||||
NEW_LINE = '__version__ = "{}"'
|
||||
|
||||
|
||||
def get_new_version(old_version, dev_number):
|
||||
assert old_version.endswith("-dev")
|
||||
return old_version.replace("-dev", ".dev{}".format(dev_number), 1)
|
||||
|
||||
|
||||
def patch_file(path, dev_number):
|
||||
with open(path, "r") as fin:
|
||||
lines = fin.readlines()
|
||||
|
||||
for i, line in enumerate(lines, start=0):
|
||||
m = LINE_RE.search(line)
|
||||
if m:
|
||||
old_version = m.group(1)
|
||||
lines[i] = NEW_LINE.format(get_new_version(old_version, dev_number))
|
||||
break
|
||||
|
||||
with open(path, "w") as fout:
|
||||
fout.writelines(lines)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("file", help="Path to script with __version__")
|
||||
parser.add_argument(
|
||||
"--dev-no", type=int, help="Number N to patch the version to '.devN'"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
patch_file(args.file, args.dev_no)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user