Skip to content

Create template.txt and template-txt-to-json.py #11

Create template.txt and template-txt-to-json.py

Create template.txt and template-txt-to-json.py #11

Workflow file for this run

name: ci-pypi
# This workflow bumps the version of the package (do commit and tag),
# builds and uploads the package to PyPI, tests the installation under py3 and py2 from PyPI,
# and pushes the commit and tag to the branch `master`.
#
# This workflow is triggered by:
# - a manual trigger
# - a push to the repository with tags matching the pattern `ci-pypi` or `ci-pypi-*`
# the version part to bump can be specified in the tag name, e.g., `ci-pypi-major`
# the default version part to bump is `patch`
#
# This workflow should always be run against the branch `master`.
on:
workflow_dispatch:
inputs:
VERSION_PART:
description: 'Version part to bump: major, minor, patch, or suffix'
required: false
default: 'patch'
push:
tags:
- 'ci-pypi'
- 'ci-pypi-(major|minor|patch|suffix)'
jobs:
pypi-py3-build-and-upload:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12.3']
outputs:
NEW_VERSION: ${{ steps.bump-version.outputs.NEW_VERSION }}
steps:
- name: Get version part
run: |
case ${{ github.event_name }} in
workflow_dispatch)
version_part=${{ github.event.inputs.VERSION_PART }}
;;
push)
version_part=$(echo "${{ github.ref_name }}" | awk -F- '{print $3}')
version_part=${version_part:-patch}
;;
esac
echo "VERSION_PART=$version_part" >> $GITHUB_ENV
- 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: Set up git user
run: |
git config --global user.name "ci-pypi.github-actions[bot]"
git config --global user.email "ci-pypi.github.actions[bot]@noreply.github.com"
- name: Bump version and tag commit
id: bump-version
run: |
bump-my-version bump --verbose "${{ env.VERSION_PART }}"
current_version=$(bump-my-version show-bump | awk 'NR==1 {print $1}')
echo "NEW_VERSION=${current_version}" >> $GITHUB_ENV
echo "NEW_VERSION=${current_version}" >> $GITHUB_OUTPUT
- name: Build source and binary distributions
run: python -m build
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
- name: Push commit and tag
run: git push origin HEAD:master refs/tags/${{ env.NEW_VERSION }}
pypi-py3-install:
runs-on: ubuntu-latest
needs: pypi-py3-build-and-upload
strategy:
fail-fast: false
matrix:
python-version: ['3.12.3']
env:
NEW_VERSION: ${{ needs.pypi-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
- name: Install from binary distribution
uses: nick-invision/retry@v2
with:
timeout_minutes: 6
max_attempts: 3
retry_on: error
command: |
pip install --only-binary shadowsocks-manager shadowsocks-manager==${{ env.NEW_VERSION }}
- name: Clean up for installing source distribution
run: |
pip list --exclude pip | awk 'NR>2 {print $1}' | xargs pip uninstall -y
- name: Install from source distribution with PEP 517 required
uses: nick-invision/retry@v2
with:
timeout_minutes: 3
max_attempts: 3
retry_on: error
command: |
pip install --use-pep517 --no-binary shadowsocks-manager shadowsocks-manager==${{ env.NEW_VERSION }}
pypi-py2-install:
runs-on: ubuntu-latest
needs: pypi-py3-build-and-upload
container:
image: python:2.7
env:
NEW_VERSION: ${{ needs.pypi-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
uses: nick-invision/retry@v2
with:
timeout_minutes: 6
max_attempts: 3
retry_on: error
command: |
pip install --only-binary shadowsocks-manager shadowsocks-manager==${{ env.NEW_VERSION }}
- name: Clean up for installing source distribution
run: |
pip list --exclude pip --exclude setuptools --exclude wheel | awk 'NR>2 {print $1}' | xargs pip uninstall -y
- name: Install from source distribution with setuptools and wheel required
uses: nick-invision/retry@v2
with:
timeout_minutes: 3
max_attempts: 3
retry_on: error
command: |
pip install --no-build-isolation --no-binary shadowsocks-manager shadowsocks-manager==${{ env.NEW_VERSION }}