Python Package Publishing #21
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: Python Package Publishing | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Enter the new version for the package' | |
required: true | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: # Job-level permissions configuration starts here | |
contents: write # 'write' access to repository contents | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.7' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Update version in setup.py | |
run: | | |
sed -i "s/\"version\": \".*\"/\"version\": \"${{ github.event.inputs.version }}\"/" setup.py | |
- name: Update project URL, download URL, and release notes in setup.py | |
run: | | |
latest_version="${{ github.event.inputs.version }}" | |
latest_download_url="https://github.com/ingrammicro-xvantage/xi-sdk-resellers-python/archive/${latest_version}.tar.gz" | |
sed -i "s|download_url='https://github.com/ingrammicro-xvantage/xi-sdk-resellers-python/archive/.*.tar.gz'|download_url='${latest_download_url}'|" setup.py | |
- name: Commit and push changes | |
run: | | |
git config --global user.email "${{ secrets.ADMIN_EMAIL }}" | |
git config --global user.name "${{ secrets.ORG_NAME }}" | |
git add . | |
if git diff --exit-code; then | |
echo "No changes to commit." | |
else | |
git add . | |
git commit -m "Bump version to ${{ github.event.inputs.version }}" | |
git push https://${{secrets.WORKFLOW_TOKEN}}@github.com/ingrammicro-xvantage/xi-sdk-resellers-python main | |
fi | |
- name: Build package | |
run: python -m build | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} |