diff --git a/.github/workflows/python_deploy_prod.yml b/.github/workflows/python_deploy_prod.yml index 199b32bef9..e1cd88158e 100644 --- a/.github/workflows/python_deploy_prod.yml +++ b/.github/workflows/python_deploy_prod.yml @@ -6,8 +6,8 @@ on: workflow_dispatch: inputs: release-tag: - description: 'Tag for the existing (draft) release to publish assets from' - required: true + description: 'Tag for the release to publish assets from (defaults to the tag this workflow run was triggered from)' + required: false publish-conda: description: 'Publish Conda package' required: false @@ -26,20 +26,35 @@ concurrency: cancel-in-progress: true jobs: + validate-release-tag: + name: Validate release tag + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Ensure a release tag is resolvable + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && \ + [ -z "${{ github.event.inputs.release-tag }}" ] && \ + [ "${{ github.ref_type }}" != "tag" ]; then + echo "::error::No 'release-tag' input was provided, and this run was not triggered from a tag (ref_type=${{ github.ref_type }}, ref_name=${{ github.ref_name }}). Re-run this workflow selecting the release tag under 'Use workflow from', or provide 'release-tag' manually." + exit 1 + fi call-workflow-conda-release: name: Publish production Conda package on JFrog Artifactory + needs: validate-release-tag if: ${{ github.event_name == 'release' || github.event.inputs.publish-conda == 'true' }} uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-release_conda_assets.yml@v3 permissions: contents: write with: virtual-repo-names: '["public-noremote-conda-prod"]' - release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag }} + release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag || github.ref_name }} secrets: JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} call-workflow-pypi-release: name: Publish production PyPI package (JFrog Artifactory, PyPI) + needs: validate-release-tag if: ${{ github.event_name == 'release' || github.event.inputs.publish-pypi == 'true' }} uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-release_pypi_assets.yml@v3 permissions: @@ -47,8 +62,8 @@ jobs: with: package-name: 'mira-simpeg' virtual-repo-names: '["public-pypi-prod", "pypi"]' - release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag }} + release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag || github.ref_name }} secrets: JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file