Skip to content

chore(ci): publish to pypi on release #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ orbs:
github-cli: circleci/[email protected]
slack: circleci/[email protected]






commands:
install-lfs:
steps:
Expand Down
113 changes: 24 additions & 89 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@ name: Upload Python Package
on:
push:
tags:
- v*.**
- v*
branches:
- develop
pull_request:
branches:
- develop
workflow_dispatch:

permissions:
contents: read

jobs:
build_wheels:
build-wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest-8, macos-latest]
os: [ubuntu-latest, macos-latest]

steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -33,9 +43,9 @@ jobs:
git branch
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

# TODO: add cbuildwheel cache
- name: Build release distributions
run: |
uv build --wheel
run: uv build --wheel
env:
HATCH_BUILD_HOOKS_ENABLE: true

Expand All @@ -45,107 +55,32 @@ jobs:
path: dist/

release:
needs: build_wheels
runs-on: ubuntu-latest-8
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/')
needs: build-wheels
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4

- name: Setup backend
uses: ./.github/actions/setup-backend

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1

- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
pattern: wheels-*

- name: Release PyPI
run: |
export UV_PUBLISH_PASSWORD="${{ secrets.PYPI_TOKEN }}"
export UV_PUBLISH_USERNAME="__token__"
uv publish --publish-url https://upload.pypi.org/legacy/ --keyring-provider disabled

- name: Make github release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
fail_on_unmatched_files: true
generate_release_notes: true

- name: Publish message to slack
uses: slackapi/[email protected]
if: success() && startsWith(github.ref, 'refs/tags/')
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "✅ New codegen-sdk Release Successfully Published! 🚀",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"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>"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "<!date^${{ github.event.release.published_at }}^Published {date_num} at {time}|Published just now>"
}
]
}
]
}

- name: Publish failed message to slack
uses: slackapi/[email protected]
if: failure() && startsWith(github.ref, 'refs/tags/')
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "❌ codegen-sdk Release Failed",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"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>"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Failed at <!date^${{ github.event.release.published_at }}^{date_num} {time}|just now>"
}
]
}
]
}
Loading