Release #541
This file contains 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
name: Release | |
# N.B.: build steps should match the tests we run in ci.yml | |
on: | |
create | |
jobs: | |
build: | |
# Use older Ubuntu release to avoid building with a too new glibc, which will cause | |
# errors on older distributions, if anyone uses the generated binary directly. | |
runs-on: ubuntu-20.04 | |
permissions: {} | |
# ensure we don't release on create events for branches (only tags) | |
if: ${{ startsWith( github.ref, 'refs/tags' ) }} | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21 | |
id: go | |
- name: Set up protoc | |
uses: pganalyze/setup-protoc@v3 | |
with: | |
version: 28.2 | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Runs tests | |
run: | | |
make build OUTFILE=pganalyze-collector-linux-amd64 | |
make test | |
DOCKER_BUILDKIT=1 make integration_test | |
- name: Upload build | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pganalyze-collector-linux-amd64 | |
path: pganalyze-collector-linux-amd64 | |
build_arm: | |
runs-on: ubicloud-standard-2-arm | |
permissions: {} | |
# ensure we don't release on create events for branches (only tags) | |
if: ${{ startsWith( github.ref, 'refs/tags' ) }} | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21 | |
id: go | |
- name: Set up protoc | |
uses: pganalyze/setup-protoc@v3 | |
with: | |
version: 28.2 | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Runs tests | |
run: | | |
make build OUTFILE=pganalyze-collector-linux-arm64 | |
make test | |
DOCKER_BUILDKIT=1 make integration_test | |
- name: Upload build | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pganalyze-collector-linux-arm64 | |
path: pganalyze-collector-linux-arm64 | |
build_packages: | |
# Use older Ubuntu release to ensure availability of CGroupsv1 (which are necessary | |
# currently to support older systemd on some of the test containers) | |
runs-on: ubuntu-20.04 | |
permissions: {} | |
# ensure we don't release on create events for branches (only tags) | |
if: ${{ startsWith( github.ref, 'refs/tags' ) }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Build packages | |
run: | | |
DOCKER_BUILDKIT=1 make -C packages build | |
- name: Test packages | |
run: | | |
DOCKER_BUILDKIT=1 make -C packages test | |
- name: Upload packages as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: packages | |
path: | | |
packages/tmp/pganalyze-collector-*.aarch64.rpm | |
packages/tmp/pganalyze-collector-*.x86_64.rpm | |
packages/tmp/pganalyze-collector_*_amd64.deb | |
packages/tmp/pganalyze-collector_*_arm64.deb | |
if-no-files-found: error | |
build_charts: | |
runs-on: ubuntu-latest | |
# ensure we don't release on create events for branches (only tags) | |
if: ${{ startsWith( github.ref, 'refs/tags' ) }} | |
steps: | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Create helm package | |
run: helm package contrib/helm/pganalyze-collector | |
- name: Upload packages as artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: charts | |
path: | | |
pganalyze-collector-*.tgz | |
if-no-files-found: error | |
release: | |
needs: [build, build_arm, build_packages, build_charts] | |
runs-on: ubuntu-latest | |
# ensure we don't release on create events for branches (only tags) | |
if: ${{ startsWith( github.ref, 'refs/tags' ) }} | |
steps: | |
- name: Download build | |
uses: actions/download-artifact@v4 | |
with: | |
name: pganalyze-collector-linux-amd64 | |
- name: Download arm build | |
uses: actions/download-artifact@v4 | |
with: | |
name: pganalyze-collector-linux-arm64 | |
- name: Download build packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
- name: Download helm package | |
uses: actions/download-artifact@v4 | |
with: | |
name: charts | |
- name: Get version and git version from tag | |
id: get_version | |
run: | | |
echo "git_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.git_version }} | |
release_name: ${{ steps.get_version.outputs.git_version }} | |
draft: false | |
prerelease: false | |
- name: Upload release build | |
id: upload-release-build | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pganalyze-collector-linux-amd64 | |
asset_name: pganalyze-collector-linux-amd64 | |
asset_content_type: application/octet-stream | |
- name: Upload release build (arm) | |
id: upload-release-build-arm | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pganalyze-collector-linux-arm64 | |
asset_name: pganalyze-collector-linux-arm64 | |
asset_content_type: application/octet-stream | |
- name: Upload release build package (RPM, x86-64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pganalyze-collector-${{ steps.get_version.outputs.version }}-1.x86_64.rpm | |
asset_name: pganalyze-collector-${{ steps.get_version.outputs.version }}-1.x86_64.rpm | |
asset_content_type: application/octet-stream | |
- name: Upload release build package (RPM, arm64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pganalyze-collector-${{ steps.get_version.outputs.version }}-1.aarch64.rpm | |
asset_name: pganalyze-collector-${{ steps.get_version.outputs.version }}-1.aarch64.rpm | |
asset_content_type: application/octet-stream | |
- name: Upload release build package (DEB, x86-64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pganalyze-collector_${{ steps.get_version.outputs.version }}_amd64.deb | |
asset_name: pganalyze-collector_${{ steps.get_version.outputs.version }}_amd64.deb | |
asset_content_type: application/octet-stream | |
- name: Upload release build package (DEB, arm64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./pganalyze-collector_${{ steps.get_version.outputs.version }}_arm64.deb | |
asset_name: pganalyze-collector_${{ steps.get_version.outputs.version }}_arm64.deb | |
asset_content_type: application/octet-stream | |
release_charts: | |
needs: [release] | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # for AWS credentials | |
# ensure we don't release on create events for branches (only tags) | |
if: ${{ startsWith( github.ref, 'refs/tags' ) }} | |
steps: | |
- name: Download helm package | |
uses: actions/download-artifact@v4 | |
with: | |
name: charts | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
- name: Get version from tag | |
id: get_version | |
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Load the current index.yaml | |
run: curl -o index.yaml https://charts.pganalyze.com/index.yaml | |
continue-on-error: true | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::793741702295:role/CollectorChartsPackage | |
aws-region: us-east-1 | |
- name: Upload package to S3 | |
run: | | |
aws s3 cp --acl public-read \ | |
pganalyze-collector-${{ steps.get_version.outputs.version }}.tgz s3://charts.pganalyze.com/pganalyze-collector-${{ steps.get_version.outputs.version }}.tgz | |
- name: Create or update index.yaml | |
run: helm repo index . --merge index.yaml --url https://charts.pganalyze.com/ | |
- name: Upload index.yaml to S3 | |
run: | | |
aws s3 cp --acl public-read --content-type application/yaml --cache-control no-cache \ | |
index.yaml s3://charts.pganalyze.com/index.yaml |