Skip to content

Commit 004e5ec

Browse files
committed
Release workflow
1 parent 239dc55 commit 004e5ec

File tree

4 files changed

+159
-14
lines changed

4 files changed

+159
-14
lines changed

.github/workflows/cleanup_pypi.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
workflow_call:
44
inputs:
55
environment:
6-
description: CI environment to run in (test.pypi or production.pypi)
6+
description: CI environment to run in (pypi-test or pypi-prod-nightly)
77
type: string
88
required: true
99
workflow_dispatch:
@@ -16,10 +16,9 @@ on:
1616
description: CI environment to run in
1717
type: choice
1818
required: true
19-
default: test.pypi
2019
options:
21-
- test.pypi
22-
- production.pypi
20+
- pypi-prod-nightly
21+
- pypi-test
2322

2423
jobs:
2524
cleanup_pypi:

.github/workflows/on_push_postrelease.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ jobs:
3838
minimal: false
3939
testsuite: all
4040
git-ref: ${{ github.ref }}
41-
duckdb-git-ref: ${{ needs.extract_duckdb_tag.outputs.duckdb_version }}
42-
force-version: ${{ github.ref_name }}
41+
duckdb-git-ref: ${{ github.ref_name }}
42+
set-version: ${{ needs.extract_duckdb_tag.outputs.duckdb_version }}

.github/workflows/packaging.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Packaging
2-
run-name: Build ${{ inputs.minimal && 'minimal set of' || 'all' }} packages (version=${{ inputs.force-version != '' && inputs.force-version || 'dev' }}, tests=${{ inputs.testsuite }}, ref=${{ inputs.git-ref }}, duckdb ref=${{ inputs.duckdb-git-ref }})
2+
run-name: Build ${{ inputs.minimal && 'minimal set of' || 'all' }} packages (version=${{ inputs.set-version != '' && inputs.set-version || 'dev' }}, tests=${{ inputs.testsuite }}, ref=${{ inputs.git-ref }}, duckdb ref=${{ inputs.duckdb-git-ref }})
33
on:
44
workflow_dispatch:
55
inputs:
@@ -25,7 +25,7 @@ on:
2525
description: Git ref of DuckDB
2626
required: true
2727
default: refs/heads/main
28-
force-version:
28+
set-version:
2929
type: string
3030
description: Force version (vX.Y.Z-((rc|post)N))
3131
required: false
@@ -48,7 +48,7 @@ on:
4848
type: string
4949
description: Git ref of DuckDB
5050
required: false
51-
force-version:
51+
set-version:
5252
description: Force version (vX.Y.Z-((rc|post)N))
5353
required: false
5454
type: string
@@ -82,8 +82,8 @@ jobs:
8282
git checkout ${{ inputs.duckdb-git-ref }}
8383
8484
- name: Set OVERRIDE_GIT_DESCRIBE
85-
if: ${{ inputs.force-version != '' }}
86-
run: echo "OVERRIDE_GIT_DESCRIBE=${{ inputs.force-version }}" >> $GITHUB_ENV
85+
if: ${{ inputs.set-version != '' }}
86+
run: echo "OVERRIDE_GIT_DESCRIBE=${{ inputs.set-version }}" >> $GITHUB_ENV
8787

8888
- name: Install Astral UV
8989
uses: astral-sh/setup-uv@v6
@@ -149,7 +149,6 @@ jobs:
149149
uv run -v pytest ${{ inputs.testsuite == 'fast' && './tests/fast' || './tests' }} --verbose --ignore=./tests/stubs
150150
151151
steps:
152-
153152
- name: Checkout DuckDB Python
154153
uses: actions/checkout@v4
155154
with:
@@ -166,8 +165,8 @@ jobs:
166165
167166
# Make sure that OVERRIDE_GIT_DESCRIBE is propagated to cibuildwhel's env, also when it's running linux builds
168167
- name: Set OVERRIDE_GIT_DESCRIBE
169-
if: ${{ inputs.force-version != '' }}
170-
run: echo "CIBW_ENVIRONMENT=OVERRIDE_GIT_DESCRIBE=${{ inputs.force-version }}" >> $GITHUB_ENV
168+
if: ${{ inputs.set-version != '' }}
169+
run: echo "CIBW_ENVIRONMENT=OVERRIDE_GIT_DESCRIBE=${{ inputs.set-version }}" >> $GITHUB_ENV
171170

172171
# Install Astral UV, which will be used as build-frontend for cibuildwheel
173172
- uses: astral-sh/setup-uv@v6

