-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
REGISTRY_IMAGE: devopsconsultants/conventional-changelog-release | ||
QUAY_IMAGE: quay.io/devops_consultants/conventional-changelog-release | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Conventional Changelog Action | ||
id: changelog | ||
uses: TriPSs/conventional-changelog-action@v5 | ||
with: | ||
version-file: version.json | ||
preset: conventionalcommits | ||
github-token: ${{ github.token }} | ||
release-count: "0" | ||
|
||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
if: ${{ steps.changelog.outputs.skipped == 'false' }} | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
tag_name: ${{ steps.changelog.outputs.tag }} | ||
release_name: ${{ steps.changelog.outputs.tag }} | ||
body: ${{ steps.changelog.outputs.clean_changelog }} | ||
|
||
outputs: | ||
relVer: ${{ steps.changelog.outputs.tag }} | ||
|
||
docker: | ||
runs-on: ubuntu-latest | ||
needs: [release] | ||
steps: | ||
- name: Get Tags for Image | ||
id: meta-new | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.REGISTRY_IMAGE }} | ||
${{ env.QUAY_IMAGE}} | ||
tags: | | ||
type=semver,pattern={{raw}},value=${{ needs.release.outputs.relVer }} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
# - name: Set up QEMU | ||
# uses: docker/setup-qemu-action@v3 | ||
|
||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to Quay.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.QUAY_ID }} | ||
password: ${{ secrets.QUAY_PW }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
# platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta-new.outputs.tags }} | ||
labels: ${{ steps.meta-new.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
crash.*.log | ||
|
||
# Exclude all .tfvars files, which are likely to contain sensitive data, such as | ||
# password, private keys, and other secrets. These should not be part of version | ||
# control as they are data points which are potentially sensitive and subject | ||
# to change depending on the environment. | ||
*.tfvars | ||
*.tfvars.json | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Include override files you do wish to add to version control using negated pattern | ||
# !example_override.tf | ||
|
||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan | ||
# example: *tfplan* | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:22.5.1-alpine3.20 | ||
|
||
RUN apk add --update --no-cache bash git curl && apk upgrade | ||
|
||
# Install the Bitbucket Pipes Toolkit | ||
RUN wget --no-verbose -P / https://bitbucket.org/bitbucketpipelines/bitbucket-pipes-toolkit-bash/raw/0.6.0/common.sh | ||
|
||
COPY LICENSE pipe.yml README.md / | ||
|
||
RUN npm install -g conventional-changelog-cli conventional-recommended-bump conventional-changelog-conventionalcommits git-semver-tags | ||
|
||
COPY pipe.sh / | ||
RUN chmod a+x /*.sh | ||
|
||
ENTRYPOINT ["/pipe.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
source "$(dirname "$0")/common.sh" | ||
|
||
|
||
# Required parameters | ||
TF_MODULE_PATH=${TF_MODULE_PATH:?"TF_MODULE_PATH env variable is required"} | ||
|
||
# Default values | ||
DEBUG=${DEBUG:="false"} | ||
TAG_PREFIX=${TAG_PREFIX:="v"} | ||
|
||
COMMITTER_NAME=${GIT_COMMITTER_NAME:="Conventional Commits Release"} | ||
COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL:="[email protected]"} | ||
|
||
# RUN_TFLINT=${RUN_TFLINT:="true"} | ||
# RUN_TRIVY=${RUN_TRIVY:="true"} | ||
# RUN_VALIDATE=${RUN_VALIDATE:="true"} | ||
# RUN_FMT=${RUN_FMT:="true"} | ||
|
||
enable_debug() { | ||
if [[ "${DEBUG}" == "true" ]]; then | ||
info "Enabling debug mode." | ||
set -x | ||
fi | ||
} | ||
enable_debug | ||
|
||
increment_version() { | ||
local version=$1 | ||
local increment=$2 | ||
local major=$(echo $version | cut -d. -f1) | ||
local minor=$(echo $version | cut -d. -f2) | ||
local patch=$(echo $version | cut -d. -f3) | ||
|
||
if [ "$increment" == "major" ]; then | ||
major=$((major + 1)) | ||
minor=0 | ||
patch=0 | ||
elif [ "$increment" == "minor" ]; then | ||
minor=$((minor + 1)) | ||
patch=0 | ||
elif [ "$increment" == "patch" ]; then | ||
patch=$((patch + 1)) | ||
fi | ||
|
||
echo "${major}.${minor}.${patch}" | ||
} | ||
|
||
|
||
info "Running module release for ${TF_MODULE_PATH}" | ||
|
||
LAST_TAG=$(git-semver-tags --tag-prefix "${TAG_PREFIX}" | head -n 1) | ||
GIT_FILTER="${LAST_TAG}..HEAD" | ||
if [[ -z "${LAST_TAG}" ]]; then | ||
info "No tags found - new release starting at 0.0.0" | ||
LAST_VERSION="0.0.0" | ||
GIT_FILTER="" | ||
else | ||
info "Last release: ${LAST_TAG}" | ||
LAST_VERSION=$(echo "${LAST_TAG}" | sed "s/${TAG_PREFIX}//") | ||
fi | ||
|
||
|
||
NUM_COMMITS=$(git log --oneline ${GIT_FILTER} -- ${TF_MODULE_PATH} | wc -l) | ||
info "Number of commits since last release: ${NUM_COMMITS}" | ||
|
||
if [[ "${NUM_COMMITS}" == "0" ]]; then | ||
success "No changes detected, skipping release" | ||
exit 0 | ||
fi | ||
|
||
INCREMENT_TYPE=$(conventional-recommended-bump -p conventionalcommits --commit-path ${TF_MODULE_PATH}) | ||
echo -n "Version Increment: " | ||
conventional-recommended-bump -p conventionalcommits --commit-path ${TF_MODULE_PATH} -v | ||
|
||
NEW_VERSION=$(increment_version ${LAST_VERSION} ${INCREMENT_TYPE}) | ||
info "New version: ${NEW_VERSION}" | ||
|
||
# git tag -a "${TAG_PREFIX}${NEW_VERSION}" -m "Release ${TAG_PREFIX}${NEW_VERSION}" | ||
git tag "${TAG_PREFIX}${NEW_VERSION}" | ||
|
||
info "Generating CHANGELOG.md" | ||
run conventional-changelog -p conventionalcommits -i ${TF_MODULE_PATH}/CHANGELOG.md -s -r 0 -t ${TAG_PREFIX} --commit-path ${TF_MODULE_PATH} -u false | ||
if [[ "${status}" == "0" ]]; then | ||
success "Success!" | ||
else | ||
fail "Error!" | ||
fi | ||
|
||
GIT_AUTHOR_NAME=${COMMITTER_NAME} | ||
GIT_AUTHOR_EMAIL=${COMMITTER_EMAIL} | ||
GIT_COMMITTER_NAME=${COMMITTER_NAME} | ||
GIT_COMMITTER_EMAIL=${COMMITTER_EMAIL} | ||
EMAIL=${COMMITTER_EMAIL} | ||
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL EMAIL | ||
|
||
git add ${TF_MODULE_PATH}/CHANGELOG.md | ||
git commit -m "chore(release): update changelog for ${TF_MODULE_PATH} [skip ci]" | ||
git tag -f -am "Tagging for release ${TAG_PREFIX}${NEW_VERSION}" "${TAG_PREFIX}${NEW_VERSION}" | ||
git push origin "${TAG_PREFIX}${NEW_VERSION}" | ||
|
||
# cd ${TF_MODULE_PATH} | ||
|
||
# if [[ "${RUN_FMT}" == "true" ]]; then | ||
# info "Checking module formatting" | ||
# run terraform init && terraform fmt -check | ||
|
||
# if [[ "${status}" == "0" ]]; then | ||
# success "Success!" | ||
# else | ||
# fail "Error!" | ||
# fi | ||
# fi | ||
|
||
# if [[ "${RUN_VALIDATE}" == "true" ]]; then | ||
# info "Checking module validation" | ||
# run terraform validate | ||
|
||
# if [[ "${status}" == "0" ]]; then | ||
# success "Success!" | ||
# else | ||
# fail "Error!" | ||
# fi | ||
# fi | ||
|
||
|
||
# if [[ "${RUN_TFLINT}" == "true" ]]; then | ||
# info "Checking module linting" | ||
# run tflint | ||
|
||
# if [[ "${status}" == "0" ]]; then | ||
# success "Success!" | ||
# else | ||
# fail "Error!" | ||
# fi | ||
# fi | ||
|
||
# if [[ "${RUN_TRIVY}" == "true" ]]; then | ||
# info "Checking module vulnerabilities" | ||
# run trivy config . | ||
|
||
# if [[ "${status}" == "0" ]]; then | ||
# success "Success!" | ||
# else | ||
# fail "Error!" | ||
# fi | ||
# fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Conventional Commit Release | ||
image: devopsconsultants/conventional-changelog-release:0.1.0 | ||
description: This pipe runs changelog generation and release creation based on conventional commits. | ||
category: Code quality | ||
repository: https://github.com/devops-consultants/conventional-changelog-release | ||
maintainer: | ||
name: DevOps Consultants | ||
tags: | ||
- bitbucket-pipelines | ||
- pipes | ||
- bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": ["config:recommended"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"version": "0.0.1" | ||
} |