feat(circleci): initial circleci configuration file
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
version: 2.1
|
||||
|
||||
workflows:
|
||||
package-helm-chart:
|
||||
jobs:
|
||||
- get-version:
|
||||
filters:
|
||||
tags: &filter-allow-all
|
||||
only: /.*/
|
||||
|
||||
- pre-commit:
|
||||
filters:
|
||||
tags: *filter-allow-all
|
||||
|
||||
- helm-package-and-publish:
|
||||
filters:
|
||||
tags: *filter-allow-all
|
||||
branches: &filter-only-main
|
||||
only:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
get-version:
|
||||
docker: &docker-image
|
||||
- image: cimg/base:2022.04
|
||||
working_directory: &workingdir /tmp/ci
|
||||
steps:
|
||||
- checkout
|
||||
- run: mkdir -p workspace
|
||||
- run:
|
||||
name: set version
|
||||
command: |
|
||||
echo "export VERSION=$(.circleci/get_version.sh)" >> workspace/env-vars
|
||||
- run:
|
||||
name: store version
|
||||
command: |
|
||||
cat workspace/env-vars >> $BASH_ENV
|
||||
- run:
|
||||
name: echo version
|
||||
command: |
|
||||
echo "VERSION=${VERSION}"
|
||||
- persist_to_workspace:
|
||||
root: workspace
|
||||
paths:
|
||||
- env-vars
|
||||
|
||||
pre-commit:
|
||||
parameters:
|
||||
config_file:
|
||||
default: ./.pre-commit-config.yaml
|
||||
description: Optional, path to pre-commit config file.
|
||||
type: string
|
||||
cache_prefix:
|
||||
default: ''
|
||||
description: |
|
||||
Optional cache prefix to be used on CircleCI. Can be used for cache busting or to ensure multiple jobs use different caches.
|
||||
type: string
|
||||
docker:
|
||||
- image: speckle/pre-commit-runner:latest
|
||||
resource_class: &docker-resource-class medium
|
||||
working_directory: *workingdir
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- cache-pre-commit-<<parameters.cache_prefix>>-{{ checksum "<<parameters.config_file>>" }}
|
||||
- run:
|
||||
name: Install pre-commit hooks
|
||||
command: pre-commit install-hooks --config <<parameters.config_file>>
|
||||
- save_cache:
|
||||
key: cache-pre-commit-<<parameters.cache_prefix>>-{{ checksum "<<parameters.config_file>>" }}
|
||||
paths:
|
||||
- ~/.cache/pre-commit
|
||||
- run:
|
||||
name: Run pre-commit
|
||||
command: pre-commit run --all-files --config <<parameters.config_file>>
|
||||
- run:
|
||||
command: git --no-pager diff
|
||||
name: git diff
|
||||
when: on_fail
|
||||
|
||||
helm-package-and-publish:
|
||||
docker:
|
||||
- image: quay.io/helmpack/chart-testing:v3.7.1-amd64
|
||||
resource_class: *docker-resource-class
|
||||
working_directory: *workingdir
|
||||
steps:
|
||||
- checkout
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- 'TODO: add fingerprint here'
|
||||
- attach_workspace:
|
||||
at: /tmp/workspace
|
||||
- run:
|
||||
name: populate environment variables
|
||||
command: |
|
||||
cat /tmp/workspace/env-vars >> $BASH_ENV
|
||||
- run:
|
||||
name: Build and Publish
|
||||
command: ./.circleci/package_and_publish_helm.sh
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
TEMP_PACKAGE_DIR="${TEMP_PACKAGE_DIR:-"/tmp/.cr-release-packages"}"
|
||||
HELM_PACKAGE_BRANCH="${HELM_PACKAGE_BRANCH:-"gh-pages"}"
|
||||
HELM_STABLE_BRANCH="${HELM_STABLE_BRANCH:-"main"}"
|
||||
HELM_CHART_DIR_PATH="${HELM_CHART_DIR_PATH:-"deploy/helm"}"
|
||||
|
||||
if [[ -z "${VERSION}" ]]; then
|
||||
echo "VERSION environment variable should be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "${GIT_EMAIL}" ]]; then
|
||||
echo "GIT_EMAIL environment variable should be set"
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "${GIT_USERNAME}" ]]; then
|
||||
echo "GIT_USERNAME environment variable should be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🧹 cleaning temporary directory"
|
||||
rm -rf "${TEMP_PACKAGE_DIR}" || true
|
||||
mkdir "${TEMP_PACKAGE_DIR}"
|
||||
|
||||
helm version -c
|
||||
|
||||
echo "🏗️ building dependencies"
|
||||
helm dependency build "${HELM_CHART_DIR_PATH}"
|
||||
echo "🎁 packaging ${HELM_CHART_DIR_PATH} with version: ${VERSION}"
|
||||
helm package "${HELM_CHART_DIR_PATH}" --dependency-update --version "${VERSION}" --app-version "${VERSION}" --destination "${TEMP_PACKAGE_DIR}"
|
||||
|
||||
echo "⏬ checking out git branch '${HELM_PACKAGE_BRANCH}'"
|
||||
git config user.email "${GIT_EMAIL}"
|
||||
git config user.name "${GIT_USERNAME}"
|
||||
git fetch
|
||||
git switch "${HELM_PACKAGE_BRANCH}"
|
||||
if [[ -n "${CIRCLE_TAG}" || "${CIRCLE_BRANCH}" == "${HELM_STABLE_BRANCH}" ]]; then
|
||||
echo "🛻 copying packages to stable directory"
|
||||
cp -a "${TEMP_PACKAGE_DIR}/." stable/
|
||||
pushd stable
|
||||
helm repo index .
|
||||
popd
|
||||
else
|
||||
cp -a "${TEMP_PACKAGE_DIR}/." incubator/
|
||||
echo "🛻 copying packages to incubator directory"
|
||||
pushd incubator
|
||||
helm repo index .
|
||||
popd
|
||||
fi
|
||||
|
||||
echo "⏫ adding, commiting, and pushing to git repository"
|
||||
git add .
|
||||
git commit -m "updating helm chart to version ${VERSION}"
|
||||
git push --set-upstream origin "${HELM_PACKAGE_BRANCH}"
|
||||
Reference in New Issue
Block a user