From 77544bfd969026f61eca0fe04745b78bfb7dd730 Mon Sep 17 00:00:00 2001 From: Philippe Scorsolini Date: Thu, 17 Jun 2021 16:23:05 +0200 Subject: [PATCH] Added release workflows with chart-releaser (#5) Following the automated release process, this time for the helm chart. This patch includes some order on the workflows plus the addition of the chart-releaser action. The steps to release can be found in the RELEASE.md file. Co-authored-by: Jonathan Gonzalez V --- .github/dependabot.yml | 6 ++++ .github/workflows/continuous-delivery.yml | 34 +----------------- .github/workflows/lint.yml | 36 +++++++++++++++++++ .github/workflows/release-pr.yml | 31 ++++++++++++++++ .github/workflows/release-publish.yml | 30 ++++++++++++++++ .github/workflows/release-tag.yml | 28 +++++++++++++++ README.md | 14 ++++++-- RELEASE.md | 19 ++++++++++ .../cloud-native-postgresql}/.helmignore | 0 .../cloud-native-postgresql}/Chart.yaml | 3 ++ .../cloud-native-postgresql}/LICENSE | 0 .../cloud-native-postgresql}/README.md | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/configmap.yaml | 0 .../templates/crds/crds.yaml | 0 .../templates/deployment.yaml | 0 .../mutatingwebhookconfiguration.yaml | 0 .../templates/rbac.yaml | 0 .../templates/service.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../validatingwebhookconfiguration.yaml | 0 .../values.schema.json | 0 .../cloud-native-postgresql}/values.yaml | 8 ++--- 24 files changed, 170 insertions(+), 39 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/release-pr.yml create mode 100644 .github/workflows/release-publish.yml create mode 100644 .github/workflows/release-tag.yml create mode 100644 RELEASE.md rename {cloud-native-postgresql => charts/cloud-native-postgresql}/.helmignore (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/Chart.yaml (94%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/LICENSE (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/README.md (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/NOTES.txt (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/_helpers.tpl (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/configmap.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/crds/crds.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/deployment.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/mutatingwebhookconfiguration.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/rbac.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/service.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/tests/test-connection.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/templates/validatingwebhookconfiguration.yaml (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/values.schema.json (100%) rename {cloud-native-postgresql => charts/cloud-native-postgresql}/values.yaml (93%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1230149 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 9e2a8cc..97c1c92 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -1,41 +1,9 @@ name: continuous-delivery on: - push: pull_request: jobs: - linter: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up Helm - uses: azure/setup-helm@v1 - with: - version: v3.4.0 - - - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.0.1 - - - name: Run chart-testing (list-changed) - id: list-changed - run: | - changed=$(ct list-changed --target-branch=main) - if [[ -n "$changed" ]]; then - echo "::set-output name=changed::true" - fi - - - name: Run chart-testing (lint) - run: ct lint --target-branch=main - install_deploy: runs-on: ubuntu-20.04 steps: @@ -55,7 +23,7 @@ jobs: - name: Deploy using helm chart run: | helm upgrade --install cnp --namespace postgresql-operator-system \ - --create-namespace cloud-native-postgresql --wait + --create-namespace charts/cloud-native-postgresql --wait - name: Install kubectl uses: azure/setup-kubectl@v1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3884b1e --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,36 @@ +name: linter + +on: + push: + +jobs: + linter: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.0.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch=main) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi + + - name: Run chart-testing (lint) + run: ct lint --target-branch=main diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml new file mode 100644 index 0000000..f433a99 --- /dev/null +++ b/.github/workflows/release-pr.yml @@ -0,0 +1,31 @@ +# Create a PR for a release when a commit is pushed on a release/v* branch + +name: release-pr + +on: + push: + branches: + - release/v* + +jobs: + pull-request: + runs-on: ubuntu-20.04 + steps: + - + name: Checkout + uses: actions/checkout@v2.3.4 + - + name: Get tag + run: | + echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV + - + name: Pull Request + id: open-pr + uses: repo-sync/pull-request@v2.6 + with: + destination_branch: "main" + github_token: ${{ secrets.GITHUB_TOKEN }} + pr_body: "Automated PR. Will trigger the ${{ env.TAG }} release when approved." + pr_label: release + pr_title: "Release ${{ env.TAG }}" + diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml new file mode 100644 index 0000000..841d5e8 --- /dev/null +++ b/.github/workflows/release-publish.yml @@ -0,0 +1,30 @@ +name: release-publish + +on: + push: + tags: + - v* + +jobs: + release: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.2.1 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml new file mode 100644 index 0000000..26ccc5e --- /dev/null +++ b/.github/workflows/release-tag.yml @@ -0,0 +1,28 @@ +# Create a tag when a PR on a release/v* branch is merged + +name: release-tag + +on: + pull_request: + types: + - closed + branches: + - main + +jobs: + tag: + runs-on: ubuntu-20.04 + steps: + - + name: Checkout + uses: actions/checkout@v2.3.4 + - + name: Create tag + if: github.event.pull_request.merged == true && startsWith(${{ github.head_ref }}, "release/v") + uses: christophebedard/tag-version-commit@v1.6.0 + with: + token: ${{ secrets.REPO_GHA_PAT }} + version_regex: '^Version tag to ([0-9]+\.[0-9]+\.[0-9]+)' + version_tag_prefix: v + dry_run: false + diff --git a/README.md b/README.md index 710e1c6..e44fdee 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,17 @@ designed by EnterpriseDB to manage PostgreSQL workloads on any supported Kubernetes cluster running in private, public, or hybrid cloud environments. -## Deployment +## Deployment using the latest release + +```console +helm repo add cnp https://enterprisedb.github.io/cloud-native-postgresql-helm/ +helm upgrade --install cnp \ + --namespace postgresql-operator-system \ + --create-namespace \ + cnp/cloud-native-postgresql +``` + +## Deployment using local chart To deploy the operator from sources you can run the following command: @@ -14,7 +24,7 @@ To deploy the operator from sources you can run the following command: helm upgrade --install cnp \ --namespace postgresql-operator-system \ --create-namespace \ - cloud-native-postgresql + charts/cloud-native-postgresql ``` ## Copyright diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000..1b4e309 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,19 @@ +# Cloud Native PostgreSQL release procedure + +**Steps:** + +The following steps assume version 0.2.0 as the one to be released. Alter the +instructions accordingly. + +1. Create branch `release/v0.2.0` +1. Approve the PR that is automatically generated. +1. The tag 0.2.0 will be created when the PR is merged. +1. The helm chart will be automatically added to the chart index. + +To check the chart was updated correctly, run: +```bash +helm repo add cnp https://enterprisedb.github.io/cloud-native-postgresql-helm/ +# or "helm repo update" if already added +helm search repo cnp +``` +and you should see the latest version available. diff --git a/cloud-native-postgresql/.helmignore b/charts/cloud-native-postgresql/.helmignore similarity index 100% rename from cloud-native-postgresql/.helmignore rename to charts/cloud-native-postgresql/.helmignore diff --git a/cloud-native-postgresql/Chart.yaml b/charts/cloud-native-postgresql/Chart.yaml similarity index 94% rename from cloud-native-postgresql/Chart.yaml rename to charts/cloud-native-postgresql/Chart.yaml index cc86ba7..3b5b999 100644 --- a/cloud-native-postgresql/Chart.yaml +++ b/charts/cloud-native-postgresql/Chart.yaml @@ -33,3 +33,6 @@ keywords: - postgres - database home: https://www.enterprisedb.com/products/postgresql-on-kubernetes-ha-clusters-k8s-containers-scalable +maintainers: + - name: phisco + email: philippe.scorsolini@enterprisedb.com diff --git a/cloud-native-postgresql/LICENSE b/charts/cloud-native-postgresql/LICENSE similarity index 100% rename from cloud-native-postgresql/LICENSE rename to charts/cloud-native-postgresql/LICENSE diff --git a/cloud-native-postgresql/README.md b/charts/cloud-native-postgresql/README.md similarity index 100% rename from cloud-native-postgresql/README.md rename to charts/cloud-native-postgresql/README.md diff --git a/cloud-native-postgresql/templates/NOTES.txt b/charts/cloud-native-postgresql/templates/NOTES.txt similarity index 100% rename from cloud-native-postgresql/templates/NOTES.txt rename to charts/cloud-native-postgresql/templates/NOTES.txt diff --git a/cloud-native-postgresql/templates/_helpers.tpl b/charts/cloud-native-postgresql/templates/_helpers.tpl similarity index 100% rename from cloud-native-postgresql/templates/_helpers.tpl rename to charts/cloud-native-postgresql/templates/_helpers.tpl diff --git a/cloud-native-postgresql/templates/configmap.yaml b/charts/cloud-native-postgresql/templates/configmap.yaml similarity index 100% rename from cloud-native-postgresql/templates/configmap.yaml rename to charts/cloud-native-postgresql/templates/configmap.yaml diff --git a/cloud-native-postgresql/templates/crds/crds.yaml b/charts/cloud-native-postgresql/templates/crds/crds.yaml similarity index 100% rename from cloud-native-postgresql/templates/crds/crds.yaml rename to charts/cloud-native-postgresql/templates/crds/crds.yaml diff --git a/cloud-native-postgresql/templates/deployment.yaml b/charts/cloud-native-postgresql/templates/deployment.yaml similarity index 100% rename from cloud-native-postgresql/templates/deployment.yaml rename to charts/cloud-native-postgresql/templates/deployment.yaml diff --git a/cloud-native-postgresql/templates/mutatingwebhookconfiguration.yaml b/charts/cloud-native-postgresql/templates/mutatingwebhookconfiguration.yaml similarity index 100% rename from cloud-native-postgresql/templates/mutatingwebhookconfiguration.yaml rename to charts/cloud-native-postgresql/templates/mutatingwebhookconfiguration.yaml diff --git a/cloud-native-postgresql/templates/rbac.yaml b/charts/cloud-native-postgresql/templates/rbac.yaml similarity index 100% rename from cloud-native-postgresql/templates/rbac.yaml rename to charts/cloud-native-postgresql/templates/rbac.yaml diff --git a/cloud-native-postgresql/templates/service.yaml b/charts/cloud-native-postgresql/templates/service.yaml similarity index 100% rename from cloud-native-postgresql/templates/service.yaml rename to charts/cloud-native-postgresql/templates/service.yaml diff --git a/cloud-native-postgresql/templates/tests/test-connection.yaml b/charts/cloud-native-postgresql/templates/tests/test-connection.yaml similarity index 100% rename from cloud-native-postgresql/templates/tests/test-connection.yaml rename to charts/cloud-native-postgresql/templates/tests/test-connection.yaml diff --git a/cloud-native-postgresql/templates/validatingwebhookconfiguration.yaml b/charts/cloud-native-postgresql/templates/validatingwebhookconfiguration.yaml similarity index 100% rename from cloud-native-postgresql/templates/validatingwebhookconfiguration.yaml rename to charts/cloud-native-postgresql/templates/validatingwebhookconfiguration.yaml diff --git a/cloud-native-postgresql/values.schema.json b/charts/cloud-native-postgresql/values.schema.json similarity index 100% rename from cloud-native-postgresql/values.schema.json rename to charts/cloud-native-postgresql/values.schema.json diff --git a/cloud-native-postgresql/values.yaml b/charts/cloud-native-postgresql/values.yaml similarity index 93% rename from cloud-native-postgresql/values.yaml rename to charts/cloud-native-postgresql/values.yaml index 2c83215..4468c71 100644 --- a/cloud-native-postgresql/values.yaml +++ b/charts/cloud-native-postgresql/values.yaml @@ -39,13 +39,13 @@ webhook: config: create: true data: {} - #INHERITED_ANNOTATIONS: categories - #INHERITED_LABELS: environment, workload, app - #EDB_LICENSE_KEY: + # INHERITED_ANNOTATIONS: categories + # INHERITED_LABELS: environment, workload, app + # EDB_LICENSE_KEY: name: postgresql-operator-controller-manager-config # -- Additinal arguments to be added to the operator's args list -additionalArgs: [] +additionalArgs: [] serviceAccount: # -- Specifies whether a service account should be created