-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from mikesongming/maint/13-release_triggered_c…
…i_&_publish release triggered ci & publish
- Loading branch information
Showing
4 changed files
with
159 additions
and
57 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,43 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
REV='0.7.1.post2+ga1b438c' | ||
N_REV='0.7.2' | ||
for pkg in `ls dist/* | grep ${REV}`; | ||
do | ||
n_pkg=`echo $pkg | awk -F "${REV}" "{print $1,${N_REV},$2}"` | ||
echo $pkg '->' $n_pkg | ||
done | ||
""" | ||
import os | ||
from pathlib import Path | ||
|
||
rev = os.environ.get("REV") | ||
next_rev = os.environ.get("N_REV") | ||
assert rev is not None, "env.REV is not set!" | ||
assert next_rev is not None, "env.N_REV is not set!" | ||
|
||
_script = Path(__file__) | ||
|
||
|
||
def rename_pkg(pkg): | ||
n_name = pkg.name.replace(rev, next_rev) | ||
n_pkg = pkg.parent.joinpath(n_name) | ||
print(n_pkg) | ||
pkg.rename(n_pkg) | ||
|
||
|
||
def main(): | ||
project_root = _script.parent.parent.parent | ||
dist = project_root.joinpath("dist") | ||
|
||
for pkg in dist.glob("*.tar.gz"): | ||
rename_pkg(pkg) | ||
|
||
for pkg in dist.glob("*.whl"): | ||
rename_pkg(pkg) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Publish to PYPI | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
required: true | ||
type: string | ||
is_release: | ||
required: true | ||
type: boolean | ||
rev: | ||
description: version of head ref | ||
default: '' | ||
required: false | ||
type: string | ||
next_rev: | ||
description: next version of head ref | ||
default: '' | ||
required: false | ||
type: string | ||
sdist_artifact: | ||
default: 'sdist' | ||
required: false | ||
type: string | ||
wheels_artifact: | ||
default: 'wheels' | ||
required: false | ||
type: string | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
pypa_publish: | ||
name: ✨ publish to PYPY | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ inputs.ref }} | ||
fetch-depth: 0 | ||
|
||
- name: Download sdist | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.sdist_artifact }} | ||
path: dist | ||
|
||
- name: Download all wheels | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ inputs.wheels_artifact }} | ||
path: dist | ||
|
||
- name: Rename packages | ||
if: ${{ ! inputs.is_release }} | ||
env: | ||
REV: ${{ inputs.rev }} | ||
N_REV: ${{ inputs.next_rev }} | ||
run: | | ||
python .github/scripts/rename_test_packages.py | ||
- name: Publish package to TestPyPI | ||
if: ${{ ! inputs.is_release }} | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
skip_existing: true | ||
print_hash: true | ||
|
||
- name: Publish package to PyPI | ||
if: ${{ inputs.is_release }} | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
skip_existing: true | ||
print_hash: 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