-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added wheel_rename to handle python tags in wheel distro
- Loading branch information
Showing
2 changed files
with
92 additions
and
66 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 |
---|---|---|
|
@@ -52,22 +52,54 @@ jobs: | |
PCAPKIT_TAG_EXISTS: ${{ steps.check_tag.outputs.exists }} | ||
PCAPKIT_CONDA_LABEL: ${{ steps.get_version.outputs.PCAPKIT_CONDA_LABEL }} | ||
|
||
pypi_github: | ||
name: PyPI & GitHub Release # with Python ${{ matrix.python-version }} | ||
github: | ||
name: GitHub Release | ||
runs-on: ubuntu-latest | ||
needs: [ version_check ] | ||
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false' }} | ||
# strategy: | ||
# matrix: | ||
# python-version: | ||
# - "3.7" | ||
# - "3.8" | ||
# - "3.9" | ||
# - "3.10" | ||
# - "3.11" | ||
# - "pypy3.7" | ||
# - "pypy3.8" | ||
# - "pypy3.9" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Changelog | ||
uses: Bullrich/generate-release-changelog@master | ||
id: changelog | ||
env: | ||
REPO: ${{ github.repository }} | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: ncipollo/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
# allowUpdates: true | ||
# artifacts: | | ||
# dist/* | ||
# body: ${{ env.PCAPKIT_CHANGELOG }} | ||
body: | | ||
${{ steps.changelog.outputs.changelog }} | ||
# generateReleaseNotes: true | ||
# makeLatest: true | ||
name: PyPCAPKit v${{ needs.version_check.outputs.PCAPKIT_VERSION }} | ||
prerelease: ${{ needs.version_check.outputs.PCAPKIT_PRERELEASE }} | ||
tag: "v${{ needs.version_check.outputs.PCAPKIT_VERSION }}" | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
pypi: | ||
name: PyPI distribution for Python ${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
needs: [ github, version_check ] | ||
if: ${{ startsWith(github.ref_name, 'v') || needs.version_check.outputs.PCAPKIT_TAG_EXISTS == 'false' }} | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.8" | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
@@ -76,7 +108,7 @@ jobs: | |
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' # ${{ matrix.python-version }} | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install and Setup | ||
run: | | ||
|
@@ -85,15 +117,19 @@ jobs: | |
python -m pip install -U pip setuptools wheel | ||
python -m pip install -U build | ||
- name: Build Package (latest) | ||
#if: ${{ matrix.python-version == '3.11' }} | ||
- name: Build Package | ||
env: | ||
PCAPKIT_VERSION: ${{ needs.version_check.outputs.PCAPKIT_VERSION }} | ||
run: | | ||
python -m build | ||
# - name: Build Package (others) | ||
# if: ${{ matrix.python-version != '3.11' }} | ||
# run: | | ||
# python -m build --wheel | ||
# rename wheel's python tag | ||
python util/wheel_rename.py dist/*.whl | ||
- name: No Source Distribution for Python ${{ matrix.python-version }} | ||
if: ${{ matrix.python-version != '3.11' }} | ||
run: | | ||
rm dist/*.tar.gz | ||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
@@ -108,52 +144,6 @@ jobs: | |
repository-url: https://test.pypi.org/legacy/ | ||
skip-existing: true | ||
|
||
- name: Changelog | ||
uses: Bullrich/generate-release-changelog@master | ||
id: changelog | ||
env: | ||
REPO: ${{ github.repository }} | ||
|
||
# run: | | ||
# # NOTE: inspired from Bullrich/generate-release-changelog | ||
# # https://github.com/Bullrich/generate-release-changelog/blob/master/entrypoint.sh | ||
|
||
# tag=$(git tag --sort version:refname | tail -n 2 | head -n 1) | ||
# echo tag=$tag | ||
|
||
# if [ "$tag" ]; then | ||
# changelog=$(git log --oneline --no-decorate $tag..HEAD) | ||
# else | ||
# changelog=$(git log --oneline --no-decorate) | ||
# fi | ||
|
||
# echo $changelog | ||
|
||
# changelog="${changelog//'%'/'%25'}" | ||
# changelog="${changelog//$'\n'/'%0A' - }" | ||
# changelog=" - ${changelog//$'\r'/'%0D'}" | ||
|
||
# echo "PCAPKIT_CHANGELOG=$changelog" >> $GITHUB_ENV | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: ncipollo/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
# allowUpdates: true | ||
artifacts: | | ||
dist/* | ||
# body: ${{ env.PCAPKIT_CHANGELOG }} | ||
body: | | ||
${{ steps.changelog.outputs.changelog }} | ||
# generateReleaseNotes: true | ||
# makeLatest: true | ||
name: PyPCAPKit v${{ needs.version_check.outputs.PCAPKIT_VERSION }} | ||
prerelease: ${{ needs.version_check.outputs.PCAPKIT_PRERELEASE }} | ||
tag: "v${{ needs.version_check.outputs.PCAPKIT_VERSION }}" | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
|
||
conda: | ||
name: Conda deployment of package with Python ${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
|
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,36 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import shutil | ||
import sys | ||
import warnings | ||
|
||
# python implementation | ||
MAP_IMPL = { | ||
'cpython': 'cp', | ||
'pypy': 'pp', | ||
} | ||
implementation = MAP_IMPL.get(sys.implementation.name) | ||
if implementation is None: | ||
raise ValueError(f'Unknown Python implementation: {sys.implementation.name}') | ||
python = f'{implementation}%s%s' % sys.version_info[:2] | ||
|
||
for file in sys.argv[1:]: | ||
root, name = os.path.split(file) | ||
if not name.endswith('.whl'): | ||
continue | ||
|
||
# wheel name format | ||
# {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl | ||
try: | ||
distribution, version, _, abi, platform = os.path.splitext(name)[0].split('-') | ||
except ValueError: | ||
warnings.warn(f'Unknown filename: {name}') | ||
continue | ||
|
||
if distribution != 'pypcapkit': | ||
warnings.warn(f'Unknown distribution: {distribution}') | ||
continue | ||
|
||
new_file = f'pypcapkit-{version}-{python}-{abi}-{platform}.whl' | ||
shutil.move(file, os.path.join(root, new_file)) |