Skip to content

Commit 2809406

Browse files
committed
Enable test.pypi.org publishing
1 parent d1a41a3 commit 2809406

File tree

2 files changed

+61
-63
lines changed

2 files changed

+61
-63
lines changed

.github/workflows/pypi-package.yml

+58-63
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,72 @@
11
---
2-
name: Build & maybe upload PyPI package
2+
name: Build & maybe upload PyPI package
33

4-
on:
5-
push:
6-
branches: [main]
7-
tags: ["*"]
8-
release:
9-
types:
10-
- published
11-
workflow_dispatch:
4+
on:
5+
push:
6+
branches: [main]
7+
tags: ["*"]
8+
release:
9+
types:
10+
- published
11+
workflow_dispatch:
1212

13-
permissions:
14-
contents: read
15-
id-token: write
13+
permissions:
14+
contents: read
15+
id-token: write
1616

17-
env:
18-
FORCE_COLOR: "1" # Make tools pretty.
19-
PIP_DISABLE_PIP_VERSION_CHECK: "1"
20-
PIP_NO_PYTHON_VERSION_WARNING: "1"
17+
env:
18+
FORCE_COLOR: "1" # Make tools pretty.
19+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
20+
PIP_NO_PYTHON_VERSION_WARNING: "1"
2121

22-
jobs:
23-
# Always build & lint package.
24-
build-package:
25-
name: Build & verify package
26-
runs-on: ubuntu-latest
2722

28-
steps:
29-
- name: Set version
30-
if: github.event_name == 'push' && github.ref == 'refs/head/main'
31-
run: |
32-
echo "SETUPTOOLS_SCM_PRETEND_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
23+
jobs:
24+
# Always build & lint package.
25+
build-package:
26+
name: Build & verify package
27+
runs-on: ubuntu-latest
3328

29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
3433

35-
- uses: actions/checkout@v4
36-
with:
37-
fetch-depth: 0
34+
- uses: hynek/build-and-inspect-python-package@v2
3835

39-
- uses: hynek/build-and-inspect-python-package@v2
36+
# Upload to Test PyPI on every commit on main.
37+
release-test-pypi:
38+
name: Publish in-dev package to test.pypi.org
39+
if: github.repository_owner == 'alexrudy' && github.event_name == 'push' && github.ref == 'refs/heads/main'
40+
environment: test-pypi-release
41+
runs-on: ubuntu-latest
42+
needs: build-package
4043

41-
# Upload to Test PyPI on every commit on main.
42-
release-test-pypi:
43-
name: Publish in-dev package to test.pypi.org
44-
if: github.repository_owner == 'alexrudy' && github.ref == 'refs/head/main'
45-
environment: test-pypi-release
46-
runs-on: ubuntu-latest
47-
needs: build-package
44+
steps:
45+
- name: Download packages built by build-and-inspect-python-package
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: Packages
49+
path: dist
4850

49-
steps:
50-
- name: Download packages built by build-and-inspect-python-package
51-
uses: actions/download-artifact@v4
52-
with:
53-
name: Packages
54-
path: dist
51+
- name: Upload package to Test PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
with:
54+
repository-url: https://test.pypi.org/legacy/
5555

56-
- name: Upload package to Test PyPI
57-
uses: pypa/gh-action-pypi-publish@release/v1
58-
with:
59-
repository-url: https://test.pypi.org/legacy/
56+
# Upload to real PyPI on GitHub Releases.
57+
release-pypi:
58+
name: Publish released package to pypi.org
59+
if: github.repository_owner == 'alexrudy' && github.event.action == 'published'
60+
environment: pypi-release
61+
runs-on: ubuntu-latest
62+
needs: build-package
6063

61-
# Upload to real PyPI on GitHub Releases.
62-
release-pypi:
63-
name: Publish released package to pypi.org
64-
if: github.repository_owner == 'alexrudy' && github.event.action == 'published'
65-
environment: pypi-release
66-
runs-on: ubuntu-latest
67-
needs: build-package
64+
steps:
65+
- name: Download packages built by build-and-inspect-python-package
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: Packages
69+
path: dist
6870

69-
steps:
70-
- name: Download packages built by build-and-inspect-python-package
71-
uses: actions/download-artifact@v4
72-
with:
73-
name: Packages
74-
path: dist
75-
76-
- name: Upload package to PyPI
77-
uses: pypa/gh-action-pypi-publish@release/v1
71+
- name: Upload package to PyPI
72+
uses: pypa/gh-action-pypi-publish@release/v1

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ source = "vcs"
3131
[tool.hatch.build.hooks.vcs]
3232
version-file = "src/bootlace/_version.py"
3333

34+
[tool.hatch.version.raw-options]
35+
local_scheme = "no-local-version"
36+
3437
[project.urls]
3538
Documentation = "https://github.com/alexrudy/bootlace#readme"
3639
Issues = "https://github.com/alexrudy/bootlace/issues"

0 commit comments

Comments
 (0)