release 0.4.7.post0 #5
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: Release Trigger | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- master | |
paths: | |
- 'pai/version.py' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
publish: | |
name: Release Trigger | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'releases/v') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.8' | |
- name: Check version match | |
id: check_version | |
run: | | |
BRANCH_VERSION=${{ github.head_ref }} | |
BRANCH_VERSION=${BRANCH_VERSION#releases/v} | |
FILE_VERSION=$(python -c "from pai.version import VERSION; print(VERSION)") | |
if [[ "$BRANCH_VERSION" != "$FILE_VERSION" ]]; then | |
echo "Version in branch name ($BRANCH_VERSION) does not match version in file ($FILE_VERSION)" | |
exit 1 | |
fi | |
- name: Get version and create version tag | |
run: | | |
VERSION=$(python -c "from pai.version import VERSION; print(VERSION)") | |
git tag v$VERSION | |
git push origin v$VERSION | |
# git tag pushed by GitHub action bot will not trigger another action. | |
- name: Install dependencies | |
run: pip install wheel setuptools twine | |
- name: Build package | |
run: python setup.py sdist bdist_wheel | |
- name: Publish package to PyPI | |
run: twine upload dist/* --skip-existing -u __token__ -p $PYPI_TOKEN |