-
Notifications
You must be signed in to change notification settings - Fork 75
Add release package workflow #190
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4d3980c
Add release package workflow
gdecandia 20d5ddb
Validate release packages against PostgreSQL
pinodeca 40bc822
Pass release version into package build container
pinodeca 48565f0
Cancel stale package workflow PR runs
pinodeca b9f1b92
Use Debian-valid package versions for PR builds
pinodeca 6d274b9
Use crate version for PR package builds
pinodeca b0c4359
Fix package validation database target
pinodeca 251b12d
Allow pgspot DSL operator finding
pinodeca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,282 @@ | ||
| name: Package Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: 'Tag/version to package, for example v0.2.2' | ||
| required: true | ||
| type: string | ||
| publish_release: | ||
| description: 'Upload assets to the GitHub release' | ||
| required: true | ||
| default: false | ||
| type: boolean | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| pull_request: | ||
| paths: | ||
| - '.github/workflows/package-release.yml' | ||
| - 'Cargo.toml' | ||
| - 'Cargo.lock' | ||
| - 'Makefile' | ||
| - 'expected/**' | ||
| - 'scripts/package-deb.sh' | ||
| - 'scripts/validate-deb-package.sh' | ||
| - 'sql/**' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | ||
| CARGO_PGRX_VERSION: 0.16.1 | ||
| PACKAGE_HTTP_FEATURE: http-allow-azure-domains | ||
|
|
||
| concurrency: | ||
| group: package-release-${{ github.event.inputs.tag || github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| build-packages: | ||
| name: Build PG${{ matrix.pg_version }} ${{ matrix.platform.type }} package | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| pg_version: [17, 18] | ||
| platform: | ||
| - type: amd64 | ||
| docker_platform: linux/amd64 | ||
| file_pattern: x86-64 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.inputs.tag || github.ref }} | ||
|
|
||
| - name: Set version | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "VERSION=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV" | ||
| elif [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| crate_version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) | ||
| echo "VERSION=${crate_version}~pr${{ github.event.pull_request.number }}+${GITHUB_SHA::7}" >> "$GITHUB_ENV" | ||
| else | ||
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV" | ||
| fi | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
|
pinodeca marked this conversation as resolved.
|
||
| - name: Build pgrx package in Docker | ||
| run: | | ||
| docker run --rm \ | ||
| --platform "${{ matrix.platform.docker_platform }}" \ | ||
| -e VERSION \ | ||
| -v "$PWD:/work" \ | ||
| -w /work \ | ||
| --user root \ | ||
| rustlang/rust:nightly-bookworm \ | ||
| bash -euxo pipefail -c ' | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| apt-get update | ||
| apt-get install -y \ | ||
| ca-certificates \ | ||
| curl \ | ||
| gnupg \ | ||
| lsb-release \ | ||
| pkg-config \ | ||
| libssl-dev \ | ||
| libclang-dev \ | ||
| clang \ | ||
| build-essential \ | ||
| bison \ | ||
| flex \ | ||
| libreadline-dev \ | ||
| zlib1g-dev \ | ||
| libxml2-dev \ | ||
| libxslt1-dev \ | ||
| libicu-dev \ | ||
| file \ | ||
| zip | ||
|
|
||
| install -d -m 0755 /usr/share/keyrings | ||
| curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ | ||
| | gpg --dearmor -o /usr/share/keyrings/postgresql-keyring.gpg | ||
| echo "deb [signed-by=/usr/share/keyrings/postgresql-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \ | ||
| > /etc/apt/sources.list.d/pgdg.list | ||
| apt-get update | ||
| apt-get install -y \ | ||
| postgresql-${{ matrix.pg_version }} \ | ||
| postgresql-server-dev-${{ matrix.pg_version }} | ||
|
|
||
| export PG_CONFIG="/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config" | ||
| export PATH="/usr/lib/postgresql/${{ matrix.pg_version }}/bin:$PATH" | ||
| cargo install cargo-pgrx --version "${{ env.CARGO_PGRX_VERSION }}" --locked | ||
| cargo pgrx init --pg${{ matrix.pg_version }} "$PG_CONFIG" | ||
|
|
||
| FEATURES="pg${{ matrix.pg_version }}" | ||
| if [ -n "${{ env.PACKAGE_HTTP_FEATURE }}" ]; then | ||
| FEATURES="$FEATURES,${{ env.PACKAGE_HTTP_FEATURE }}" | ||
| fi | ||
|
|
||
| cargo pgrx package \ | ||
| --pg-config "$PG_CONFIG" \ | ||
| --no-default-features \ | ||
| --features "$FEATURES" | ||
|
|
||
| scripts/package-deb.sh \ | ||
| "$VERSION" \ | ||
| "$PWD/target/release/pg_durable-pg${{ matrix.pg_version }}" \ | ||
| "${{ matrix.platform.type }}" \ | ||
| "${{ matrix.pg_version }}" | ||
| ' | ||
|
|
||
| - name: Verify Debian package | ||
| run: | | ||
| sudo chown -R "$USER:$USER" dist target || true | ||
| deb_file=$(ls dist/pg-durable-postgresql-${{ matrix.pg_version }}_*_${{ matrix.platform.type }}.deb) | ||
| echo "Checking $deb_file" | ||
| dpkg-deb --info "$deb_file" | ||
| dpkg-deb --contents "$deb_file" | grep "usr/lib/postgresql/${{ matrix.pg_version }}/lib/pg_durable.so" | ||
| dpkg-deb --contents "$deb_file" | grep "usr/share/postgresql/${{ matrix.pg_version }}/extension/pg_durable.control" | ||
| rm -rf check-package | ||
| mkdir check-package | ||
| dpkg-deb -x "$deb_file" check-package | ||
| file "check-package/usr/lib/postgresql/${{ matrix.pg_version }}/lib/pg_durable.so" | grep -E "${{ matrix.platform.file_pattern }}" | ||
|
|
||
| - name: Create package archive | ||
| run: | | ||
| cd dist | ||
| zip "pg-durable-${VERSION}-pg${{ matrix.pg_version }}-${{ matrix.platform.type }}.zip" \ | ||
| pg-durable-postgresql-${{ matrix.pg_version }}_*_${{ matrix.platform.type }}.deb | ||
|
|
||
| - name: Upload package artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pg-durable-package-${{ github.run_id }}-pg${{ matrix.pg_version }}-${{ matrix.platform.type }} | ||
| path: | | ||
| dist/*.deb | ||
| dist/*.zip | ||
| retention-days: 30 | ||
|
|
||
| validate-packages: | ||
| name: Validate PG${{ matrix.pg_version }} ${{ matrix.platform.type }} package | ||
| needs: build-packages | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| pg_version: [17, 18] | ||
| platform: | ||
| - type: amd64 | ||
| docker_platform: linux/amd64 | ||
|
pinodeca marked this conversation as resolved.
|
||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.inputs.tag || github.ref }} | ||
|
|
||
| - name: Download package artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: pg-durable-package-${{ github.run_id }}-pg${{ matrix.pg_version }}-${{ matrix.platform.type }} | ||
| path: dist | ||
|
|
||
| - name: Validate Debian package in PostgreSQL | ||
| run: | | ||
| docker run --rm \ | ||
| --platform "${{ matrix.platform.docker_platform }}" \ | ||
| -v "$PWD:/work" \ | ||
| -w /work \ | ||
| --user root \ | ||
| debian:bookworm \ | ||
| bash -euxo pipefail -c 'scripts/validate-deb-package.sh "${{ matrix.pg_version }}" "${{ matrix.platform.type }}"' | ||
|
pinodeca marked this conversation as resolved.
|
||
|
|
||
| - name: Upload validation diagnostics on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pg-durable-validation-diagnostics-${{ github.run_id }}-pg${{ matrix.pg_version }}-${{ matrix.platform.type }} | ||
| path: | | ||
| package-validation-logs/** | ||
| regression.out | ||
| regression.diffs | ||
| if-no-files-found: ignore | ||
|
|
||
| build-source: | ||
| name: Build source archives | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.inputs.tag || github.ref }} | ||
|
|
||
| - name: Set version | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "VERSION=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV" | ||
| elif [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| crate_version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) | ||
| echo "VERSION=${crate_version}~pr${{ github.event.pull_request.number }}+${GITHUB_SHA::7}" >> "$GITHUB_ENV" | ||
| else | ||
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV" | ||
| fi | ||
|
|
||
| - name: Create source archives | ||
| run: | | ||
| clean_version="${VERSION#v}" | ||
| mkdir -p dist | ||
| git archive --format=tar --prefix="pg_durable-${clean_version}/" HEAD -o "dist/pg_durable-${clean_version}.tar" | ||
| gzip -c "dist/pg_durable-${clean_version}.tar" > "dist/pg_durable-${clean_version}.tar.gz" | ||
| bzip2 -k "dist/pg_durable-${clean_version}.tar" | ||
| rm "dist/pg_durable-${clean_version}.tar" | ||
|
|
||
| - name: Upload source artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pg-durable-source-${{ github.run_id }} | ||
| path: dist/pg_durable-*.tar.* | ||
| retention-days: 30 | ||
|
|
||
| release: | ||
| name: Upload release assets | ||
| needs: [validate-packages, build-source] | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' || github.event.inputs.publish_release == 'true' | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.inputs.tag || github.ref }} | ||
|
|
||
| - name: Set version | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "VERSION=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV" | ||
| else | ||
| echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV" | ||
| fi | ||
|
|
||
| - name: Download artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
|
|
||
| - name: Upload assets | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| if ! gh release view "$VERSION" >/dev/null 2>&1; then | ||
| gh release create "$VERSION" \ | ||
| --title "Release $VERSION" \ | ||
| --notes "Release $VERSION" \ | ||
| --draft | ||
| fi | ||
|
|
||
| find artifacts -type f \( -name '*.zip' -o -name '*.tar.gz' -o -name '*.tar.bz2' \) -print0 \ | ||
| | xargs -0 -I {} gh release upload "$VERSION" "{}" --clobber | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.