fix: Skip CLI installation if newer version is present (#51) #55
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: PyPi build and release | |
on: [push, workflow_dispatch] | |
jobs: | |
build: | |
name: PyPi build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install environment requirements | |
run: >- | |
python -m | |
pip install | |
-r | |
requirements.txt | |
- name: Run UTs | |
run: >- | |
python -m | |
unittest | |
discover | |
-v | |
- name: Install pypa/build | |
run: >- | |
python -m | |
pip install | |
build | |
--user | |
- name: Bump patch version | |
run: >- | |
python -c "from onepassword.utils import bump_version; bump_version(version_type='patch')" | |
- name: Build a source tarball | |
run: >- | |
python -m | |
build | |
--sdist | |
--outdir dist/ | |
. | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: source-code | |
path: dist/ | |
pypi-publish: | |
name: Pypi release | |
runs-on: ubuntu-latest | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: source-code | |
path: dist | |
- name: Display downloaded files | |
run: ls -R | |
working-directory: dist | |
- name: Publish distribution 📦 to Test PyPI | |
# Specifying a GitHub environment is optional, but strongly encouraged | |
if: ${{ github.ref != 'refs/heads/main' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish distribution 📦 to PyPI | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Add, commit and push version update | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git checkout main | |
pip install -e . | |
python -c "from onepassword.utils import bump_version; bump_version(version_type='patch')" | |
git add . | |
git commit -m "[actions skip] GitHub bumping the version" | |
git push |