Skip to content
22 changes: 17 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
description: "Confirm publish package"
required: true
type: boolean
docs_only:

Check notice on line 10 in .github/workflows/publish.yml

View check run for this annotation

Autodesk Chorus / security/checkov

CKV_GHA_7

The build output cannot be affected by user parameters other than the build entry point and the top-level source location. GitHub Actions workflow_dispatch inputs MUST be empty.
description: "Only publish documentation (skip package publish)"
required: false
type: boolean
default: false

jobs:
guard-ci-success:
Expand Down Expand Up @@ -77,9 +82,16 @@
with:
python-version: '3.13'

- name: Install dependencies for docs
if: ${{ github.event.inputs.docs_only == 'true' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Check if version exists on PyPI
id: pypi_check
shell: pwsh
if: ${{ github.event.inputs.docs_only != 'true' }}
run: |
$packageName = 'moldflow'

Expand All @@ -100,30 +112,30 @@
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8

- name: Skip publish, version already exists
if: steps.pypi_check.outputs.exists == 'true'
if: ${{ github.event.inputs.docs_only != 'true' && steps.pypi_check.outputs.exists == 'true' }}
run: Write-Output "Version ${{ steps.pypi_check.outputs.version }} already exists on PyPI. Skipping publish."

- name: Install build dependencies
if: steps.pypi_check.outputs.exists == 'false'
if: ${{ github.event.inputs.docs_only != 'true' && steps.pypi_check.outputs.exists == 'false' }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Build package
if: steps.pypi_check.outputs.exists == 'false'
if: ${{ github.event.inputs.docs_only != 'true' && steps.pypi_check.outputs.exists == 'false' }}
run: |
python run.py build

- name: Publish to PyPI
if: steps.pypi_check.outputs.exists == 'false'
if: ${{ github.event.inputs.docs_only != 'true' && steps.pypi_check.outputs.exists == 'false' }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python run.py publish --skip-build

- name: Create GitHub Release
if: steps.pypi_check.outputs.exists == 'false'
if: ${{ github.event.inputs.docs_only != 'true' && steps.pypi_check.outputs.exists == 'false' }}
run: |
python run.py release
env:
Expand Down
Loading