@@ -3,21 +3,31 @@ name: Upload Python Package
33on :
44 push :
55 tags :
6- - v*.**
6+ - v*
7+ branches :
8+ - develop
9+ pull_request :
10+ branches :
11+ - develop
712 workflow_dispatch :
813
914permissions :
1015 contents : read
1116
1217jobs :
13- build_wheels :
18+ build-wheels :
1419 name : Build wheels on ${{ matrix.os }}
1520 runs-on : ${{ matrix.os }}
1621 strategy :
1722 matrix :
18- os : [ubuntu-latest-8 , macos-latest]
23+ os : [ubuntu-latest, macos-latest]
1924
2025 steps :
26+ - name : Dump GitHub context
27+ env :
28+ GITHUB_CONTEXT : ${{ toJson(github) }}
29+ run : echo "$GITHUB_CONTEXT"
30+
2131 - uses : actions/checkout@v4
2232 with :
2333 fetch-depth : 0
3343 git branch
3444 git fetch --depth=1 origin +refs/tags/*:refs/tags/*
3545
46+ # TODO: add cbuildwheel cache
3647 - name : Build release distributions
37- run : |
38- uv build --wheel
48+ run : uv build --wheel
3949 env :
4050 HATCH_BUILD_HOOKS_ENABLE : true
4151
@@ -45,107 +55,32 @@ jobs:
4555 path : dist/
4656
4757 release :
48- needs : build_wheels
49- runs-on : ubuntu-latest-8
50- permissions :
51- contents : write
58+ if : startsWith(github.ref, 'refs/tags/')
59+ needs : build-wheels
60+ runs-on : ubuntu-latest
5261 environment : release
5362 steps :
5463 - uses : actions/checkout@v4
5564
5665 - name : Setup backend
5766 uses : ./.github/actions/setup-backend
5867
59- - name : Configure AWS Credentials
60- uses : aws-actions/configure-aws-credentials@v4
61- with :
62- aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
63- aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
64- aws-region : us-west-1
65-
6668 - name : Download All Artifacts
6769 uses : actions/download-artifact@v4
6870 with :
6971 path : dist
7072 merge-multiple : true
7173 pattern : wheels-*
7274
75+ - name : Release PyPI
76+ run : |
77+ export UV_PUBLISH_PASSWORD="${{ secrets.PYPI_TOKEN }}"
78+ export UV_PUBLISH_USERNAME="__token__"
79+ uv publish --publish-url https://upload.pypi.org/legacy/ --keyring-provider disabled
80+
7381 - name : Make github release
7482 uses : softprops/action-gh-release@v2
75- if : startsWith(github.ref, 'refs/tags/')
7683 with :
7784 files : dist/*
7885 fail_on_unmatched_files : true
7986 generate_release_notes : true
80-
81- - name : Publish message to slack
82- 83- if : success() && startsWith(github.ref, 'refs/tags/')
84- with :
85- webhook : ${{ secrets.SLACK_WEBHOOK_URL }}
86- webhook-type : incoming-webhook
87- payload : |
88- {
89- "blocks": [
90- {
91- "type": "header",
92- "text": {
93- "type": "plain_text",
94- "text": "✅ New codegen-sdk Release Successfully Published! 🚀",
95- "emoji": true
96- }
97- },
98- {
99- "type": "section",
100- "text": {
101- "type": "mrkdwn",
102- "text": "*Version:* ${{ github.ref_name }}\n*Released by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Links:*\n• <${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}|GitHub Release>\n• <https://pypi.org/project/codegen-sdk/${{ github.ref_name }}|PyPI Package>"
103- }
104- },
105- {
106- "type": "context",
107- "elements": [
108- {
109- "type": "mrkdwn",
110- "text": "<!date^${{ github.event.release.published_at }}^Published {date_num} at {time}|Published just now>"
111- }
112- ]
113- }
114- ]
115- }
116-
117- - name : Publish failed message to slack
118- 119- if : failure() && startsWith(github.ref, 'refs/tags/')
120- with :
121- webhook : ${{ secrets.SLACK_WEBHOOK_URL }}
122- webhook-type : incoming-webhook
123- payload : |
124- {
125- "blocks": [
126- {
127- "type": "header",
128- "text": {
129- "type": "plain_text",
130- "text": "❌ codegen-sdk Release Failed",
131- "emoji": true
132- }
133- },
134- {
135- "type": "section",
136- "text": {
137- "type": "mrkdwn",
138- "text": "*Version:* ${{ github.ref_name }}\n*Attempted by:* <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}>\n\n*Details:*\n• Failed to publish version ${{ github.ref_name }}\n• <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
139- }
140- },
141- {
142- "type": "context",
143- "elements": [
144- {
145- "type": "mrkdwn",
146- "text": "Failed at <!date^${{ github.event.release.published_at }}^{date_num} {time}|just now>"
147- }
148- ]
149- }
150- ]
151- }
0 commit comments