|
7 | 7 | paths: |
8 | 8 | - cumulusci/__about__.py |
9 | 9 |
|
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + id-token: write |
| 13 | + |
10 | 14 | concurrency: publishing |
11 | 15 |
|
12 | 16 | jobs: |
| 17 | + determine-environment: |
| 18 | + name: Determine release environment |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + version: ${{ steps.version.outputs.version }} |
| 22 | + environment: ${{ steps.version.outputs.environment }} |
| 23 | + prerelease: ${{ steps.version.outputs.prerelease }} |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - name: Set up Python 3.11 |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: 3.11 |
| 30 | + - name: Install hatch |
| 31 | + run: python -m pip install hatch |
| 32 | + - name: Determine version and environment |
| 33 | + id: version |
| 34 | + run: | |
| 35 | + VERSION="$(hatch version)" |
| 36 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + # Determine environment based on version pattern (PEP 440 compliant) |
| 39 | + ENVIRONMENT="" |
| 40 | + PRERELEASE="" |
| 41 | + if [[ "$VERSION" =~ \.dev[0-9]*$ ]]; then |
| 42 | + ENVIRONMENT="development" |
| 43 | + PRERELEASE="true" |
| 44 | + elif [[ "$VERSION" =~ (a|b|rc)[0-9]+$ ]]; then |
| 45 | + ENVIRONMENT="staging" |
| 46 | + PRERELEASE="true" |
| 47 | + else |
| 48 | + ENVIRONMENT="production" |
| 49 | + PRERELEASE="false" |
| 50 | + fi |
| 51 | +
|
| 52 | + echo "environment=$ENVIRONMENT" >> $GITHUB_OUTPUT |
| 53 | + echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + echo "📦 Version: $VERSION" |
| 56 | + echo "🌍 Environment: $ENVIRONMENT" |
| 57 | +
|
13 | 58 | publish-to-pypi: |
14 | | - name: Publish new release to PyPI |
| 59 | + name: Publish ${{ needs.determine-environment.outputs.version }} to PyPI |
15 | 60 | runs-on: ubuntu-latest |
| 61 | + needs: determine-environment |
| 62 | + environment: |
| 63 | + name: ${{ needs.determine-environment.outputs.environment }} |
| 64 | + url: https://pypi.org/project/clariti-cumulusci/${{ needs.determine-environment.outputs.version }} |
| 65 | + permissions: |
| 66 | + id-token: write # Required for trusted publishing |
| 67 | + contents: write # Required for creating releases |
16 | 68 | steps: |
17 | | - - uses: actions/checkout@main |
| 69 | + - uses: actions/checkout@v4 |
18 | 70 | - name: Set up Python 3.11 |
19 | | - uses: actions/setup-python@v4 |
| 71 | + uses: actions/setup-python@v5 |
20 | 72 | with: |
21 | 73 | python-version: 3.11 |
22 | 74 | cache: pip |
23 | 75 | - name: Install build tools |
24 | 76 | run: python -m pip install hatch tomli tomli-w |
25 | 77 | - name: Build source tarball and binary wheel |
26 | 78 | run: hatch build -c |
27 | | - - name: Upload to PyPI |
28 | | - run: hatch publish |
29 | | - env: |
30 | | - HATCH_INDEX_USER: "__token__" |
31 | | - HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }} |
32 | | - - name: Create release |
| 79 | + - name: Publish to PyPI (Trusted Publishing) |
| 80 | + uses: pypa/gh-action-pypi-publish@106e0b0b7c337fa67ed433972f777c6357f78598 # v1.13.0 |
| 81 | + # No credentials needed - uses OIDC trusted publishing |
| 82 | + - name: Create GitHub release |
33 | 83 | env: |
34 | 84 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 85 | + VERSION: ${{ needs.determine-environment.outputs.version }} |
| 86 | + PRERELEASE: ${{ needs.determine-environment.outputs.prerelease }} |
35 | 87 | run: | |
36 | | - VERSION="$(hatch version)" |
37 | 88 | awk '/<!-- latest-start -->/,/<!-- latest-stop -->/' docs/history.md > changelog.md |
| 89 | +
|
| 90 | + PRERELEASE_FLAG="" |
| 91 | + if [[ "$PRERELEASE" == "true" ]]; then |
| 92 | + PRERELEASE_FLAG="--prerelease" |
| 93 | + fi |
| 94 | +
|
38 | 95 | gh release create "v$VERSION" \ |
39 | 96 | dist/*.whl \ |
40 | 97 | dist/*.tar.gz \ |
41 | 98 | --notes-file changelog.md \ |
42 | | - --title $VERSION |
| 99 | + --title "v$VERSION" \ |
| 100 | + $PRERELEASE_FLAG |
0 commit comments