Skip to content

Commit a7b8c61

Browse files
ci: update to semantic-pr-release-drafter@v0.4.0 and simplify publish workflow (#944)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 816e7fe commit a7b8c61

File tree

2 files changed

+60
-80
lines changed

2 files changed

+60
-80
lines changed

.github/workflows/pypi_publish.yml

Lines changed: 24 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,38 @@
1-
name: Build and/or Publish
1+
# This workflow publishes the python package to PyPI.
2+
#
3+
# Triggers:
4+
# - release: published - When user clicks "Publish" on a draft release (downloads pre-built assets)
5+
#
6+
# Authentication: This workflow expects GitHub OIDC for passwordless PyPI publishing.
7+
# For more info: https://docs.pypi.org/trusted-publishers/
28

3-
on:
4-
push:
5-
6-
workflow_dispatch:
7-
inputs:
8-
git_ref:
9-
description: 'Git ref (SHA or branch) to checkout and build'
10-
required: false
11-
type: string
12-
version_override:
13-
description: 'Version to use (overrides dynamic versioning)'
14-
required: false
15-
type: string
16-
publish:
17-
description: 'Whether to publish to PyPI (true/false)'
18-
required: false
19-
type: string
20-
default: 'false'
9+
name: Publish Package
2110

22-
workflow_call:
23-
inputs:
24-
git_ref:
25-
description: 'Git ref (SHA or branch) to checkout and build'
26-
required: true
27-
type: string
28-
version_override:
29-
description: 'Version to use (overrides dynamic versioning)'
30-
required: false
31-
type: string
32-
publish:
33-
description: 'Whether to publish to PyPI'
34-
required: false
35-
type: boolean
36-
default: false
11+
on:
12+
release:
13+
types: [published]
3714

3815
env:
3916
AIRBYTE_ANALYTICS_ID: ${{ vars.AIRBYTE_ANALYTICS_ID }}
4017

4118
jobs:
42-
build:
43-
runs-on: ubuntu-latest
44-
steps:
45-
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
46-
with:
47-
ref: ${{ inputs.git_ref || github.ref }}
48-
fetch-depth: 0
49-
- name: Prepare version override
50-
id: version
51-
run: |
52-
echo "override=${{ inputs.version_override }}" >> $GITHUB_OUTPUT
53-
echo "has_override=${{ inputs.version_override != '' }}" >> $GITHUB_OUTPUT
54-
- name: Build package (with version override)
55-
if: steps.version.outputs.has_override == 'true'
56-
uses: hynek/build-and-inspect-python-package@v2
57-
env:
58-
UV_DYNAMIC_VERSIONING_BYPASS: ${{ steps.version.outputs.override }}
59-
- name: Build package (dynamic version)
60-
if: steps.version.outputs.has_override != 'true'
61-
uses: hynek/build-and-inspect-python-package@v2
62-
63-
publish:
64-
name: Publish to PyPI
19+
publish_to_pypi:
20+
name: Publish Package to PyPI
6521
runs-on: ubuntu-latest
66-
needs: [build]
6722
permissions:
68-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
69-
contents: write # Needed to upload artifacts to the release
23+
id-token: write
24+
contents: read
7025
environment:
7126
name: PyPi
7227
url: https://pypi.org/p/airbyte
73-
# Publish when: (1) triggered by a tag push, OR (2) called with publish=true (handles both boolean and string)
74-
if: startsWith(github.ref, 'refs/tags/') || inputs.publish == true || inputs.publish == 'true'
7528
steps:
76-
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
77-
with:
78-
name: Packages
79-
path: dist
80-
- name: Upload wheel to release
81-
# Only upload to GitHub release when triggered by a tag
82-
if: startsWith(github.ref, 'refs/tags/')
83-
uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # latest
84-
with:
85-
repo_token: ${{ secrets.GITHUB_TOKEN }}
86-
file: dist/*.whl
87-
tag: ${{ github.ref }}
88-
overwrite: true
89-
file_glob: true
29+
- name: Download release assets
30+
uses: robinraju/release-downloader@v1.12
31+
with:
32+
tag: ${{ github.event.release.tag_name }}
33+
fileName: "*"
34+
out-file-path: dist
9035

91-
- name: Publish
92-
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
36+
# Uses GitHub OIDC for passwordless authentication (see header comment)
37+
- name: Publish to PyPI
38+
uses: pypa/gh-action-pypi-publish@v1.13.0
Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Release Drafter
22

33
on:
4+
workflow_dispatch: {}
45
push:
56
branches:
67
- main
@@ -10,12 +11,45 @@ concurrency:
1011
cancel-in-progress: false
1112

1213
jobs:
13-
update_release_draft:
14+
draft_release:
15+
name: Draft Release
1416
permissions:
1517
contents: write
1618
pull-requests: write
1719
runs-on: ubuntu-latest
1820
steps:
19-
- uses: aaronsteers/semantic-pr-release-drafter@v0.3.0
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v7
23+
with:
24+
version: "latest"
25+
python-version: "3.10"
26+
27+
- name: Checkout Repo
28+
uses: actions/checkout@v6
29+
with:
30+
# Shallow clone is sufficient since we bypass dynamic versioning
31+
fetch-depth: 1
32+
33+
- name: Get release version (dry-run)
34+
uses: aaronsteers/semantic-pr-release-drafter@v0.4.0
35+
id: dry-run
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
with:
39+
dry-run: true
40+
41+
- name: Build package
42+
env:
43+
VERSION: ${{ steps.dry-run.outputs.tag_name }}
44+
# Standardize by removing preceding 'v' char:
45+
run: POETRY_DYNAMIC_VERSIONING_BYPASS="${VERSION#v}" uv build
46+
47+
- name: Create or update draft release
48+
uses: aaronsteers/semantic-pr-release-drafter@v0.4.0
2049
env:
2150
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
version: ${{ steps.dry-run.outputs.tag_name }}
53+
attach-files: |
54+
dist/*.whl
55+
dist/*.tar.gz

0 commit comments

Comments
 (0)