-
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #4 from Erotemic/dev/pypi_deploy
Actions for sdist and pypi deployment
- Loading branch information
Showing
2 changed files
with
130 additions
and
5 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 |
---|---|---|
|
@@ -7,7 +7,6 @@ jobs: | |
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", pypy3] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Download submodules | ||
|
@@ -29,6 +28,51 @@ jobs: | |
run: | | ||
pytest | ||
build_sdist: | ||
name: Build source wheels | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
- name: Set up Python 3.8 | ||
uses: actions/[email protected] | ||
with: | ||
python-version: 3.8 | ||
- name: Upgrade pip | ||
run: |- | ||
python -m pip install --upgrade pip | ||
python -m pip install setuptools>=0.8 wheel build | ||
- name: Build sdist | ||
shell: bash | ||
run: |- | ||
python -m build --sdist --outdir wheelhouse | ||
- name: Install sdist | ||
run: |- | ||
ls -al ./wheelhouse | ||
pip install pytest pytest-cov | ||
pip install Cython | ||
pip install wheelhouse/*.tar.gz -v | ||
- name: Test sdist | ||
run: |- | ||
pwd | ||
ls -al | ||
# Run in a sandboxed directory | ||
WORKSPACE_DNAME="testsrcdir_minimal_${CI_PYTHON_VERSION}_${GITHUB_RUN_ID}_${RUNNER_OS}" | ||
mkdir -p $WORKSPACE_DNAME | ||
cd $WORKSPACE_DNAME | ||
# Get path to installed package | ||
MOD_NAME=lark_cython | ||
MOD_DPATH=$(python -c "import $MOD_NAME, os; print(os.path.dirname($MOD_NAME.__file__))") | ||
echo "MOD_DPATH = $MOD_DPATH" | ||
# Run the tests | ||
python -m pytest --cov=$MOD_NAME $MOD_DPATH ../tests | ||
cd .. | ||
- name: Upload sdist artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: wheels | ||
path: ./wheelhouse/*.tar.gz | ||
|
||
build_binary_wheels: | ||
name: ${{ matrix.os }}, arch=${{ matrix.arch }} | ||
runs-on: ${{ matrix.os }} | ||
|
@@ -99,3 +143,50 @@ jobs: | |
with: | ||
name: wheels | ||
path: ./wheelhouse/*.whl | ||
|
||
publish_wheels: | ||
name: Publish Wheels | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build_binary_wheels | ||
- build_sdist | ||
|
||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download wheels and sdist | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: wheels | ||
path: wheelhouse | ||
|
||
- name: Show files to upload | ||
shell: bash | ||
run: ls -la wheelhouse | ||
|
||
### See github action page for details | ||
# https://github.com/marketplace/actions/pypi-publish | ||
|
||
# ---- | ||
- name: Publish to Live PyPI | ||
# Only publish real wheels for new git tags. | ||
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
skip_existing: true | ||
#repository_url: https://upload.pypi.org/legacy/ # default url should be fine | ||
packages_dir: wheelhouse | ||
verbose: true | ||
|
||
# ---- | ||
- name: Publish to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
if: github.event_name == 'push' && ! startsWith(github.event.ref, 'refs/tags') | ||
with: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
skip_existing: true | ||
repository_url: https://test.pypi.org/legacy/ | ||
packages_dir: wheelhouse | ||
verbose: 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