1- # Automatically create a GitHub Release when a version tag is pushed
2- # This triggers the pypi-publish.yml workflow
1+ # Auto- create GitHub Release and publish to PyPI when a version tag is pushed
2+ # Uses Trusted Publishing (OIDC) - no API tokens needed
33#
44# Usage:
55# git tag v0.1.0
66# git push origin v0.1.0
77
8- name : Auto Release
8+ name : Release
99
1010on :
1111 push :
1414
1515permissions :
1616 contents : write
17+ id-token : write # Required for trusted publishing
1718
1819jobs :
19- create-release :
20+ build :
21+ name : Build distributions
22+ runs-on : ubuntu-latest
23+ steps :
24+ - uses : actions/checkout@v4
25+
26+ - name : Set up Python
27+ uses : actions/setup-python@v5
28+ with :
29+ python-version : " 3.12"
30+
31+ - name : Install build dependencies
32+ run : python -m pip install --upgrade pip build
33+
34+ - name : Build distributions
35+ run : python -m build
36+
37+ - name : Upload distributions
38+ uses : actions/upload-artifact@v4
39+ with :
40+ name : release-dists
41+ path : dist/
42+
43+ release :
2044 name : Create GitHub Release
2145 runs-on : ubuntu-latest
46+ needs : build
2247 steps :
2348 - uses : actions/checkout@v4
2449 with :
25- fetch-depth : 0 # Fetch all history for changelog
50+ fetch-depth : 0
2651
2752 - name : Get version from tag
2853 id : version
@@ -42,11 +67,16 @@ jobs:
4267 else
4368 CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
4469 fi
45- # Escape for GitHub output
4670 echo "changelog<<EOF" >> $GITHUB_OUTPUT
4771 echo "$CHANGELOG" >> $GITHUB_OUTPUT
4872 echo "EOF" >> $GITHUB_OUTPUT
4973
74+ - name : Download distributions
75+ uses : actions/download-artifact@v4
76+ with :
77+ name : release-dists
78+ path : dist/
79+
5080 - name : Create Release
5181 uses : softprops/action-gh-release@v2
5282 with :
6898 Full Changelog: https://github.com/${{ github.repository }}/compare/${{ steps.prev_tag.outputs.prev_tag }}...v${{ steps.version.outputs.version }}
6999 draft : false
70100 prerelease : ${{ contains(steps.version.outputs.version, '-') }}
71- generate_release_notes : false
101+ files : |
102+ dist/*
103+
104+ publish :
105+ name : Publish to PyPI
106+ runs-on : ubuntu-latest
107+ needs : build
108+ environment :
109+ name : pypi
110+ url : https://pypi.org/p/pylet
111+
112+ steps :
113+ - name : Download distributions
114+ uses : actions/download-artifact@v4
115+ with :
116+ name : release-dists
117+ path : dist/
118+
119+ - name : Publish to PyPI
120+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments