Skip to content

Commit bf8a7fa

Browse files
committed
publish to PyPI as rsconnect and rsconnect-python
- update makefile to support building wheels with a different package name - add a script to rewrite the package name in CI - `uv run` is used for this so that the necessary `toml` dependency is installed without drama - add a second publishing step that sets the PACKAGE_NAME environment variable and publishes to PyPI - duplicating the workflow rather than matrixing avoids the possibilty that the renamed workflow executes first and no `rsconnect-python` build is produced
1 parent 8601629 commit bf8a7fa

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,39 @@ jobs:
111111
user: __token__
112112
password: ${{ secrets.PYPI_TOKEN }}
113113

114+
publish-rsconnect:
115+
needs: test
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v4
119+
with:
120+
fetch-depth: 0
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
- uses: actions/setup-python@v4
124+
with:
125+
python-version: 3.8.x
126+
- name: Install uv # see scripts/temporary-rename
127+
uses: astral-sh/setup-uv@v5
128+
- run: pip install -e '.[test]'
129+
- run: pip freeze
130+
- run: make dist
131+
id: create_dist
132+
env:
133+
PACKAGE_NAME: rsconnect
134+
- uses: actions/upload-artifact@v4
135+
with:
136+
name: distributions
137+
path: dist/
138+
- run: pip install -vvv ${{ steps.create_dist.outputs.whl }}
139+
- run: rsconnect version
140+
- run: rsconnect --help
141+
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
142+
uses: pypa/gh-action-pypi-publish@release/v1
143+
with:
144+
user: __token__
145+
password: ${{ secrets.PYPI_TOKEN }}
146+
114147
docs:
115148
needs: test
116149
runs-on: ubuntu-latest

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ VERSION := $(shell python -m setuptools_scm)
22
HOSTNAME := $(shell hostname)
33
S3_PREFIX := s3://rstudio-connect-downloads/connect/rsconnect-python
44

5-
BDIST_WHEEL := dist/rsconnect_python-$(VERSION)-py2.py3-none-any.whl
5+
PACKAGE_NAME ?= rsconnect_python
6+
BDIST_WHEEL := dist/$(PACKAGE_NAME)-$(VERSION)-py2.py3-none-any.whl
67

78
RUNNER = docker run \
89
-it --rm \
@@ -75,11 +76,12 @@ clean:
7576
./build \
7677
./dist \
7778
./htmlcov \
78-
./rsconnect_python.egg-info
79+
./rsconnect_python.egg-info \
80+
./rsconnect.egg-info
7981

8082
.PHONY: clean-stores
8183
clean-stores:
82-
@find . -name "rsconnect-python" | xargs rm -rf
84+
@find . -name "rsconnect-python" -o -name "rsconnect_python-*" -o -name "rsconnect-*" | xargs rm -rf
8385

8486
.PHONY: shell
8587
shell: RUNNER = bash -c
@@ -110,6 +112,7 @@ version:
110112
# exported as a point of reference instead.
111113
.PHONY: dist
112114
dist:
115+
./scripts/temporary-rename
113116
pip wheel --no-deps -w dist .
114117
twine check $(BDIST_WHEEL)
115118
rm -vf dist/*.egg

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[project]
22
name = "rsconnect_python"
3-
description = "Python integration with Posit Connect"
3+
description = "The Posit Connect command-line interface."
44

5-
authors = [{ name = "Michael Marchetti", email = "mike@posit.co" }]
5+
authors = [{ name = "Posit, PBC", email = "rsconnect@posit.co" }]
66
license = { file = "LICENSE.md" }
77
readme = { file = "README.md", content-type = "text/markdown" }
88
requires-python = ">=3.8"

scripts/temporary-rename

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env -S uv run --script
2+
# /// script
3+
# dependencies = ["toml"]
4+
# ///
5+
import os
6+
7+
import toml
8+
9+
if "PACKAGE_NAME" in os.environ:
10+
11+
with open("pyproject.toml", "r") as f:
12+
pyproject = toml.load(f)
13+
14+
# Override package name from pyproject.toml with environment variable
15+
pyproject["project"]["name"] = os.environ["PACKAGE_NAME"]
16+
17+
with open("pyproject.toml", "w") as f:
18+
toml.dump(pyproject, f)

0 commit comments

Comments
 (0)