Skip to content

Commit 61afc77

Browse files
authored
post: add actions for version in release-python-package.md
1 parent c028f7e commit 61afc77

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

content/posts/release-python-package.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,52 @@ your-project 0.1.0 => 0.2.0
9898
```
9999
and pushing your updated `pyproject.toml`.
100100

101+
Using github actions, you can specify the version to install:
102+
```
103+
name: Package
104+
on:
105+
workflow_dispatch:
106+
push:
107+
branches:
108+
- "master"
109+
110+
jobs:
111+
build:
112+
name: "Build and publish package"
113+
runs-on: ubuntu-latest
114+
outputs: ### <<<<< add this to pass version information between jobs
115+
version: ${{ steps.get_version.outputs.version }}
116+
steps:
117+
- uses: actions/checkout@v4
118+
with:
119+
fetch-depth: 0 # for git-versionning
120+
- name: Install the latest version of uv
121+
uses: astral-sh/setup-uv@v6
122+
with:
123+
enable-cache: true
124+
- name: Get version ### <<<<< add this to pass version information between jobs
125+
id: get_version
126+
run: |
127+
echo "version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)" >> $GITHUB_OUTPUT
128+
- name: Build dist
129+
run: uv build
130+
- name: Publish packages
131+
run: uv publish --token ${{ secrets.TWINE_PASSWORD }}
132+
deploy:
133+
needs:
134+
- build
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Deploy to the server
138+
uses: https://github.com/appleboy/ssh-action@master
139+
with:
140+
host: ${{ vars.HOST_MACHINE }}
141+
username: ${{ secrets.HOST_SSH_USER }}
142+
key: ${{ secrets.HOST_SSH_KEY }}
143+
script: |
144+
pip install --force-reinstall your-project==${{ needs.build.outputs.version }}
145+
```
146+
101147
#### - Dynamic versioning
102148
In `pyproject.toml` add:
103149
```

0 commit comments

Comments
 (0)