Skip to content

Commit

Permalink
Release automation (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
whites11 authored Aug 7, 2024
1 parent 36dd0c0 commit 28978f9
Show file tree
Hide file tree
Showing 14 changed files with 239 additions and 66 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/make-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Make release

on:
push:
branches:
- "main"

defaults:
run:
shell: bash

jobs:
release:
permissions:
contents: write
pull-requests: write

runs-on: [dataplane, self-hosted, linux, x64, small]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check release
id: check
run: |
last_commit_msg="$(git log -1 --pretty=%B|head -n1)"
echo "Last commit msg = '${last_commit_msg}'"
if [[ $last_commit_msg == \[RELEASE* ]]
then
version="$(echo "$last_commit_msg" | cut -d"]" -f1 | cut -d" " -f2)"
else
echo "Latest commit does not look like a release commit"
echo "release-version=null" >> $GITHUB_OUTPUT
exit 0
fi
# strip any leading "v" from the release.
version="${version#v}"
# validate semver.
if [[ $version =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo "Preparing release $version"
else
echo "Invalid semver $version in branch name"
exit 1
fi
echo "release-version=${version}" >> $GITHUB_OUTPUT
- name: Create tag
if: ${{ steps.check.outputs.release-version != 'null' }}
run: |
tag="disabled-v${{ steps.check.outputs.release-version }}"
git tag $tag
git push origin $tag
58 changes: 58 additions & 0 deletions .github/workflows/prepare-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Prepare release

on:
workflow_dispatch:
inputs:
version:
required: true
description: "The semver formatted version for the new release i.e 0.3.1"

defaults:
run:
shell: bash

jobs:
bump:
permissions:
contents: write
pull-requests: write

runs-on: [dataplane, self-hosted, linux, x64, small]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Bump provider version in examples
id: bump
run: |
version="${{ inputs.version }}"
# strip any leading "v" from the release.
version="${version#v}"
# validate semver.
if [[ $version =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo "Preparing release $version"
else
echo "Invalid semver $version in branch name"
exit 1
fi
echo "release-version=${version}" >> $GITHUB_OUTPUT
# Bump semver in examples
export CLICKHOUSE_TERRAFORM_PROVIDER_VERSION="$version"
for f in `find examples -name provider.tf.template`
do
dst="${f%.template}"
cat $f | envsubst > $dst
sed -i '1s/^/# This file is generated automatically please do not edit\n/' $dst
done
- name: Open PR with changes
id: pr
uses: peter-evans/create-pull-request@v6
with:
branch: "bump-provider-to-${{ steps.bump.outputs.release-version }}"
title: "[RELEASE ${{ steps.bump.outputs.release-version }}] Bump provider version in examples"
15 changes: 0 additions & 15 deletions examples/PrivateLink/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}
}
}

variable "organization_id" {
type = string
}
Expand All @@ -19,12 +10,6 @@ variable "token_secret" {
type = string
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}

resource "clickhouse_service" "aws_red" {
name = "red"
cloud_provider = "aws"
Expand Down
14 changes: 14 additions & 0 deletions examples/PrivateLink/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}
}
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
14 changes: 14 additions & 0 deletions examples/PrivateLink/provider.tf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
clickhouse = {
version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}"
source = "ClickHouse/clickhouse"
}
}
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
21 changes: 0 additions & 21 deletions examples/PrivateLinkAzure/main.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}

azapi = {
source = "Azure/azapi"
version = "1.13.1"
}

}
}

variable "organization_id" {
type = string
}
Expand Down Expand Up @@ -40,12 +25,6 @@ variable "private_endpoint_azure_bar_uuid" {
default = ""
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}

resource "clickhouse_service" "azure_red" {
name = "red"
cloud_provider = "azure"
Expand Down
20 changes: 20 additions & 0 deletions examples/PrivateLinkAzure/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}

azapi = {
source = "Azure/azapi"
version = "1.13.1"
}

}
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
20 changes: 20 additions & 0 deletions examples/PrivateLinkAzure/provider.tf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
terraform {
required_providers {
clickhouse = {
version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}"
source = "ClickHouse/clickhouse"
}

azapi = {
source = "Azure/azapi"
version = "1.13.1"
}

}
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
15 changes: 0 additions & 15 deletions examples/PrivateServiceConnect/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}
}
}

variable "organization_id" {
type = string
}
Expand All @@ -19,12 +10,6 @@ variable "token_secret" {
type = string
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}

resource "clickhouse_service" "gcp_red" {
name = "gcp_red"
cloud_provider = "gcp"
Expand Down
14 changes: 14 additions & 0 deletions examples/PrivateServiceConnect/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}
}
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
14 changes: 14 additions & 0 deletions examples/PrivateServiceConnect/provider.tf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
clickhouse = {
version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}"
source = "ClickHouse/clickhouse"
}
}
}

provider "clickhouse" {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
15 changes: 0 additions & 15 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}
}
}

variable "organization_id" {
type = string
}
Expand All @@ -19,12 +10,6 @@ variable "token_secret" {
type = string
}

provider clickhouse {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}

resource "clickhouse_service" "service" {
name = "My Terraform Service"
cloud_provider = "aws"
Expand Down
14 changes: 14 additions & 0 deletions examples/basic/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
clickhouse = {
version = "0.0.10"
source = "ClickHouse/clickhouse"
}
}
}

provider clickhouse {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}
14 changes: 14 additions & 0 deletions examples/basic/provider.tf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
clickhouse = {
version = "${CLICKHOUSE_TERRAFORM_PROVIDER_VERSION}"
source = "ClickHouse/clickhouse"
}
}
}

provider clickhouse {
organization_id = var.organization_id
token_key = var.token_key
token_secret = var.token_secret
}

0 comments on commit 28978f9

Please sign in to comment.