Skip to content

Commit f32ac44

Browse files
authored
Merge pull request #145 from veithly/feat/update-version
chore(ci): refactor release workflow for PyPI publishing
2 parents 65fa8c8 + 2428c83 commit f32ac44

File tree

1 file changed

+63
-43
lines changed

1 file changed

+63
-43
lines changed

.github/workflows/release.yml

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,70 @@
1-
name: Release to PyPI
1+
# This workflow will upload a Python Package to PyPI when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
210

311
on:
4-
push:
5-
tags:
6-
- 'v*.*.*'
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
717

818
jobs:
9-
release:
19+
release-build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.11"
28+
29+
- name: Build release distributions
30+
run: |
31+
# NOTE: put your own distribution build steps here.
32+
python -m pip install build
33+
python -m build
34+
35+
- name: Upload distributions
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: release-dists
39+
path: dist/
40+
41+
pypi-publish:
1042
runs-on: ubuntu-latest
43+
needs:
44+
- release-build
45+
permissions:
46+
# IMPORTANT: this permission is mandatory for trusted publishing
47+
id-token: write
48+
49+
# Dedicated environments with protections for publishing are strongly recommended.
50+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
51+
environment:
52+
name: pypi
53+
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
54+
# url: https://pypi.org/p/YOURPROJECT
55+
#
56+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
57+
# ALTERNATIVE: exactly, uncomment the following line instead:
58+
url: https://pypi.org/project/spoon-ai-sdk/${{ github.event.release.name }}
1159

1260
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v4
15-
16-
- name: Set up Python
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.11'
20-
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install build twine
25-
26-
- name: Build package
27-
run: python -m build
28-
29-
- name: Publish to PyPI
30-
env:
31-
TWINE_USERNAME: __token__
32-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
33-
run: |
34-
twine upload dist/*
35-
36-
- name: Create GitHub Release
37-
uses: softprops/action-gh-release@v1
38-
with:
39-
tag_name: ${{ github.ref_name }}
40-
name: Release ${{ github.ref_name }}
41-
body: |
42-
Automatic release created for version ${{ github.ref_name }}
43-
44-
## Changes
45-
- Version bump to ${{ github.ref_name }}
46-
- Automatic PyPI publication for spoon-ai-sdk
47-
draft: false
48-
prerelease: false
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
- name: Retrieve release distributions
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: release-dists
65+
path: dist/
66+
67+
- name: Publish release distributions to PyPI
68+
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
packages-dir: dist/

0 commit comments

Comments
 (0)