Publish tagged version #44
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: Publish tagged version | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Tag to publish (e.g. 'v0.1.11')" | |
required: true | |
type: string | |
index: | |
description: "Target index" | |
required: true | |
type: choice | |
default: "PyPI" | |
options: | |
- PyPI | |
- Artifactory | |
# need to grab org secrets for artifactory publish | |
env: | |
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }} | |
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
jobs: | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Check out tag | |
run: | | |
git fetch --tags | |
git checkout ${{ inputs.tag }} | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine | |
pip install importlib_metadata==7.2.1 | |
- name: Build Package | |
run: | | |
python -m build | |
- name: Publish to PyPI | |
if: ${{ inputs.index == 'PyPI' }} | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Publish to Artifactory | |
if: ${{ inputs.index == 'Artifactory' }} | |
env: | |
TWINE_USERNAME: ${{ secrets.ARTIFACTORY_USER }} | |
TWINE_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
TWINE_NON_INTERACTIVE: true | |
run: twine upload --verbose --repository-url='https://artifactory.corp.alleninstitute.org/artifactory/api/pypi/pypi-release-local' dist/* | |