From 6570c18ca504d9d61a850074e2a331163741594c Mon Sep 17 00:00:00 2001 From: ostatni5 <26521377+ostatni5@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:42:03 +0100 Subject: [PATCH 1/3] Add release automation --- release-automation/bump-version.sh | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 release-automation/bump-version.sh diff --git a/release-automation/bump-version.sh b/release-automation/bump-version.sh new file mode 100755 index 0000000..eee0e6d --- /dev/null +++ b/release-automation/bump-version.sh @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +# Usage: ./bump-version.sh +VERSION="$1" +MIX_EXS="mix.exs" +README="README.md" +MARKER_VERSION="# project version - bump-version.sh" + +if [ -z "$VERSION" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Navigate to fishjam_protos directory +cd fishjam_protos + +BRANCH_NAME="release-$VERSION" +git checkout -b "$BRANCH_NAME" + +if [ ! -f "$MIX_EXS" ]; then + echo "Error: $MIX_EXS not found in repo root" + exit 1 +fi + +# Update version in mix.exs (Version line follows MARKER_VERSION) +# - The substitution uses a regex that matches a literal `version: "`, then +# three groups of digits separated by dots (e.g. `1.2.3`), and the closing +# `"`. We capture the prefix and suffix and replace only the numeric part +# with the value of the shell variable `$VERSION`, keeping the surrounding +# text intact. +if grep -q "$MARKER_VERSION" "$MIX_EXS"; then + sed -i.bak -E "/$MARKER_VERSION/{n;s/version: \"[0-9]+\.[0-9]+\.[0-9]+\"/version: \"$VERSION\"/;}" "$MIX_EXS" + rm -f "$MIX_EXS.bak" +else + echo "Error: Marker '$MARKER_VERSION' not found in $MIX_EXS. Please add it above the version line." + exit 1 +fi + +# Confirm replacement +if ! grep -q "version: \"$VERSION\"" "$MIX_EXS"; then + echo "Error: Failed to update version in $MIX_EXS via regex" + exit 1 +fi +echo "Updated $MIX_EXS to $VERSION" + +# Update version in README.md if present +if [ -f "$README" ]; then + sed -i.bak -E "s/:fishjam_protos, \"~> [0-9]+\.[0-9]+\.[0-9]+\"/:fishjam_protos, \"~> $VERSION\"/" "$README" + rm -f "$README.bak" + echo "Updated $README to version $VERSION" +else + echo "⚠️ $README not found, skipping README version update" +fi + +echo "✅ Version bump complete for $VERSION" +echo "BRANCH_NAME:$BRANCH_NAME" From 11f50c1649c21c4dcd0fc401c62589b83e5d93b3 Mon Sep 17 00:00:00 2001 From: ostatni5 <26521377+ostatni5@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:47:57 +0100 Subject: [PATCH 2/3] Add comment in mix to mark project version --- fishjam_protos/mix.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/fishjam_protos/mix.exs b/fishjam_protos/mix.exs index 19da41f..89fc8c2 100644 --- a/fishjam_protos/mix.exs +++ b/fishjam_protos/mix.exs @@ -4,6 +4,7 @@ defmodule FishjamProtos.MixProject do def project do [ app: :fishjam_protos, + # project version - bump-version.sh version: "0.4.0", elixir: "~> 1.17", start_permanent: Mix.env() == :prod, From 48c21428647f2ca332a99aeec9efb577949ca98c Mon Sep 17 00:00:00 2001 From: ostatni5 <26521377+ostatni5@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:21:35 +0100 Subject: [PATCH 3/3] Update version handling in mix.exs and bump-version.sh --- fishjam_protos/mix.exs | 5 +++-- release-automation/bump-version.sh | 21 ++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/fishjam_protos/mix.exs b/fishjam_protos/mix.exs index 89fc8c2..dc036e7 100644 --- a/fishjam_protos/mix.exs +++ b/fishjam_protos/mix.exs @@ -1,11 +1,12 @@ defmodule FishjamProtos.MixProject do use Mix.Project + @release_version "0.4.0" + def project do [ app: :fishjam_protos, - # project version - bump-version.sh - version: "0.4.0", + version: @release_version, elixir: "~> 1.17", start_permanent: Mix.env() == :prod, elixirc_paths: ["lib"], diff --git a/release-automation/bump-version.sh b/release-automation/bump-version.sh index eee0e6d..0cf81ea 100755 --- a/release-automation/bump-version.sh +++ b/release-automation/bump-version.sh @@ -5,7 +5,6 @@ set -e VERSION="$1" MIX_EXS="mix.exs" README="README.md" -MARKER_VERSION="# project version - bump-version.sh" if [ -z "$VERSION" ]; then echo "Usage: $0 " @@ -23,26 +22,22 @@ if [ ! -f "$MIX_EXS" ]; then exit 1 fi -# Update version in mix.exs (Version line follows MARKER_VERSION) -# - The substitution uses a regex that matches a literal `version: "`, then -# three groups of digits separated by dots (e.g. `1.2.3`), and the closing -# `"`. We capture the prefix and suffix and replace only the numeric part -# with the value of the shell variable `$VERSION`, keeping the surrounding -# text intact. -if grep -q "$MARKER_VERSION" "$MIX_EXS"; then - sed -i.bak -E "/$MARKER_VERSION/{n;s/version: \"[0-9]+\.[0-9]+\.[0-9]+\"/version: \"$VERSION\"/;}" "$MIX_EXS" +# Search and replace `@release_version ""` to new version +if grep -q "@release_version" "$MIX_EXS"; then + sed -i.bak -E 's/(@release_version[[:space:]]*")[^"]*/\1'"$VERSION"'/' "$MIX_EXS" rm -f "$MIX_EXS.bak" else - echo "Error: Marker '$MARKER_VERSION' not found in $MIX_EXS. Please add it above the version line." + echo "Error: @release_version line not found in $MIX_EXS" exit 1 fi -# Confirm replacement -if ! grep -q "version: \"$VERSION\"" "$MIX_EXS"; then +# Confirm replacement: accept either a literal version string or the module attribute +if grep -q "@release_version \"$VERSION\"" "$MIX_EXS"; then + echo "Updated $MIX_EXS to $VERSION" +else echo "Error: Failed to update version in $MIX_EXS via regex" exit 1 fi -echo "Updated $MIX_EXS to $VERSION" # Update version in README.md if present if [ -f "$README" ]; then