Skip to content

Commit 27e7e4f

Browse files
committed
Allow regualar commits
1 parent 2cabacf commit 27e7e4f

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

release.sh

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,40 @@ TESTED_UP_TO=$(echo "$JSON_DATA" | jq -r 'to_entries[] | select(.value == "lates
1111
# Read the TESTED_UP_TO value from config.json
1212
CONFIG_TESTED_UP_TO=$(jq -r '.TESTED_UP_TO' ./config.json)
1313

14-
# Compare the two values and exit if they are the same
15-
if [[ "$TESTED_UP_TO" == "$CONFIG_TESTED_UP_TO" ]]; then
14+
# Fetch the current STABLE_TAG value from config.json
15+
PREVIOUS_STABLE_TAG=$(jq -r '.STABLE_TAG' config.json)
16+
17+
# Get the latest git tag
18+
LATEST_TAG=$(git describe --tags --abbrev=0 || echo "")
19+
20+
# Check if there are commits since the latest tag
21+
if [ -n "$LATEST_TAG" ]; then
22+
COMMITS_SINCE_TAG=$(git log "$LATEST_TAG"..HEAD --pretty=format:"* %s")
23+
else
24+
COMMITS_SINCE_TAG=$(git log --pretty=format:"* %s")
25+
fi
26+
27+
# Determine if there are code changes since the last tag
28+
CODE_CHANGED=false
29+
if [[ -n "$COMMITS_SINCE_TAG" ]]; then
30+
CODE_CHANGED=true
31+
fi
32+
33+
# Determine if the WordPress version has changed
34+
WP_VERSION_CHANGED=false
35+
if [[ "$TESTED_UP_TO" != "$CONFIG_TESTED_UP_TO" ]]; then
36+
WP_VERSION_CHANGED=true
37+
fi
38+
39+
# Exit early if no code changes and WordPress version hasn't changed
40+
if [[ "$CODE_CHANGED" == false && "$WP_VERSION_CHANGED" == false ]]; then
1641
echo "### :no_good_woman: Didn't update versions :no_good:" >> $GITHUB_STEP_SUMMARY
1742
echo "" >> $GITHUB_STEP_SUMMARY
18-
echo "Stopped because WordPress version ($TESTED_UP_TO) has not changed." >> $GITHUB_STEP_SUMMARY
19-
echo "TESTED_UP_TO has not changed. Exiting..."
43+
echo "Stopped because there are no changes since the last release." >> $GITHUB_STEP_SUMMARY
44+
echo "No changes detected. Exiting..."
2045
exit 0
2146
fi
2247

23-
# Fetch the current STABLE_TAG value from config.json
24-
PREVIOUS_STABLE_TAG=$(jq -r '.STABLE_TAG' config.json)
25-
2648
# Increment the STABLE_TAG value
2749
STABLE_TAG=$(echo "$PREVIOUS_STABLE_TAG" | awk -F. '{$NF+=1} 1' OFS=.)
2850

@@ -41,20 +63,24 @@ sed -i -e "s/Tested up to: [0-9.]*$/Tested up to: $TESTED_UP_TO/" \
4163
# Get the current date in the specified format
4264
DATE=$(date +"%Y-%m-%d")
4365

44-
# Generate the new changelog item
45-
NEW_ENTRY=$(cat <<EOL
46-
= $STABLE_TAG =
47-
* $DATE
48-
* Upgraded to WordPress $TESTED_UP_TO
49-
EOL
50-
)
66+
# Prepare the changelog entry
67+
CHANGELOG_ENTRY="= $STABLE_TAG =\n* $DATE"
68+
69+
# Add WordPress version update to changelog if it has changed
70+
if [[ "$WP_VERSION_CHANGED" == true ]]; then
71+
CHANGELOG_ENTRY="$CHANGELOG_ENTRY\n* Upgraded to WordPress $TESTED_UP_TO"
72+
fi
73+
74+
# Add commit messages to changelog if there are code changes
75+
if [[ "$CODE_CHANGED" == true ]]; then
76+
CHANGELOG_ENTRY="$CHANGELOG_ENTRY\n* Changes:\n$COMMITS_SINCE_TAG"
77+
fi
5178

52-
# Use sed to insert the new changelog item below the line "== Changelog =="
53-
sed -i -e "/== Changelog ==/a\\
79+
# Insert the new changelog entry below the line "== Changelog =="
80+
# Use sed to insert the changelog entry
81+
sed -i "/== Changelog ==/a \\
5482
\\
55-
= $STABLE_TAG =\\
56-
* $DATE\\
57-
* Upgraded to WordPress $TESTED_UP_TO" ./readme.txt
83+
$CHANGELOG_ENTRY" ./readme.txt
5884

5985
# Update the config.json file
6086
echo "{

0 commit comments

Comments
 (0)