Skip to content

Commit 4e6cd13

Browse files
committed
feat: use autopub 1.0.0 alpha for releases
1 parent 2bb240b commit 4e6cd13

File tree

3 files changed

+173
-64
lines changed

3 files changed

+173
-64
lines changed

.github/workflows/pre-release-pr.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,54 @@ on:
44
repository_dispatch:
55
types: [pre-release-command]
66

7+
env:
8+
AUTOPUB_CMD: uvx --from 'autopub>=1.0.0a48' --with pygithub autopub
9+
710
jobs:
811
pre-release:
912
name: Pre-release
1013
runs-on: ubuntu-latest
1114
steps:
12-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1316
with:
1417
ref: ${{ github.event.client_payload.pull_request.head.sha }}
18+
1519
- name: Install uv
1620
uses: astral-sh/setup-uv@v5
21+
1722
- name: Set up Python
1823
run: uv python install 3.12
19-
- name: Install deps
20-
run: |
21-
uv pip install --system githubrelease autopub httpx
24+
2225
- name: Check if release exists
2326
id: check_release
24-
run: echo "::set-output name=release::$(autopub check)"
27+
run: |
28+
if $AUTOPUB_CMD check; then
29+
echo "has_release=true" >> $GITHUB_OUTPUT
30+
else
31+
echo "has_release=false" >> $GITHUB_OUTPUT
32+
exit 0
33+
fi
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
36+
2537
- name: Metadata
2638
id: metadata
27-
if: steps.check_release.outputs.release == ''
28-
run: echo "::set-output name=commit::$(git rev-parse HEAD)"
39+
if: steps.check_release.outputs.has_release == 'true'
40+
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
41+
2942
- name: Find Release Comment
30-
uses: peter-evans/find-comment@v1
43+
uses: peter-evans/find-comment@v3
3144
id: find_comment
32-
if: steps.check_release.outputs.release == ''
45+
if: steps.check_release.outputs.has_release == 'true'
3346
with:
3447
token: ${{ secrets.BOT_TOKEN }}
3548
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
3649
comment-author: botberry
3750
body-includes: "# Pre-release"
51+
3852
- name: Create or update comment
39-
uses: peter-evans/create-or-update-comment@v1
40-
if: steps.check_release.outputs.release == ''
53+
uses: peter-evans/create-or-update-comment@v4
54+
if: steps.check_release.outputs.has_release == 'true'
4155
with:
4256
token: ${{ secrets.BOT_TOKEN }}
4357
comment-id: ${{ steps.find_comment.outputs.comment-id }}
@@ -48,24 +62,26 @@ jobs:
4862
4963
Releasing commit [${{ steps.metadata.outputs.commit }}] to PyPi as pre-release! :package:
5064
edit-mode: replace
65+
5166
- name: Publish pre-release version
52-
if: steps.check_release.outputs.release == ''
67+
if: steps.check_release.outputs.has_release == 'true'
5368
id: release
5469
env:
5570
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
5671
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
5772
run: |
58-
autopub prepare
73+
$AUTOPUB_CMD prepare
5974
# Get current version and append dev timestamp
6075
CURRENT_VERSION=$(grep -m1 'version = ' pyproject.toml | cut -d'"' -f2)
6176
DEV_VERSION="${CURRENT_VERSION}.dev.$(date '+%s')"
6277
sed -i "s/version = \"${CURRENT_VERSION}\"/version = \"${DEV_VERSION}\"/" pyproject.toml
63-
uv build
78+
$AUTOPUB_CMD build
6479
uv publish
65-
echo "::set-output name=version::${DEV_VERSION}"
80+
echo "version=${DEV_VERSION}" >> $GITHUB_OUTPUT
81+
6682
- name: Create or update comment
67-
uses: peter-evans/create-or-update-comment@v1
68-
if: steps.check_release.outputs.release == ''
83+
uses: peter-evans/create-or-update-comment@v4
84+
if: steps.check_release.outputs.has_release == 'true'
6985
with:
7086
token: ${{ secrets.BOT_TOKEN }}
7187
comment-id: ${{ steps.find_comment.outputs.comment-id }}

