blob: 64d776a6a1c7b365d94d53e6d682899d67a675b3 (
plain)
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
|
name: Publish Release
run-name: "Publish Release"
on:
workflow_dispatch:
inputs:
pypi_target:
description: "PyPI repository to publish to"
required: true
type: choice
options:
- "test.pypi.org"
default: "test.pypi.org"
repo_release_ref:
description: "Gitlint git reference to publish release for"
default: "main"
jobs:
publish:
runs-on: "ubuntu-latest"
steps:
- name: Setup python
uses: actions/setup-python@v4.5.0
with:
python-version: "3.11"
- name: Install Hatch
run: python -m pip install hatch==1.6.3
- uses: actions/checkout@v3.3.0
with:
ref: ${{ inputs.repo_release_ref }}
fetch-depth: 0 # checkout all history, needed for hatch versioning
# Run hatch version once to avoid additional output ("Setting up build environment for missing dependencies")
# during the next step
- name: Hatch version
run: hatch version
# Hatch versioning is based on git (using hatch-vcs). If there is no explicit tag for the commit we're trying to
# publish, hatch versioning strings will have this format: 0.19.0.dev52+g9f7dc7d
# With the string after '+' being the 'g<short-sha>' of the commit.
#
# However, PyPI doesn't allow '+' in version numbers (no PEP440 local versions allowed on PyPI).
# To work around this, we override the version string by setting the SETUPTOOLS_SCM_PRETEND_VERSION env var
# to the version string without the '+' and everything after it.
# We then only actual publish such releases on the main branch to guarantee the dev numbering scheme remains
# unique.
# Note that when a tag *is* present (i.e. v0.19.0), hatch versioning will return the tag name (i.e. 0.19.0)
# and this step has no effect, ie. SETUPTOOLS_SCM_PRETEND_VERSION will be the same as `hatch version`.
- name: Set SETUPTOOLS_SCM_PRETEND_VERSION
run: |
echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(hatch version | cut -d+ -f1)" >> $GITHUB_ENV
- name: Build (gitlint-core)
run: hatch build
working-directory: ./gitlint-core
- name: Build (gitlint)
run: hatch build
- name: Publish (gitlint-core)
run: hatch publish -r test
working-directory: ./gitlint-core
env:
HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_GITLINT_CORE_USERNAME }}
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_GITLINT_CORE_PASSWORD }}
if: inputs.pypi_target == 'test.pypi.org' && inputs.repo_release_ref == 'main'
- name: Publish (gitlint)
run: hatch publish -r test
env:
HATCH_INDEX_USER: ${{ secrets.TEST_PYPI_GITLINT_USERNAME }}
HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_GITLINT_PASSWORD }}
if: inputs.pypi_target == 'test.pypi.org' && inputs.repo_release_ref == 'main'
check_env:
needs:
- publish
steps:
- name: Print SETUPTOOLS_SCM_PRETEND_VERSION
run: |
echo "$SETUPTOOLS_SCM_PRETEND_VERSION"
test_release:
needs:
- publish
uses: jorisroovers/gitlint/.github/workflows/test-release.yml@main
with:
gitlint_version: "0.19.0.dev51"
pypi_source: ${{ inputs.pypi_target }}
repo_test_ref: ${{ inputs.repo_release_ref }}
|