From 28656f30286ee7b5d166144ba2e05c78cfdbafd1 Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Wed, 21 Feb 2024 13:24:07 -0500 Subject: [PATCH] ci: Replace releaser and circleci with release please --- .circleci/config.yml | 49 -------------------------- .github/actions/ci/action.yml | 15 ++++++++ .github/actions/publish/action.yml | 51 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 22 ++++++++++++ .github/workflows/lint-pr-title.yml | 12 +++++++ .github/workflows/manual-publish.yml | 28 +++++++++++++++ .github/workflows/release-please.yml | 38 +++++++++++++++++++++ .github/workflows/stale.yml | 10 ++++++ .ldrelease/build.sh | 25 -------------- .ldrelease/config.yml | 13 ------- .ldrelease/prepare.sh | 8 ----- .ldrelease/update-version.sh | 5 --- .release-please-manifest.json | 3 ++ CHANGELOG.md | 12 +++++++ Chart.yaml | 2 +- Makefile | 4 +++ README.md | 2 +- release-please-config.json | 10 ++++++ 18 files changed, 207 insertions(+), 102 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/actions/ci/action.yml create mode 100644 .github/actions/publish/action.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/lint-pr-title.yml create mode 100644 .github/workflows/manual-publish.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/stale.yml delete mode 100755 .ldrelease/build.sh delete mode 100644 .ldrelease/config.yml delete mode 100755 .ldrelease/prepare.sh delete mode 100755 .ldrelease/update-version.sh create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 7bf5ff4..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: 2.1 - -orbs: - helm: circleci/helm@2.0.1 - -workflows: - test: - jobs: - - test - - test-daily: - triggers: - - schedule: - cron: "0 6 * * * " - filters: - branches: - only: main - jobs: - - test - -jobs: - test: - docker: - - image: cimg/go:1.19 - - steps: - - checkout - - helm/install-helm-client - # We need to do this to ensure the git status command below returns a - # clean working tree. - - run: - name: Clean up after installation - command: rm get_helm.sh - - # Make test runs this already, but I'm separating it out here to make the - # CI output easier to read through. - - run: - name: Prepare environment - command: make prepare - - - run: - name: Run tests against chart - command: make test - - - run: - name: Ensure golden files are up-to-date - command: | - make update-golden-files - [[ -z $(git status --porcelain) ]] diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml new file mode 100644 index 0000000..b1a58bd --- /dev/null +++ b/.github/actions/ci/action.yml @@ -0,0 +1,15 @@ +name: Quality control +description: 'Run quality control checks' + +runs: + using: composite + steps: + - name: Run tests against chart + shell: bash + run: make test + + - name: Ensure golden files are up-to-date + shell: bash + run: | + make update-golden-files + [[ -z $(git status --porcelain) ]] diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 0000000..9120b5d --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,51 @@ +name: Publish Chart +description: 'Publish to gh-pages-backed chart repository' +inputs: + dry_run: + description: 'Is this a dry run. If so no package will be published.' + required: true + token: + description: 'The GitHub token used to upload artifacts to the published release' + required: true + +runs: + using: composite + steps: + - uses: actions/checkout@v4 + with: + ref: gh-pages + path: helm-repo + + - name: Determine chart version + shell: bash + id: version + run: | + version=$(helm show chart . | awk '/version/ { print $2 }') + echo "CHART_VERSION=$version" >> "$GITHUB_OUTPUT" + echo "ARTIFACT=ld-relay-$version.tgz" >> "$GITHUB_OUTPUT" + + - name: Package the helm chart + shell: bash + run: make package + + - name: Generate updated index.yaml + shell: bash + run: helm repo index . --url https://launchdarkly.github.io/ld-relay-helm --merge helm-repo/index.yaml + + - name: Move files into publishable directory + shell: bash + run: mv ${{ steps.version.outputs.ARTIFACT }} index.yaml helm-repo + + - name: Publish to GitHub pages + if: ${{ inputs.dry_run == 'false' }} + uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.1 + with: + docs_path: helm-repo + github_token: ${{ inputs.token }} + + - name: Attach published chart to release + if: ${{ inputs.dry_run == 'false' }} + shell: bash + run: gh release upload ${{ steps.version.outputs.CHART_VERSION }} helm-repo/${{ steps.version.outputs.ARTIFACT }} --clobber + env: + GH_TOKEN: ${{ inputs.token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7a7f0b6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: Quality control + +on: + push: + branches: [ main ] + paths-ignore: + - '**.md' # Do not need to run CI for markdown changes. + pull_request: + branches: [ main ] + paths-ignore: + - '**.md' + +jobs: + ci: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: azure/setup-helm@v4.0.0 + + - name: Run quality control checks + uses: ./.github/actions/ci diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 0000000..4ba79c1 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,12 @@ +name: Lint PR title + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + lint-pr-title: + uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml new file mode 100644 index 0000000..29c5a84 --- /dev/null +++ b/.github/workflows/manual-publish.yml @@ -0,0 +1,28 @@ +name: Publish Package +on: + workflow_dispatch: + inputs: + dry_run: + description: 'Is this a dry run? If so no package will be published.' + type: boolean + required: true + +jobs: + build-publish: + runs-on: ubuntu-latest + # Needed to get tokens during publishing. + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: azure/setup-helm@v4.0.0 + + - name: Run quality control checks + uses: ./.github/actions/ci + + - uses: ./.github/actions/publish + with: + dry_run: ${{ inputs.dry_run }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..0eb114a --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,38 @@ +name: Run Release Please + +on: + push: + branches: [ main ] + +jobs: + release-package: + runs-on: ubuntu-latest + permissions: + id-token: write # Needed if using OIDC to get release secrets. + contents: write # Contents and pull-requests are for release-please to make releases. + pull-requests: write + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + command: manifest + token: ${{secrets.GITHUB_TOKEN}} + default-branch: main + + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.releases_created }} + with: + fetch-depth: 0 # If you only need the current version keep this. + + - uses: azure/setup-helm@v4.0.0 + if: ${{ steps.release.outputs.releases_created }} + + - name: Run quality control checks + if: ${{ steps.release.outputs.releases_created }} + uses: ./.github/actions/ci + + - uses: ./.github/actions/publish + if: ${{ steps.release.outputs.releases_created }} + with: + dry_run: false + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..14118d4 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,10 @@ +name: 'Close stale issues and PRs' +on: + workflow_dispatch: + schedule: + # Happen once per day at 1:30 AM + - cron: '30 1 * * *' + +jobs: + sdk-close-stale: + uses: launchdarkly/gh-actions/.github/workflows/sdk-stale.yml@main diff --git a/.ldrelease/build.sh b/.ldrelease/build.sh deleted file mode 100755 index 0a695eb..0000000 --- a/.ldrelease/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -ue - -helm lint . -helm package . - -# Our helm chart is being hosted on GitHub Pages. -# -# In order to update the index.yaml file in the publish step, we need access to this branch of the repository. -GH_PAGES_DIR="$LD_RELEASE_TEMP_DIR/gh-pages" -git clone -b gh-pages https://github.com/launchdarkly/ld-relay-helm.git "$GH_PAGES_DIR" - -# We can use the latest built release, along with the previously published -# index.yaml file to generate an updated index.yaml. -helm repo index . --url https://launchdarkly.github.io/ld-relay-helm --merge "$GH_PAGES_DIR"/index.yaml - -cp ld-relay-"$LD_RELEASE_VERSION".tgz "$LD_RELEASE_ARTIFACTS_DIR" - -# We can place the new .tgz, all existing .tgz files, and the updated -# index.yaml files into the release docs directory, and releaser will handle -# updating the gh-pages branch for us. -mv ld-relay-"$LD_RELEASE_VERSION".tgz "$LD_RELEASE_DOCS_DIR" -mv index.yaml "$LD_RELEASE_DOCS_DIR" -mv "$GH_PAGES_DIR"/*.tgz "$LD_RELEASE_DOCS_DIR" diff --git a/.ldrelease/config.yml b/.ldrelease/config.yml deleted file mode 100644 index 248d445..0000000 --- a/.ldrelease/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 - -jobs: - - docker: - image: fedora:36 - -branches: - - name: main - - name: 2.x - - name: 1.x - -documentation: - gitHubPages: true diff --git a/.ldrelease/prepare.sh b/.ldrelease/prepare.sh deleted file mode 100755 index 6f6d537..0000000 --- a/.ldrelease/prepare.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -uex - -yum install -y helm git - -mkdir ~/.ssh -ssh-keyscan github.com > ~/.ssh/known_hosts diff --git a/.ldrelease/update-version.sh b/.ldrelease/update-version.sh deleted file mode 100755 index 3e053c9..0000000 --- a/.ldrelease/update-version.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -ue - -sed -i "/^version:/c version: ${LD_RELEASE_VERSION}" ./Chart.yaml diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..6110c0f --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "3.3.0" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab5007..8ef31c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ Change log All notable changes to the LaunchDarkly Relay Proxy Helm Chart will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org). +## [3.3.0](https://github.com/keelerm84/playground/compare/3.2.0...3.3.0) (2024-02-21) + + +### Features + +* Remove releaser config ([823a5ef](https://github.com/keelerm84/playground/commit/823a5efb51e77e787e0d415424896c7819606d0b)) + + +### Bug Fixes + +* Fix manual publish ([3d193e3](https://github.com/keelerm84/playground/commit/3d193e3810a00e896a7025adf3e530dc65f63e88)) + ## [3.2.0] - 2024-02-21 ### Added: - Add support for container lifecycle hooks. (Thanks, [Helinanu](https://github.com/launchdarkly/ld-relay-helm/pull/57)!) diff --git a/Chart.yaml b/Chart.yaml index 1515881..ee72bcc 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -23,7 +23,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 3.2.0 +version: 3.3.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/Makefile b/Makefile index 172e472..703f290 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,10 @@ unittest: #! Run the unit tests lint: #! Run helm lint against this chart @helm lint +.PHONY: package +package: #! Build the helm package (e.g. ld-relay-x.y.z.tgz) + @helm package . + .PHONY: update-golden-files update-golden-files: #! Update unit test golden files (WARNING: Will change your local fs) @go test ./test -update-golden=true diff --git a/README.md b/README.md index 0d13856..6fc2af9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LaunchDarkly Relay Proxy Helm Chart -[![CircleCI](https://dl.circleci.com/status-badge/img/gh/launchdarkly/ld-relay-helm/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/launchdarkly/ld-relay-helm/tree/main) +[![Quality control](https://github.com/launchdarkly/ld-relay-helm/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/ld-relay-helm/actions/workflows/ci.yml) A Helm chart to ease deployment of the [LaunchDarkly Relay Proxy](https://github.com/launchdarkly/ld-relay) to Kubernetes (k8s). diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..85a6e84 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,10 @@ +{ + "packages": { + ".": { + "release-type": "helm", + "versioning": "default", + "include-v-in-tag": false, + "include-component-in-tag": false + } + } +}