Skip to content

Commit fadcd53

Browse files
committed
update release action
1 parent a5f6228 commit fadcd53

File tree

4 files changed

+62
-8
lines changed

4 files changed

+62
-8
lines changed

.github/workflows/mutation-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
continue-on-error: true
2727

2828
steps:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3030
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v4
31+
uses: actions/setup-python@v5
3232
with:
3333
python-version: ${{ matrix.python-version }}
3434
- name: Install dependencies

.github/workflows/release.yml

+54-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,70 @@ on:
44
release:
55
types:
66
- published
7+
workflow_dispatch: # for testing
78

89
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+
960
notify-release:
1061
runs-on: ubuntu-latest
1162
name: Notify Release
63+
needs: publish-package
64+
if: needs.publish-package.outputs.published == 'true'
1265
strategy:
1366
matrix:
1467
url: [SLACK_WEBHOOK_ASK_DEVREL_URL, SLACK_WEBHOOK_DEVREL_TOOLING_URL, SLACK_WEBHOOK_DEVREL_PRIVATE_URL]
1568
steps:
1669
- name: Send to slack channels
17-
uses: slackapi/slack-github-action@v2.0.0
70+
uses: slackapi/slack-github-action@v2
1871
if: always()
1972
continue-on-error: true
2073
with:
@@ -36,6 +89,3 @@ jobs:
3689
text:
3790
type: "mrkdwn"
3891
text: "You can view the full change log <${{github.event.release.html_url }}|here>"
39-
40-
41-

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
.PHONY: test coverage
1+
.PHONY: format test coverage coverage-report install
2+
3+
format:
4+
pants lint ::
5+
pants fix ::
26

37
test:
48
pants test ::
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.1.4'
1+
__version__ = '1.1.4dev2'

0 commit comments

Comments
 (0)