| 1 |
name: Publish Release |
| 2 |
run-name: "Publish Release (pypi_target=${{ inputs.pypi_target }}, repo_release_ref=${{ inputs.repo_release_ref }})" |
| 3 |
|
| 4 |
on: |
| 5 |
|
| 6 |
workflow_call: |
| 7 |
inputs: |
| 8 |
pypi_target: |
| 9 |
description: "PyPI repository to publish to" |
| 10 |
required: true |
| 11 |
type: string |
| 12 |
default: "test.pypi.org" |
| 13 |
repo_release_ref: |
| 14 |
description: "Gitlint git reference to publish release for" |
| 15 |
type: string |
| 16 |
default: "main" |
| 17 |
|
| 18 |
|
| 19 |
workflow_dispatch: |
| 20 |
inputs: |
| 21 |
pypi_target: |
| 22 |
description: "PyPI repository to publish to" |
| 23 |
required: true |
| 24 |
type: choice |
| 25 |
options: |
| 26 |
- "pypi.org" |
| 27 |
- "test.pypi.org" |
| 28 |
default: "test.pypi.org" |
| 29 |
repo_release_ref: |
| 30 |
description: "Gitlint git reference to publish release for" |
| 31 |
type: string |
| 32 |
default: "main" |
| 33 |
|
| 34 |
jobs: |
| 35 |
publish: |
| 36 |
timeout-minutes: 15 |
| 37 |
runs-on: "ubuntu-latest" |
| 38 |
outputs: |
| 39 |
gitlint_version: ${{ steps.set_version.outputs.gitlint_version }} |
| 40 |
steps: |
| 41 |
- name: Setup python |
| 42 |
uses: actions/[email protected] |
| 43 |
with: |
| 44 |
python-version: "3.11" |
| 45 |
|
| 46 |
- name: Install pypa/build |
| 47 |
run: python -m pip install build==0.10.0 |
| 48 |
|
| 49 |
- name: Install Hatch |
| 50 |
run: python -m pip install hatch==1.6.3 |
| 51 |
|
| 52 |
- uses: actions/[email protected] |
| 53 |
with: |
| 54 |
ref: ${{ inputs.repo_release_ref }} |
| 55 |
fetch-depth: 0 |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
- name: Hatch version |
| 60 |
run: hatch version |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
- name: Set SETUPTOOLS_SCM_PRETEND_VERSION |
| 77 |
id: set_version |
| 78 |
run: | |
| 79 |
echo "gitlint_version=$(hatch version | cut -d+ -f1)" >> $GITHUB_OUTPUT |
| 80 |
|
| 81 |
- name: Build (gitlint-core) |
| 82 |
run: python -m build |
| 83 |
working-directory: ./gitlint-core |
| 84 |
env: |
| 85 |
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.set_version.outputs.gitlint_version }} |
| 86 |
|
| 87 |
- name: Build (gitlint) |
| 88 |
run: python -m build |
| 89 |
env: |
| 90 |
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ steps.set_version.outputs.gitlint_version }} |
| 91 |
|
| 92 |
- name: Publish gitlint-core (pypi.org) |
| 93 |
run: hatch publish |
| 94 |
working-directory: ./gitlint-core |
| 95 |
env: |
| 96 |
HATCH_INDEX_USER: ${{ secrets.PYPI_GITLINT_CORE_USERNAME }} |
| 97 |
HATCH_INDEX_AUTH: ${{ secrets.PYPI_GITLINT_CORE_PASSWORD }} |
| 98 |
if: inputs.pypi_target == 'pypi.org' |
| 99 |
|
| 100 |
- name: Publish gitlint (pypi.org) |
| 101 |
run: hatch publish |
| 102 |
env: |
| 103 |
HATCH_INDEX_USER: ${{ secrets.PYPI_GITLINT_USERNAME }} |
| 104 |
HATCH_INDEX_AUTH: ${{ secrets.PYPI_GITLINT_PASSWORD }} |
| 105 |
if: inputs.pypi_target == 'pypi.org' |
| 106 |
|
| 107 |
- name: Publish gitlint-core (test.pypi.org) |
| 108 |
run: hatch publish -r test |
| 109 |
working-directory: ./gitlint-core |
| 110 |
env: |
| 111 |
HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_GITLINT_CORE_USERNAME }} |
| 112 |
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_GITLINT_CORE_PASSWORD }} |
| 113 |
if: inputs.pypi_target == 'test.pypi.org' |
| 114 |
|
| 115 |
- name: Publish gitlint (test.pypi.org) |
| 116 |
run: hatch publish -r test |
| 117 |
env: |
| 118 |
HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_GITLINT_USERNAME }} |
| 119 |
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_GITLINT_PASSWORD }} |
| 120 |
if: inputs.pypi_target == 'test.pypi.org' |
| 121 |
|
| 122 |
|
| 123 |
wait-for-package: |
| 124 |
needs: |
| 125 |
- publish |
| 126 |
runs-on: "ubuntu-latest" |
| 127 |
steps: |
| 128 |
- name: Install gitlint |
| 129 |
uses: nick-fields/[email protected] |
| 130 |
with: |
| 131 |
timeout_minutes: 1 |
| 132 |
max_attempts: 10 |
| 133 |
command: | |
| 134 |
python -m pip install gitlint==${{ needs.publish.outputs.gitlint_version }} |
| 135 |
if: inputs.pypi_target == 'pypi.org' |
| 136 |
|
| 137 |
- name: Install gitlint (test.pypi.org) |
| 138 |
uses: nick-fields/[email protected] |
| 139 |
with: |
| 140 |
timeout_minutes: 1 |
| 141 |
max_attempts: 10 |
| 142 |
command: | |
| 143 |
pip install --no-cache-dir -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple gitlint==${{ needs.publish.outputs.gitlint_version }} |
| 144 |
if: inputs.pypi_target == 'test.pypi.org' |
| 145 |
|
| 146 |
- name: gitlint --version |
| 147 |
run: | |
| 148 |
gitlint --version |
| 149 |
[ "$(gitlint --version)" == "gitlint, version ${{ needs.publish.outputs.gitlint_version }}" ] |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
- name: Sleep |
| 155 |
run: sleep 600 |
| 156 |
|
| 157 |
test-release: |
| 158 |
needs: |
| 159 |
- publish |
| 160 |
- wait-for-package |
| 161 |
uses: ./.github/workflows/test-release.yml |
| 162 |
with: |
| 163 |
gitlint_version: ${{ needs.publish.outputs.gitlint_version }} |
| 164 |
pypi_source: ${{ inputs.pypi_target }} |
| 165 |
repo_test_ref: ${{ inputs.repo_release_ref }} |
| 166 |
|
| 167 |
publish-docker: |
| 168 |
needs: |
| 169 |
- publish |
| 170 |
- test-release |
| 171 |
uses: ./.github/workflows/publish-docker.yml |
| 172 |
secrets: inherit |
| 173 |
with: |
| 174 |
gitlint_version: ${{ needs.publish.outputs.gitlint_version }} |
| 175 |
docker_image_tag: "latest_dev" |
| 176 |
push_to_dockerhub: true |