.github/workflows/release.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Release is called by duckdb's InvokeCI -> NotifyExternalRepositories job
2+
name: Release
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
duckdb-sha:
7+
type: string
8+
description: The DuckDB submodule commit to build against
9+
required: true
10+
stable-version:
11+
type: string
12+
description: Release a stable version (vX.Y.Z-((rc|post)N))
13+
required: false
14+
pypi-index:
15+
type: choice
16+
description: Which PyPI to use
17+
required: true
18+
options:
19+
- test
20+
- prod
21+
store-s3:
22+
type: boolean
23+
description: Also store test packages in S3
24+
default: false
25+
26+
defaults:
27+
run:
28+
shell: bash
29+
30+
jobs:
31+
build_and_test:
32+
name: Build and test releases
33+
uses: ./.github/workflows/packaging.yml
34+
with:
35+
minimal: false
36+
testsuite: none
37+
git-ref: ${{ github.ref }}
38+
duckdb-git-ref: ${{ inputs.duckdb-sha }}
39+
set-version: ${{ inputs.stable-version }}
40+
41+
upload_s3:
42+
name: Upload Artifacts to S3
43+
runs-on: ubuntu-latest
44+
needs: [build_and_test]
45+
if: ${{ github.repository_owner == 'duckdb' && ( inputs.pypi-index == 'prod' || inputs.store-s3 ) }}
46+
steps:
47+
- name: Fetch artifacts
48+
uses: actions/download-artifact@v4
49+
with:
50+
pattern: '{sdist,wheel}*'
51+
path: artifacts/
52+
merge-multiple: true
53+
54+
- name: Authenticate with AWS
55+
uses: aws-actions/configure-aws-credentials@v4
56+
with:
57+
aws-region: 'us-east-2'
58+
aws-access-key-id: ${{ secrets.S3_DUCKDB_STAGING_ID }}
59+
aws-secret-access-key: ${{ secrets.S3_DUCKDB_STAGING_KEY }}
60+
61+
- name: Upload Artifacts
62+
id: s3_upload
63+
run: |
64+
sha=${{ github.ref }}
65+
aws s3 cp artifacts s3://duckdb-staging/${{ github.repository }}/${sha:0:10}/ --recursive
66+
67+
- name: S3 Upload Summary
68+
run : |
69+
sha=${{ github.ref }}
70+
version=$(basename artifacts/*.tar.gz | sed 's/duckdb-\(.*\).tar.gz/\1/g')
71+
echo "## S3 Upload Summary" >> $GITHUB_STEP_SUMMARY
72+
echo "* Version: ${version}" >> $GITHUB_STEP_SUMMARY
73+
echo "* SHA: ${sha:0:10}" >> $GITHUB_STEP_SUMMARY
74+
echo "* S3 URL: s3://duckdb-staging/${{ github.repository }}/${sha:0:10}/" >> $GITHUB_STEP_SUMMARY
75+
76+
determine_environment:
77+
name: Determine the Github Actions environment to use
78+
runs-on: ubuntu-latest
79+
needs: build_and_test
80+
outputs:
81+
env_name: ${{ steps.set-env.outputs.env_name }}
82+
steps:
83+
- name: Set environment name
84+
id: set-env
85+
run: |
86+
set -euo pipefail
87+
case "${{ inputs.pypi-index }}" in
88+
test)
89+
echo "env_name=pypi-test" >> "$GITHUB_OUTPUT"
90+
;;
91+
prod)
92+
if [[ -n "${{ inputs.stable-version }}" ]]; then
93+
echo "env_name=pypi-prod" >> "$GITHUB_OUTPUT"
94+
else
95+
echo "env_name=pypi-prod-nightly" >> "$GITHUB_OUTPUT"
96+
fi
97+
;;
98+
*)
99+
echo "Error: invalid combination of inputs.pypi-index='${{ inputs.pypi-index }}' and inputs.stable-version='${{ inputs.stable-version }}'" >&2
100+
exit 1
101+
;;
102+
esac
103+
104+
publish_pypi:
105+
name: Publish Artifacts to PyPI
106+
runs-on: ubuntu-latest
107+
needs: determine_environment
108+
environment:
109+
name: ${{ needs.determine_environment.outputs.env_name }}
110+
permissions:
111+
# this is needed for the OIDC flow that is used with trusted publishing on PyPI
112+
id-token: write
113+
steps:
114+
- if: ${{ vars.PYPI_HOST == '' }}
115+
run: |
116+
echo "Error: PYPI_HOST is not set in CI environment '${{ needs.determine_environment.outputs.env_name }}'"
117+
exit 1
118+
119+
- name: Fetch artifacts
120+
uses: actions/download-artifact@v4
121+
with:
122+
pattern: '{sdist,wheel}*'
123+
path: packages/
124+
merge-multiple: true
125+
126+
- name: Upload artifacts to PyPI
127+
uses: pypa/gh-action-pypi-publish@release/v1
128+
with:
129+
repository-url: 'https://${{ vars.PYPI_HOST }}/legacy/'
130+
packages-dir: packages
131+
verbose: 'true'
132+
133+
- name: PyPI Upload Summary
134+
run : |
135+
version=$(basename packages/*.tar.gz | sed 's/duckdb-\(.*\).tar.gz/\1/g')
136+
echo "## PyPI Upload Summary" >> $GITHUB_STEP_SUMMARY
137+
echo "* Version: ${version}" >> $GITHUB_STEP_SUMMARY
138+
echo "* PyPI Host: ${{ vars.PYPI_HOST }}" >> $GITHUB_STEP_SUMMARY
139+
echo "* CI Environment: ${{ needs.determine_environment.outputs.env_name }}" >> $GITHUB_STEP_SUMMARY
140+
141+
cleanup_nightlies:
142+
name: Remove Nightlies from PyPI
143+
needs: [determine_environment, publish_pypi]
144+
if: ${{ inputs.stable-version == '' }}
145+
uses: ./.github/workflows/cleanup_pypi.yml
146+
with:
147+
environment: ${{ needs.determine_environment.outputs.env_name }}

0 commit comments

Comments
 (0)