Help to deploy only some versions #68
-
I want to be able to upload my packages to pypi when I create a release. But I don't want to do it on every release, just stable versions. I read your tip:
But I couldn't make it work. I tried with the if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') Could you help me to implement that. This is my current # This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload to PyPI
on:
release:
branches: [ main ]
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN_RUNUP }} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For this, create a separate step, analyze your version with Python, and set an output (see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter). Then, use that output in an if-clause later. Here's an example job that runs before all the others, for inspiration: https://github.com/ansible/pylibssh/blob/45d2199/.github/workflows/build-test-n-publish.yml#L32-L148. P.S. re: "I tried with the if you suggested but I couldn't deploy any package (tagged or not) when I added the if. This one" — this is because your clause expected the event to be |
Beta Was this translation helpful? Give feedback.
For this, create a separate step, analyze your version with Python, and set an output (see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter). Then, use that output in an if-clause later.
Here's an example job that runs before all the others, for inspiration: https://github.com/ansible/pylibssh/blob/45d2199/.github/workflows/build-test-n-publish.yml#L32-L148.
P.S. re: "I tried with the if you suggested but I couldn't deploy any package (tagged or not) when I added the if. This one" — this is because your clause expected the event to be
push
but your workflow only gets triggered onrelease
so the conditional is never true.