|
1 | 1 | name: Publish package to PyPi |
2 | 2 |
|
3 | 3 | on: |
4 | | - # CHANGED: This allows you to manually run the workflow from the |
5 | | - # GitHub Actions tab (click 'Run workflow'). |
| 4 | + # This allows you to manually run the workflow from the GitHub Actions tab. |
6 | 5 | workflow_dispatch: |
7 | 6 | inputs: |
8 | 7 | branch: |
9 | 8 | description: 'Branch or tag to build from (e.g., main or v1.0.0)' |
10 | 9 | required: true |
11 | 10 | default: 'main' |
| 11 | + release_title: |
| 12 | + description: 'Release Title (e.g., v1.0.0: Initial Release)' |
| 13 | + required: true # Making title required for a proper release |
| 14 | + # Removed release_notes input here |
12 | 15 |
|
13 | 16 | jobs: |
14 | 17 | push: |
15 | 18 | runs-on: ubuntu-latest |
16 | 19 |
|
17 | | - # 1. SECURITY: Add permissions for OIDC token generation |
| 20 | + # UPDATED: Permissions now include 'releases: write' |
18 | 21 | permissions: |
19 | | - id-token: write # Grants permission to exchange a token with PyPI |
20 | | - contents: read # Allows checkout of the repository |
| 22 | + id-token: write |
| 23 | + contents: read |
| 24 | + releases: write # <-- REQUIRED for creating the GitHub Release |
21 | 25 |
|
22 | 26 | steps: |
23 | 27 | - name: Checkout |
24 | 28 | uses: actions/checkout@v5 |
25 | 29 | with: |
26 | | - # Use the branch/tag provided in the manual input |
27 | 30 | ref: ${{ github.event.inputs.branch }} |
28 | 31 |
|
29 | 32 | - name: Setup Python |
30 | 33 | uses: actions/setup-python@v5 |
31 | 34 | with: |
32 | | - # Use a stable, specific version |
33 | 35 | python-version: 3.11 |
34 | 36 |
|
35 | 37 | - name: Build package |
36 | | - # Install the 'build' tool and then run it to create the sdist and wheel. |
37 | 38 | run: | |
38 | 39 | python -m pip install --upgrade pip |
39 | 40 | python -m pip install build |
40 | 41 | python -m build |
41 | 42 |
|
42 | | - # 2. SECURITY: Publish to PyPi (using Trusted Publisher) |
| 43 | + # 2. Publish to PyPi (using Trusted Publisher) |
43 | 44 | - name: Publish to PyPi (using Trusted Publisher) |
44 | 45 | uses: pypa/gh-action-pypi-publish@release/v1 |
45 | | - # No manual secrets are needed! |
| 46 | + |
| 47 | + # 3. ADDED: Create GitHub Release |
| 48 | + - name: Create GitHub Release |
| 49 | + id: create_release |
| 50 | + uses: actions/create-release@v1 |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + with: |
| 54 | + tag_name: ${{ github.event.inputs.branch }} |
| 55 | + release_name: ${{ github.event.inputs.release_title }} |
| 56 | + # The body now uses the title since release_notes was removed |
| 57 | + body: ${{ github.event.inputs.release_title }} |
| 58 | + draft: false |
| 59 | + prerelease: false |
0 commit comments