From d8834929db34ab4bb5ebf18e0c4d34a2490c6f7a Mon Sep 17 00:00:00 2001 From: Max Gabrielsson Date: Thu, 26 Oct 2023 11:37:14 +0200 Subject: [PATCH 1/2] add distribution of nightly extension binaries for latest stable duckdb --- .../workflows/MainDistributionPipeline.yml | 31 +++++ .github/workflows/_extension_deploy.yml | 121 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 .github/workflows/MainDistributionPipeline.yml create mode 100644 .github/workflows/_extension_deploy.yml diff --git a/.github/workflows/MainDistributionPipeline.yml b/.github/workflows/MainDistributionPipeline.yml new file mode 100644 index 00000000..602f2f59 --- /dev/null +++ b/.github/workflows/MainDistributionPipeline.yml @@ -0,0 +1,31 @@ +# +# This workflow calls the main distribution pipeline from DuckDB to build, test and (optionally) release the extension +# +name: Main Extension Distribution Pipeline +on: + push: + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} + cancel-in-progress: true + +jobs: + duckdb-stable-build: + name: Build extension binaries + uses: duckdb/duckdb/.github/workflows/_extension_distribution.yml@v0.9.1 + with: + duckdb_version: v0.9.1 + extension_name: spatial + vcpkg_commit: 9edb1b8e590cc086563301d735cae4b6e732d2d2 # TODO: remove pinned vcpkg commit when updating duckdb version + + duckdb-stable-deploy: + name: Deploy extension binaries + needs: duckdb-stable-build + uses: ./.github/workflows/_extension_deploy.yml + secrets: inherit + with: + duckdb_version: v0.9.1 + extension_name: spatial + deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }} \ No newline at end of file diff --git a/.github/workflows/_extension_deploy.yml b/.github/workflows/_extension_deploy.yml new file mode 100644 index 00000000..212ebca4 --- /dev/null +++ b/.github/workflows/_extension_deploy.yml @@ -0,0 +1,121 @@ +# +# Reusable workflow that deploys the artifacts produced by github.com/duckdb/duckdb/.github/workflows/_extension_distribution.yml +# +# note: this workflow needs to be located in the extension repository, as it requires secrets to be passed to the +# deploy script. However, it should generally not be necessary to modify this workflow in your extension repository, as +# this workflow can be configured to use a custom deploy script. + + +name: Extension Deployment +on: + workflow_call: + inputs: + # The name of the extension + extension_name: + required: true + type: string + # DuckDB version to build against + duckdb_version: + required: true + type: string + # ';' separated list of architectures to exclude, for example: 'linux_amd64;osx_arm64' + exclude_archs: + required: false + type: string + default: "" + # Whether to upload this deployment as the latest. This may overwrite a previous deployment. + deploy_latest: + required: false + type: boolean + default: false + # Whether to upload this deployment under a versioned path. These will not be deleted automatically + deploy_versioned: + required: false + type: boolean + default: false + # Postfix added to artifact names. Can be used to guarantee unique names when this workflow is called multiple times + artifact_postfix: + required: false + type: string + default: "" + # Override the default deploy script with a custom script + deploy_script: + required: false + type: string + default: "./scripts/extension-upload.sh" + # Override the default matrix parse script with a custom script + matrix_parse_script: + required: false + type: string + default: "./duckdb/scripts/modify_distribution_matrix.py" + +jobs: + generate_matrix: + name: Generate matrix + runs-on: ubuntu-latest + outputs: + deploy_matrix: ${{ steps.parse-matrices.outputs.deploy_matrix }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: 'true' + + - name: Checkout DuckDB to version + run: | + cd duckdb + git checkout ${{ inputs.duckdb_version }} + + - id: parse-matrices + run: | + python3 ${{ inputs.matrix_parse_script }} --input ./duckdb/.github/config/distribution_matrix.json --deploy_matrix --output deploy_matrix.json --exclude "${{ inputs.exclude_archs }}" --pretty + deploy_matrix="`cat deploy_matrix.json`" + echo deploy_matrix=$deploy_matrix >> $GITHUB_OUTPUT + echo `cat $GITHUB_OUTPUT` + + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: generate_matrix + if: ${{ needs.generate_matrix.outputs.deploy_matrix != '{}' && needs.generate_matrix.outputs.deploy_matrix != '' }} + strategy: + matrix: ${{fromJson(needs.generate_matrix.outputs.deploy_matrix)}} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: 'true' + + - name: Checkout DuckDB to version + run: | + cd duckdb + git checkout ${{ inputs.duckdb_version }} + + - uses: actions/download-artifact@v2 + with: + name: ${{ inputs.extension_name }}-${{ inputs.duckdb_version }}-extension-${{matrix.duckdb_arch}}${{inputs.artifact_postfix}} + path: | + /tmp/extension + + - name: Deploy + shell: bash + env: + AWS_ACCESS_KEY_ID: ${{ secrets.S3_DEPLOY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DEPLOY_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.S3_REGION }} + BUCKET_NAME: ${{ secrets.S3_BUCKET }} + DUCKDB_EXTENSION_SIGNING_PK: ${{ secrets.DUCKDB_EXTENSION_SIGNING_PK }} + run: | + pwd + python3 -m pip install pip awscli + git config --global --add safe.directory '*' + cd duckdb + git fetch --tags + export DUCKDB_VERSION=`git tag --points-at HEAD` + export DUCKDB_VERSION=${DUCKDB_VERSION:=`git log -1 --format=%h`} + cd .. + git fetch --tags + export EXT_VERSION=`git tag --points-at HEAD` + export EXT_VERSION=${EXT_VERSION:=`git log -1 --format=%h`} + ${{ inputs.deploy_script }} ${{ inputs.extension_name }} $EXT_VERSION $DUCKDB_VERSION ${{ matrix.duckdb_arch }} $BUCKET_NAME ${{inputs.deploy_latest || 'true' && 'false'}} ${{inputs.deploy_versioned || 'true' && 'false'}} \ No newline at end of file From e15b87651fb93f23dc36af1478e79d8e6b1057ff Mon Sep 17 00:00:00 2001 From: Max Gabrielsson Date: Thu, 26 Oct 2023 11:45:29 +0200 Subject: [PATCH 2/2] only run distribution on main push --- .github/workflows/MainDistributionPipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/MainDistributionPipeline.yml b/.github/workflows/MainDistributionPipeline.yml index 602f2f59..5080e744 100644 --- a/.github/workflows/MainDistributionPipeline.yml +++ b/.github/workflows/MainDistributionPipeline.yml @@ -4,7 +4,8 @@ name: Main Extension Distribution Pipeline on: push: - pull_request: + branches: + - main workflow_dispatch: concurrency: