Repository navigation
95 lines (91 loc) · 4.18 KB
/
Copy pathpython_deploy_prod.yml
File metadata and controls
95 lines (91 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Deploy python package in production
on:
release:
types: [published]
workflow_dispatch:
inputs:
publish-conda:
description: 'Publish Conda package'
required: false
type: boolean
default: true
publish-pypi:
description: 'Publish PyPI package'
required: false
type: boolean
default: true
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.release.tag_name || github.ref_name }}
cancel-in-progress: true
jobs:
# Fail-fast guard, so it fails here rather than in the downstream jobs.
validate-release-tag:
name: Validate release tag
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Ensure this run was triggered from a valid release tag
env:
EVENT_NAME: ${{ github.event_name }}
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
if [ "$EVENT_NAME" = "release" ]; then
echo "::notice::Triggered by published release '$RELEASE_TAG_NAME'."
elif [ "$EVENT_NAME" = "workflow_dispatch" ]; then
if [ "$REF_TYPE" != "tag" ]; then
echo "::error::This run was not triggered from a tag (ref_type=$REF_TYPE, ref_name=$REF_NAME). Re-run this workflow selecting the release tag under 'Use workflow from'."
exit 1
fi
if [[ "$REF_NAME" != v* ]]; then
echo "::error::Tag '$REF_NAME' does not look like a release tag (release tags must start with 'v'). Re-run this workflow selecting a valid release tag."
exit 1
fi
echo "::notice::Release tag '$REF_NAME' validated successfully."
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@b2de1e00a0be160d8cf6e14716825673070bf264 # v3.13.0
with:
virtual-repo-names: '["public-noremote-conda-prod"]'
release-tag: ${{ github.event.release.tag_name || 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)
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@b2de1e00a0be160d8cf6e14716825673070bf264 # v3.13.0
with:
package-name: 'surface-apps'
virtual-repo-names: '["public-pypi-prod"]'
release-tag: ${{ github.event.release.tag_name || github.ref_name }}
secrets:
JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }}
JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }}
publish-pypi-release:
name: Publish production Python package to PyPI
needs: [validate-release-tag, call-workflow-pypi-release]
if: ${{ (github.event_name == 'release' || github.event.inputs.publish-pypi == 'true') && needs.call-workflow-pypi-release.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Download release assets
uses: MiraGeoscience/CI-tools/.github/actions/reusable-python-download_dist_release@b2de1e00a0be160d8cf6e14716825673070bf264 # v3.13.0
with:
release-tag: ${{ github.event.release.tag_name || github.ref_name }}
github-token: ${{ secrets.GITHUB_TOKEN }}
# Must be a direct step (not in a reusable workflow or composite action), see
# https://docs.pypi.org/trusted-publishers/troubleshooting/#reusable-workflows-on-github
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
with:
packages-dir: dist-download/
repository-url: https://upload.pypi.org/legacy/