.github/workflows/release-check.yml

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ on:
99
- "strawberry/**"
1010
- "pyproject.toml"
1111

12+
permissions:
13+
pull-requests: write
14+
15+
env:
16+
AUTOPUB_CMD: uvx --from 'autopub>=1.0.0a48' --with pygithub autopub
17+
1218
jobs:
1319
get-contributor-info:
1420
name: Get PR info
@@ -38,6 +44,7 @@ jobs:
3844
id: skip
3945
shell: python
4046
run: |
47+
import os
4148
bots = [
4249
"dependabot-preview[bot]",
4350
"dependabot-preview",
@@ -49,9 +56,11 @@ jobs:
4956
5057
if username in bots:
5158
print(f"Skipping {username} because it is a bot")
52-
print("::set-output name=skip::true")
59+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
60+
f.write("skip=true\n")
5361
else:
54-
print("::set-output name=skip::false")
62+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
63+
f.write("skip=false\n")
5564
5665
release-file-check:
5766
name: Release check
@@ -63,17 +72,58 @@ jobs:
6372
changelog: ${{ steps.release-check.outputs.changelog }}
6473
status: ${{ steps.release-check.outputs.release_status }}
6574
change_type: ${{ steps.release-check.outputs.change_type }}
75+
has_release: ${{ steps.check.outputs.has_release }}
6676

6777
steps:
6878
- name: Checkout code
69-
uses: actions/checkout@v2
79+
uses: actions/checkout@v4
7080
with:
7181
ref: "refs/pull/${{ github.event.number }}/merge"
82+
sparse-checkout: |
83+
RELEASE.md
84+
pyproject.toml
85+
sparse-checkout-cone-mode: false
86+
87+
- name: Install uv
88+
uses: astral-sh/setup-uv@v5
89+
90+
- name: Check with autopub
91+
id: check
92+
run: |
93+
if $AUTOPUB_CMD check; then
94+
echo "has_release=true" >> $GITHUB_OUTPUT
95+
echo "release_status=OK" >> $GITHUB_OUTPUT
96+
else
97+
echo "has_release=false" >> $GITHUB_OUTPUT
98+
echo "release_status=MISSING" >> $GITHUB_OUTPUT
99+
fi
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72102

73-
- name: Release file check
74-
uses: strawberry-graphql/strawberry/.github/release-check-action@main
103+
- name: Extract release info
75104
id: release-check
76-
if: github.event.pull_request.draft == false
105+
if: steps.check.outputs.has_release == 'true' && github.event.pull_request.draft == false
106+
run: |
107+
# Read the RELEASE.md file to get changelog and change type
108+
if [ -f "RELEASE.md" ]; then
109+
# Extract change type from first line
110+
change_type=$(head -1 RELEASE.md | grep -oE "(major|minor|patch)" | head -1)
111+
echo "change_type=${change_type}" >> $GITHUB_OUTPUT
112+
113+
# Extract changelog (everything after first line)
114+
changelog=$(tail -n +2 RELEASE.md | base64 -w 0)
115+
echo "changelog=${changelog}" >> $GITHUB_OUTPUT
116+
echo "release_status=OK" >> $GITHUB_OUTPUT
117+
fi
118+
119+
- name: Upload .autopub artifact
120+
if: steps.check.outputs.has_release == 'true'
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: autopub-data
124+
path: .autopub
125+
include-hidden-files: true
126+
if-no-files-found: ignore
77127

78128
read-tweet-md:
79129
name: Read TWEET.md
@@ -84,7 +134,7 @@ jobs:
84134
tweet: ${{ steps.extract.outputs.tweet }}
85135

86136
steps:
87-
- uses: actions/checkout@v2
137+
- uses: actions/checkout@v4
88138
with:
89139
ref: "refs/pull/${{ github.event.number }}/merge"
90140
- name: Extract tweet message and changelog
@@ -112,7 +162,7 @@ jobs:
112162
if: github.event.pull_request.draft == false
113163

114164
steps:
115-
- uses: actions/checkout@v2
165+
- uses: actions/checkout@v4
116166
- name: Send comment
117167
uses: ./.github/bot-action
118168
env:

0 commit comments

Comments
 (0)