-
Notifications
You must be signed in to change notification settings - Fork 3
Add .deb packaging workflow with GitHub Releases #57
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,136 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 📦 Build .deb Packages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| branches: [main, customer-*] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tags: ["v*"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 📦 PG ${{ matrix.pg }} ${{ matrix.os.arch }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ${{ matrix.os.runner }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pg: [18, 17, 16] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| os: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - { arch: amd64, runner: ubuntu-22.04 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - { arch: arm64, runner: ubuntu-22.04-arm } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Add PostgreSQL APT Repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get install -y curl ca-certificates gnupg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install Build Dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo apt-get install -y \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| postgresql-${{ matrix.pg }} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| postgresql-server-dev-${{ matrix.pg }} \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmake ninja-build g++ libssl-dev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| submodules: recursive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need the whole history, branches, and tags? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Configure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cmake --preset release \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -DPG_CONFIG=/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: cmake --build build --parallel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install to Staging Directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: DESTDIR=${{ github.workspace }}/dest cmake --install build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Extract Version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: meta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION=$(jq -r '.version' META.json) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PKG_NAME="pg-stat-ch-${VERSION}-pg${{ matrix.pg }}-${{ matrix.os.arch }}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "pkg_name=$PKG_NAME" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install nfpm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl -fsSL -o /tmp/nfpm.deb https://github.com/goreleaser/nfpm/releases/download/v2.46.0/nfpm_2.46.0_${{ matrix.os.arch }}.deb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sudo dpkg -i /tmp/nfpm.deb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Build .deb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PG_MAJOR: ${{ matrix.pg }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| VERSION: ${{ steps.meta.outputs.version }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARCH: ${{ matrix.os.arch }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DESTDIR: ${{ github.workspace }}/dest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| envsubst < nfpm.yml > nfpm-resolved.yml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nfpm package -f nfpm-resolved.yml -p deb -t ${{ steps.meta.outputs.pkg_name }}.deb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Upload .deb Artifact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: ${{ steps.meta.outputs.pkg_name }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: ${{ steps.meta.outputs.pkg_name }}.deb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| release: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 🚀 Upload to Release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| needs: build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Download All .deb Artifacts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: debs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: pg-stat-ch-* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| merge-multiple: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Determine Release Tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$GITHUB_REF" == refs/tags/v* ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "prerelease=false" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| elif [[ "$GITHUB_REF" == refs/heads/main ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "tag=dev" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "prerelease=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # customer-foo -> customer-foo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BRANCH="${GITHUB_REF#refs/heads/}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "tag=$BRANCH" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "prerelease=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Create or Update Release | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TAG: ${{ steps.tag.outputs.tag }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PRERELEASE: ${{ steps.tag.outputs.prerelease }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ls -la debs/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "$PRERELEASE" == "true" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create the release if it doesn't exist yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gh release create "$TAG" -R "$GITHUB_REPOSITORY" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --prerelease \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --title "$TAG" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --notes "Rolling pre-release for \`$TAG\`. Updated on every push." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # For version tags, ensure the release exists before uploading assets. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gh release create "$TAG" -R "$GITHUB_REPOSITORY" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --title "$TAG" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --notes "Release $TAG" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+121
to
+133
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Create the release if it doesn't exist yet. | |
| gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \ | |
| gh release create "$TAG" -R "$GITHUB_REPOSITORY" \ | |
| --prerelease \ | |
| --title "$TAG" \ | |
| --notes "Rolling pre-release for \`$TAG\`. Updated on every push." | |
| # Upload .deb files, replacing any existing ones. | |
| gh release upload "$TAG" debs/*.deb -R "$GITHUB_REPOSITORY" --clobber | |
| else | |
| # For version tags, the release is created by release.yml. | |
| # Wait briefly for it to exist, then attach .debs. | |
| for i in 1 2 3 4 5; do | |
| gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 && break | |
| echo "Waiting for release $TAG to be created..." | |
| sleep 10 | |
| done | |
| gh release upload "$TAG" debs/*.deb -R "$GITHUB_REPOSITORY" --clobber | |
| fi | |
| # Create the pre-release if it doesn't exist yet. | |
| gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \ | |
| gh release create "$TAG" -R "$GITHUB_REPOSITORY" \ | |
| --prerelease \ | |
| --title "$TAG" \ | |
| --notes "Rolling pre-release for \`$TAG\`. Updated on every push." | |
| else | |
| # For version tags, ensure the release exists before uploading assets. | |
| gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \ | |
| gh release create "$TAG" -R "$GITHUB_REPOSITORY" \ | |
| --title "$TAG" \ | |
| --notes "Release $TAG" | |
| fi | |
| # Upload .deb files, replacing any existing ones. | |
| gh release upload "$TAG" debs/*.deb -R "$GITHUB_REPOSITORY" --clobber |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: postgresql-${PG_MAJOR}-pg-stat-ch | ||
| arch: ${ARCH} | ||
| version: ${VERSION} | ||
| release: 1 | ||
| platform: linux | ||
| section: database | ||
| priority: optional | ||
| maintainer: "Kaushik Iska <iska.kaushik@gmail.com>" | ||
| description: "PostgreSQL Query Telemetry Exporter to ClickHouse for PostgreSQL ${PG_MAJOR}" | ||
| vendor: ClickHouse | ||
| homepage: https://github.com/ClickHouse/pg_stat_ch | ||
| license: Apache-2.0 | ||
|
|
||
| depends: | ||
| - postgresql-${PG_MAJOR} | ||
| - libssl3 | ||
|
|
||
| contents: | ||
| # Extension SQL and control files. | ||
| - src: ${DESTDIR}/usr/share/postgresql/${PG_MAJOR}/extension/*.* | ||
| dst: /usr/share/postgresql/${PG_MAJOR}/extension/ | ||
|
|
||
| # Shared library. | ||
| - src: ${DESTDIR}/usr/lib/postgresql/${PG_MAJOR}/lib/pg_stat_ch.so | ||
| dst: /usr/lib/postgresql/${PG_MAJOR}/lib/pg_stat_ch.so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also do something like
curl -O https://salsa.debian.org/postgresql/postgresql-common/-/raw/master/pgdg/apt.postgresql.org.sh sh apt.postgresql.org.sh -i -v ${{ matrix.pg }} apt-get install -y cmake ninja-build g++ libssl-dev