From 5d4a0b5c37381d25f7c5180b0df569deac6629ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20MB?= Date: Thu, 28 Nov 2024 22:25:22 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Update=20release=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Justfile | 12 ++++++++++++ release.sh | 56 ------------------------------------------------------ 2 files changed, 12 insertions(+), 56 deletions(-) create mode 100644 Justfile delete mode 100755 release.sh diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..7edb3f6 --- /dev/null +++ b/Justfile @@ -0,0 +1,12 @@ +release bump="patch": + echo "{{bump}}" | grep -E "^(major|minor|patch)$" + poetry version "{{bump}}" + git add pyproject.toml + git commit --message "🔖 New release: `poetry version -s`" + git tag "`poetry version -s`" + +[confirm('Confirm push --tags ?')] +publish: + git log -1 --pretty="%B" | grep '^🔖 New release: ' + git push + git push --tags diff --git a/release.sh b/release.sh deleted file mode 100755 index fee4e41..0000000 --- a/release.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -set -eu -o pipefail - -HELM_CHART="charts/myapp/Chart.yaml" - -if ! [[ "${1:-}" =~ ^(patch|minor|major)$ ]]; then - echo "🚨 Usage $0 patch|minor|major: to bump the corresponding version" - exit 1 -fi - -# create new version with poetry -echo "📦️ Update poetry version" -VERSION=$(poetry version "$1" -s) -export VERSION - -# update charts -if [ -f "$HELM_CHART" ]; then - echo "📦️ Update helm chart version" - yq e '.version = strenv(VERSION)' -i "$HELM_CHART" - yq e '.appVersion = strenv(VERSION)' -i "$HELM_CHART" -fi - -# add updated files to staging -git add pyproject.toml -if [ -f "$HELM_CHART" ]; then - git add "$HELM_CHART" -fi - -git --no-pager diff --staged - -echo "" -echo "" -echo "" - -# ask confirmation before commit -read -p "💡 Commit changes and create tag? [y/n] " -n 1 -r -if [[ $REPLY =~ ^[Yy]$ ]]; then - git commit --message "🔖 New release: $VERSION" - git tag "$VERSION" - - # ask confirmation before push to origin - read -p "💡 Push to origin? [y/n] " -n 1 -r - if [[ $REPLY =~ ^[Yy]$ ]]; then - git push - git push --tags - fi -else - # revert changes - echo "🤯 Reverting changes ..." - git reset HEAD pyproject.toml - git checkout pyproject.toml - if [ -f "$HELM_CHART" ]; then - git reset HEAD "$HELM_CHART" - git checkout "$HELM_CHART" - fi -fi