Update dependencies and installation process in ci-testpypi.yml #6
Workflow file for this run
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
name: ci-testpypi | |
on: | |
push: | |
paths: | |
- '.github/workflows/ci-testpypi.yml' | |
- 'pyproject.toml' | |
workflow_run: | |
workflows: ["ci-unittest"] | |
types: | |
- completed | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }} | |
PROJECT_NAME_FOR_TESTPYPI: shadowsocks-manager-alexzhangs | |
jobs: | |
testpypi-py3-build-and-upload: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }} | |
outputs: | |
new_version: ${{ steps.bump-version.outputs.new_version }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.12.3'] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install build twine bump-my-version | |
- name: Update project name to avoid naming conflict in TestPyPI | |
run: | | |
sed -i 's/^name = .*/name = "${{ env.PROJECT_NAME_FOR_TESTPYPI }}"/' pyproject.toml | |
- name: Bump version without commit and tag | |
id: bump-version | |
run: | | |
current_version=$(bump-my-version show-bump | awk 'NR==1 {print $1}') | |
new_versoin="${current_version}.$(date +%Y%m%d%H%M)" | |
bump-my-version bump --verbose --no-commit --no-tag --new-version "${new_versoin}" suffix | |
echo "::set-output name=new_version::${new_versoin}" | |
- name: Build source and binary distributions | |
run: python -m build | |
- name: Upload to TestPyPI | |
run: twine upload --repository testpypi dist/* | |
testpypi-py3-install: | |
runs-on: ubuntu-latest | |
needs: testpypi-py3-build-and-upload | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.12.3'] | |
env: | |
NEW_VERSION: ${{ needs.testpypi-py3-build-and-upload.outputs.new_version }} | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install setuptools wheel | |
- name: Install from binary distribution | |
env: | |
PIP_INDEX_URL: https://test.pypi.org/simple/ | |
run: | | |
pip install --no-deps --only-binary ${{ env.PROJECT_NAME_FOR_TESTPYPI }} ${{ env.PROJECT_NAME_FOR_TESTPYPI }}==${{ env.NEW_VERSION }} | |
- name: Clean up for installing source distribution | |
run: | | |
pip uninstall -y ${{ env.PROJECT_NAME_FOR_TESTPYPI }} | |
- name: Install from source distribution with setuptools and wheel required | |
env: | |
PIP_INDEX_URL: https://test.pypi.org/simple/ | |
run: | | |
pip install --no-build-isolation --no-deps --no-binary ${{ env.PROJECT_NAME_FOR_TESTPYPI }} ${{ env.PROJECT_NAME_FOR_TESTPYPI }}==${{ env.NEW_VERSION }} | |
testpypi-py2-install: | |
runs-on: ubuntu-latest | |
needs: testpypi-py3-build-and-upload | |
container: | |
image: python:2.7 | |
env: | |
NEW_VERSION: ${{ needs.testpypi-py3-build-and-upload.outputs.new_version }} | |
steps: | |
- name: Install dependencies | |
run: | | |
pip install --upgrade pip | |
pip install setuptools wheel | |
- name: Install from binary distribution | |
env: | |
PIP_INDEX_URL: https://test.pypi.org/simple/ | |
run: | | |
pip install --no-deps --only-binary ${{ env.PROJECT_NAME_FOR_TESTPYPI }} ${{ env.PROJECT_NAME_FOR_TESTPYPI }}==${{ env.NEW_VERSION }} | |
- name: Clean up for install source distribution | |
run: | | |
pip uninstall -y ${{ env.PROJECT_NAME_FOR_TESTPYPI }} | |
- name: Install from source distribution with setuptools and wheel required | |
env: | |
PIP_INDEX_URL: https://test.pypi.org/simple/ | |
run: | | |
pip install --no-build-isolation --no-deps --no-binary ${{ env.PROJECT_NAME_FOR_TESTPYPI }} ${{ env.PROJECT_NAME_FOR_TESTPYPI }}==${{ env.NEW_VERSION }} |