From 66ef691d28899346846b8568198f6a2937a9185a Mon Sep 17 00:00:00 2001 From: Matthew Rogers Date: Wed, 13 Nov 2024 13:32:25 +0000 Subject: [PATCH] ci: semantic release (#144) * ci: add semantic release config --- .circleci/config.yml | 37 +++++++++++++++++++++++++- .github/workflows/helm-releaser.yaml | 35 ------------------------ .github/workflows/helm-validation.yaml | 25 ----------------- .releaserc | 31 +++++++++++++++++++++ 4 files changed, 67 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/helm-releaser.yaml delete mode 100644 .github/workflows/helm-validation.yaml create mode 100644 .releaserc diff --git a/.circleci/config.yml b/.circleci/config.yml index c8d2257..c8fe3e3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,11 +3,46 @@ version: 2.1 orbs: prodsec: snyk/prodsec-orb@1.0 +executors: + k8s: + docker: + - image: alpine/k8s:1.28.14 + resource_class: small + node: + docker: + - image: cimg/node:lts + resource_class: small + +jobs: + unittest: + executor: k8s + steps: + - checkout + - run: + name: helm unittest + command: helm unittest charts/snyk-broker + + publish: + executor: node + steps: + - checkout + - run: + name: publish + command: npx semantic-release + workflows: - scans: + validate_and_publish: jobs: - prodsec/secrets-scan: name: Scan repository for secrets context: - snyk-bot-slack channel: broker-alerts + - unittest + - publish: + context: + - team-hybrid-common + filters: + branches: + only: + - main diff --git a/.github/workflows/helm-releaser.yaml b/.github/workflows/helm-releaser.yaml deleted file mode 100644 index 5830bf5..0000000 --- a/.github/workflows/helm-releaser.yaml +++ /dev/null @@ -1,35 +0,0 @@ -name: Release Charts - -on: - push: - branches: - - main - -jobs: - release: - runs-on: ubuntu-latest - 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@v3 - with: - version: v3.10.0 - - - name: Run helm unittest - run: | - helm plugin install https://github.com/helm-unittest/helm-unittest - helm unittest charts/snyk-broker - - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.4.1 - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/helm-validation.yaml b/.github/workflows/helm-validation.yaml deleted file mode 100644 index 5103463..0000000 --- a/.github/workflows/helm-validation.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Validate Charts - -on: - push: - branches: - - '**' - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install Helm - uses: azure/setup-helm@v3 - with: - version: v3.10.0 - - - name: Run helm unittest - run: | - helm plugin install https://github.com/helm-unittest/helm-unittest --version 0.6.1 - helm unittest charts/snyk-broker diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..bd2c791 --- /dev/null +++ b/.releaserc @@ -0,0 +1,31 @@ +{ + "branches": [ + { + "name": "main" + } + ], + "repositoryUrl": "git@github.com:snyk/snyk-broker-helm.git", + "tagFormat": "snyk-broker-${version}", + "plugins": [ + "@semantic-release/commit-analyzer", + [ + "@semantic-release/exec", + { + "prepareCmd": "helm package --version ${nextRelease.version} .", + "execCwd": "charts/snyk-broker" + } + ], + [ + "@semantic-release/github", + { + "assets": [ + { + "path": "charts/snyk-broker/snyk-broker-*.tgz" + } + ], + "successCommentCondition": false, + "failCommentCondition": false + } + ] + ] +}