|
| 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