PluginProbe
Simple Analytics / 1.25
Simple Analytics v1.25
1.109 1.108 1.107 1.106 1.73 1.74 1.75 1.76 1.77 1.78 1.79 1.8 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.9 1.90 1.91 All 98 releases
simpleanalytics / release.sh

release.sh in Simple Analytics 1.25, at release.sh

69 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 #!/bin/bash
2 set -euo pipefail
3 IFS=$'\n\t'
4
5 # Fetch the JSON data from the specified URL
6 JSON_DATA=$(curl -s https://api.wordpress.org/core/stable-check/1.0/)
7
8 # Use jq to parse the JSON data and extract the version marked as "latest"
9 TESTED_UP_TO=$(echo "$JSON_DATA" | jq -r 'to_entries[] | select(.value == "latest") | .key')
10
11 # Read the TESTED_UP_TO value from config.json
12 CONFIG_TESTED_UP_TO=$(jq -r '.TESTED_UP_TO' ./config.json)
13
14 # Compare the two values and exit if they are the same
15 if [[ "$TESTED_UP_TO" == "$CONFIG_TESTED_UP_TO" ]]; then
16 echo "### :no_good_woman: Didn't update versions :no_good:" >> $GITHUB_STEP_SUMMARY
17 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..."
20 exit 0
21 fi
22
23 # Fetch the current STABLE_TAG value from config.json
24 PREVIOUS_STABLE_TAG=$(jq -r '.STABLE_TAG' config.json)
25
26 # Increment the STABLE_TAG value
27 STABLE_TAG=$(echo "$PREVIOUS_STABLE_TAG" | awk -F. '{$NF+=1} 1' OFS=.)
28
29 echo "### :rocket: Updated versions :rocket:" >> $GITHUB_STEP_SUMMARY
30 echo "" >> $GITHUB_STEP_SUMMARY # this is a blank line
31 echo "- New stable tag: $STABLE_TAG (was $PREVIOUS_STABLE_TAG)" >> $GITHUB_STEP_SUMMARY
32 echo "- New WordPress version: $TESTED_UP_TO (was $CONFIG_TESTED_UP_TO)" >> $GITHUB_STEP_SUMMARY
33
34 # Use sed to replace the version lines in some files
35 sed -i -e "s/Tested up to: [0-9.]*$/Tested up to: $TESTED_UP_TO/" \
36 -e "s/Stable tag: [0-9.]*$/Stable tag: $STABLE_TAG/" ./readme.txt
37
38 sed -i -e "s/Tested up to: [0-9.]*$/Tested up to: $TESTED_UP_TO/" \
39 -e "s/Version: [0-9.]*$/Version: $STABLE_TAG/" ./simple-analytics.php
40
41 # Get the current date in the specified format
42 DATE=$(date +"%Y-%m-%d")
43
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 )
51
52 # Use sed to insert the new changelog item below the line "== Changelog =="
53 sed -i -e "/== Changelog ==/a\\
54 \\
55 = $STABLE_TAG =\\
56 * $DATE\\
57 * Upgraded to WordPress $TESTED_UP_TO" ./readme.txt
58
59 # Update the config.json file
60 echo "{
61 \"TESTED_UP_TO\": \"$TESTED_UP_TO\",
62 \"STABLE_TAG\": \"$STABLE_TAG\"
63 }" > config.json
64
65 # Output the new version information for use in subsequent GitHub Actions steps
66 echo "tested-up-to=$TESTED_UP_TO" >> $GITHUB_OUTPUT
67 echo "stable-tag=$STABLE_TAG" >> $GITHUB_OUTPUT
68 echo "has-changed=true" >> $GITHUB_OUTPUT
69