1
1
name : Publish Release
2
- run-name : " Publish Release (pypi_target =${{ inputs.pypi_target }}, repo_release_ref=${{ inputs.repo_release_ref }})"
2
+ run-name : " Publish Release (environment =${{ inputs.environment }}, repo_release_ref=${{ inputs.repo_release_ref }})"
3
3
4
4
on :
5
5
# Trigger release workflow from other workflows (e.g. release dev build as part of CI)
6
6
workflow_call :
7
7
inputs :
8
- pypi_target :
9
- description : " PyPI repository to publish to"
10
- required : true
8
+ environment :
9
+ description : " Target environment"
11
10
type : string
12
- default : " test.pypi.org "
11
+ required : true
13
12
repo_release_ref :
14
13
description : " Gitlint git reference to publish release for"
15
14
type : string
23
22
# Manually trigger a release
24
23
workflow_dispatch :
25
24
inputs :
26
- pypi_target :
27
- description : " PyPI repository to publish to"
25
+ environment :
26
+ description : " Target environment"
27
+ type : environment
28
28
required : true
29
- type : choice
30
- options :
31
- - " pypi.org"
32
- - " test.pypi.org"
33
- default : " test.pypi.org"
34
29
repo_release_ref :
35
30
description : " Gitlint git reference to publish release for"
36
31
type : string
49
44
publish :
50
45
timeout-minutes : 15
51
46
runs-on : " ubuntu-latest"
47
+ environment : ${{ inputs.environment }}
52
48
permissions :
53
49
# Required for trusted publishing to PyPI
54
50
id-token : write
@@ -110,27 +106,16 @@ jobs:
110
106
uses : pypa/gh-action-pypi-publish@release/v1
111
107
with :
112
108
packages-dir : gitlint-core/dist/
113
- if : inputs.pypi_target == 'pypi.org'
109
+ repository-url : ${{ vars.PYPI_TARGET }} # PYPI_TARGET is defined in the GHA environment
114
110
115
111
- name : Publish gitlint 🐍📦 to PyPI
116
- uses : pypa/gh-action-pypi-publish@release/v1
117
- if : inputs.pypi_target == 'pypi.org'
118
-
119
- - name : Publish gitlint-core 🐍📦 to TestPyPI
120
- uses : pypa/gh-action-pypi-publish@release/v1
121
- with :
122
- packages-dir : gitlint-core/dist/
123
- repository-url : https://test.pypi.org/legacy/
124
- if : inputs.pypi_target == 'test.pypi.org'
125
-
126
- - name : Publish gitlint 🐍📦 to TestPyPI
127
112
uses : pypa/gh-action-pypi-publish@release/v1
128
113
with :
129
- repository-url : https://test.pypi.org/legacy/
130
- if : inputs.pypi_target == 'test.pypi.org'
114
+ repository-url : ${{ vars.PYPI_TARGET }} # PYPI_TARGET is defined in the GHA environment
131
115
132
116
# Wait for gitlint package to be available in PyPI for installation
133
117
wait-for-package :
118
+ environment : ${{ inputs.environment }}
134
119
needs :
135
120
- publish
136
121
runs-on : " ubuntu-latest"
@@ -140,18 +125,10 @@ jobs:
140
125
with :
141
126
timeout_minutes : 1
142
127
max_attempts : 10
128
+ # We need to add the --extra-index-url to the pip install command to deal with PYPI_TARGET=https://test.pypi.org/legacy,
129
+ # because gitlint's dependencies are not available on Test PyPI
143
130
command : |
144
- python -m pip install gitlint==${{ needs.publish.outputs.gitlint_version }}
145
- if : inputs.pypi_target == 'pypi.org'
146
-
147
- - name : Install gitlint (test.pypi.org)
148
- uses : nick-fields/retry@v2.8.3
149
- with :
150
- timeout_minutes : 1
151
- max_attempts : 10
152
- command : |
153
- pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple gitlint==${{ needs.publish.outputs.gitlint_version }}
154
- if : inputs.pypi_target == 'test.pypi.org'
131
+ python -m pip install --no-cache-dir -i ${{ vars.PYPI_TARGET }} --extra-index-url https://pypi.org/simple gitlint==${{ needs.publish.outputs.gitlint_version }}
155
132
156
133
- name : gitlint --version
157
134
run : |
@@ -171,7 +148,7 @@ jobs:
171
148
uses : ./.github/workflows/test-release.yml
172
149
with :
173
150
gitlint_version : ${{ needs.publish.outputs.gitlint_version }}
174
- pypi_source : ${{ inputs.pypi_target }}
151
+ environment : ${{ inputs.environment }}
175
152
repo_test_ref : ${{ inputs.repo_release_ref }}
176
153
177
154
publish-docker :
0 commit comments