|
4 | 4 | release:
|
5 | 5 | types:
|
6 | 6 | - published
|
| 7 | + workflow_dispatch: # for testing |
7 | 8 |
|
8 | 9 | jobs:
|
| 10 | + publish-package: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: Publish to PyPI |
| 13 | + |
| 14 | + outputs: |
| 15 | + published: ${{ steps.set-published-state.outputs.published }} # Define an output for the job |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + id: checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 # Fetch history for all tags |
| 23 | + |
| 24 | + - name: Setup python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: 3.13 |
| 28 | + |
| 29 | + - name: Initialize pants |
| 30 | + uses: pantsbuild/actions/init-pants@main |
| 31 | + with: |
| 32 | + gha-cache-key: cache0-py3.13 |
| 33 | + named-caches-hash: ${{ hashFiles('requirements.txt') }} |
| 34 | + |
| 35 | + - name: Publish to PyPI |
| 36 | + run: | |
| 37 | + previous_tag=$(git describe --tags --abbrev=0 HEAD^) |
| 38 | + echo "Comparing changes since $previous_tag" |
| 39 | +
|
| 40 | + changed_targets=$(pants --changed-since=$previous_tag list | awk -F/ '{print $1}' | sort -u) |
| 41 | +
|
| 42 | + if [ -n "$changed_targets" ]; then |
| 43 | + echo "Publishing changed targets: $changed_targets" |
| 44 | + for target in $changed_targets; do |
| 45 | + pants publish $target:: |
| 46 | + done |
| 47 | + echo "published=true" >> $GITHUB_ENV |
| 48 | + else |
| 49 | + echo "No changes detected, skipping publish" |
| 50 | + echo "published=false" >> $GITHUB_ENV |
| 51 | + fi |
| 52 | + env: |
| 53 | + TWINE_USERNAME: __token__ |
| 54 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 55 | + |
| 56 | + - name: Set published state |
| 57 | + id: set-published-state |
| 58 | + run: echo "published=$published" >> $GITHUB_OUTPUT |
| 59 | + |
9 | 60 | notify-release:
|
10 | 61 | runs-on: ubuntu-latest
|
11 | 62 | name: Notify Release
|
| 63 | + needs: publish-package |
| 64 | + if: needs.publish-package.outputs.published == 'true' |
12 | 65 | strategy:
|
13 | 66 | matrix:
|
14 | 67 | url: [SLACK_WEBHOOK_ASK_DEVREL_URL, SLACK_WEBHOOK_DEVREL_TOOLING_URL, SLACK_WEBHOOK_DEVREL_PRIVATE_URL]
|
15 | 68 | steps:
|
16 | 69 | - name: Send to slack channels
|
17 |
| - uses: slackapi/slack-github-action@v2.0.0 |
| 70 | + uses: slackapi/slack-github-action@v2 |
18 | 71 | if: always()
|
19 | 72 | continue-on-error: true
|
20 | 73 | with:
|
|
36 | 89 | text:
|
37 | 90 | type: "mrkdwn"
|
38 | 91 | text: "You can view the full change log <${{github.event.release.html_url }}|here>"
|
39 |
| -
|
40 |
| -
|
41 |
| -
|
|
0 commit comments