Skip to content

Commit 00e708e

Browse files
committed
feat: added a release script to and moved openvox env to common hiera
1 parent 102e2ff commit 00e708e

3 files changed

Lines changed: 138 additions & 3 deletions

File tree

bin/release.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Generate comprehensive release notes from git history
5+
# This captures ALL commits since last release, not just chart updates
6+
7+
CHANGELOG_FILE="CHANGELOG.md"
8+
RELEASE_NOTES_FILE=".release-notes.md"
9+
COMMON_HIERA_FILE="modules/enableit/common/data/common.yaml"
10+
OPENVOX_ENVIRONMENT="common::openvox::environment"
11+
# Run this when the helm chart update PR is merged into master
12+
NEW_TAG=$1
13+
14+
# Get the previous tag
15+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
16+
17+
if [ -z "$NEW_TAG" ]; then
18+
echo "$0 need new tag version, current tag is $PREVIOUS_TAG"
19+
exit
20+
fi
21+
22+
if [ -z "$PREVIOUS_TAG" ]; then
23+
echo "No previous tag found, using all commits"
24+
COMMIT_RANGE="HEAD"
25+
else
26+
echo "Generating release notes since $PREVIOUS_TAG..$NEW_TAG"
27+
COMMIT_RANGE="$PREVIOUS_TAG..HEAD"
28+
fi
29+
30+
# Initialize arrays for categorization
31+
declare -a FEATURES
32+
declare -a BUG_FIXES
33+
declare -a CONFIG_CHANGES
34+
declare -a OTHER_CHANGES
35+
36+
# Process commits
37+
while IFS= read -r commit; do
38+
# Get commit message (first line only)
39+
message=$(git log --format=%s -n 1 "$commit")
40+
short_hash=$(git log --format=%h -n 1 "$commit")
41+
42+
# Skip merge commits
43+
if [[ $message =~ ^Merge ]]; then
44+
continue
45+
fi
46+
47+
formatted_message="- $short_hash $message"
48+
49+
# Categorize commits
50+
if [[ $message =~ ^feat ]]; then
51+
FEATURES+=("$formatted_message")
52+
elif [[ $message =~ ^fix ]]; then
53+
BUG_FIXES+=("$formatted_message")
54+
elif [[ $message =~ ^chore ]]; then
55+
CONFIG_CHANGES+=("$formatted_message")
56+
else
57+
OTHER_CHANGES+=("$formatted_message")
58+
fi
59+
done < <(git rev-list "$COMMIT_RANGE")
60+
61+
cat $CHANGELOG_FILE | tail -n +5 > $CHANGELOG_FILE.tmp
62+
63+
# Generate release notes file
64+
{
65+
printf '%s\n' "## LinuxAid Release Version ${NEW_TAG}"
66+
echo ""
67+
68+
if [ ${#FEATURES[@]} -gt 0 ]; then
69+
echo "### Features"
70+
printf '%s\n' "${FEATURES[@]}"
71+
echo ""
72+
fi
73+
74+
if [ ${#BUG_FIXES[@]} -gt 0 ]; then
75+
echo "### Bug Fixes"
76+
printf '%s\n' "${BUG_FIXES[@]}"
77+
echo ""
78+
fi
79+
80+
if [ ${#CONFIG_CHANGES[@]} -gt 0 ]; then
81+
echo "### Configuration Changes"
82+
printf '%s\n' "${CONFIG_CHANGES[@]}"
83+
echo ""
84+
fi
85+
86+
if [ ${#OTHER_CHANGES[@]} -gt 0 ]; then
87+
echo "### Other Changes"
88+
printf '%s\n' "${OTHER_CHANGES[@]}"
89+
echo ""
90+
fi
91+
92+
# If no commits categorized, add a note
93+
total=$((${#FEATURES[@]} + ${#BUG_FIXES[@]} + ${#CONFIG_CHANGES[@]} + ${#OTHER_CHANGES[@]}))
94+
if [ $total -eq 0 ]; then
95+
echo "No changes in this release."
96+
fi
97+
} > "$RELEASE_NOTES_FILE"
98+
99+
{
100+
printf '%s\n' "# Changelog"
101+
echo ""
102+
printf '%s\n' "All releases and the changes included in them (pulled from git commits added since last release) will be detailed in this file."
103+
echo ""
104+
} > "$CHANGELOG_FILE"
105+
106+
107+
# Prepend the new release note in the changelog.md file
108+
cat "$RELEASE_NOTES_FILE" "$CHANGELOG_FILE.tmp" >> "$CHANGELOG_FILE"
109+
110+
echo "Release notes generated: $CHANGELOG_FILE"
111+
rm -fr $CHANGELOG_FILE.tmp
112+
113+
# yq ends up removing the blank lines
114+
#yq eval -i -P ".[\"common::openvox::environment\"] = \"$NEW_TAG\"" "$COMMON_HIERA_FILE"
115+
sed -i "s/$OPENVOX_ENVIRONMENT: \"$PREVIOUS_TAG\"/$OPENVOX_ENVIRONMENT: \"$NEW_TAG\"/g" "$COMMON_HIERA_FILE"
116+
echo "Openvox environment is updated to $NEW_TAG"
117+
118+
exit
119+
if [[ -n "$(git status --porcelain)" ]]; then
120+
git add -A "$CHANGELOG_FILE" "$RELEASE_NOTES_FILE" "$COMMON_HIERA_FILE"
121+
git commit -m "chore(doc): Update changelog"
122+
fi
123+
124+
git tag -a "$NEW_TAG" -m "Linuxaid Release $NEW_TAG"
125+
126+
echo "Pushing changelog changes to Gitea"
127+
git push origin master
128+
129+
echo "Pushing tag to Gitea"
130+
git push origin "$NEW_TAG"
131+
132+
echo "Pushing changelog changes to Github"
133+
git push github master
134+
135+
echo "Pushing tag to Github"
136+
git push github "$NEW_TAG"

modules/enableit/common/data/common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ common::system::services:
312312

313313
# Puppet
314314
common::openvox::version: "8.23.0"
315+
common::openvox::environment: "v1.3.0"
315316
common::openvox::server: enableit.puppet.obmondo.com
316317
common::openvox::package_name: "openvox-agent"
317318
common::openvox::configure_agent: true

modules/enableit/common/manifests/openvox.pp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
Eit_types::Version $version,
1919
Stdlib::Host $server,
2020
String $package_name,
21+
String $environment,
2122
Stdlib::Port $server_port = 443,
2223
Boolean $manage = true,
2324
Eit_types::Noop_Value $noop_value = undef,
2425
Stdlib::Absolutepath $config_file = $facts['puppet_config'],
2526
Boolean $run_agent_as_noop = true,
2627
Optional[Hash] $extra_main_settings = undef,
27-
28-
# TODO: lets control via enc script
29-
String $environment = 'v1.3.0',
3028
) {
3129
if $manage {
3230
contain profile::openvox

0 commit comments

Comments
 (0)