@@ -16,94 +16,66 @@ jobs:
1616 - name : Checkout repository
1717 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1818
19- - name : Calculate current release month and versions
20- id : release_info
19+ - name : Collect supported versions from hugo.toml
20+ id : versions
2121 run : |
22- # Get current date
23- CURRENT_MONTH=$(date +%m)
24- CURRENT_YEAR=$(date +%Y)
25-
26- # Get current month name
27- MONTH_NAME=$(date +%B)
28-
29- # Read current version from VERSION file
30- CURRENT_VERSION=$(cat VERSION | tr -d 'v' | tr -d '\n')
31-
32- # Parse version (assuming format X.Y.Z)
33- MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
34- MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
35- PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
36-
37- # Calculate N version (current minor version)
38- N_VERSION="v${MAJOR}.${MINOR}"
39-
40- # Calculate N-1 version (previous minor version)
41- if [ $MINOR -gt 0 ]; then
42- N_MINUS_1_MINOR=$((MINOR - 1))
43- N_MINUS_1_VERSION="v${MAJOR}.${N_MINUS_1_MINOR}"
44- else
45- # If minor is 0, go to previous major version
46- if [ $MAJOR -gt 0 ]; then
47- N_MINUS_1_MAJOR=$((MAJOR - 1))
48- N_MINUS_1_VERSION="v${N_MINUS_1_MAJOR}.0"
49- else
50- N_MINUS_1_VERSION="v0.0"
22+ TODAY=$(date +%Y-%m-%d)
23+
24+ # Extract version/eol pairs from hugo.toml, skipping "latest"
25+ ACTIVE_VERSIONS=()
26+ VERSION=""
27+ VERSION_RE='version[[:space:]]*=[[:space:]]*"([^"]+)"'
28+ EOL_RE='eol[[:space:]]*=[[:space:]]*"([^"]+)"'
29+ while IFS= read -r line; do
30+ if [[ "$line" =~ $VERSION_RE ]]; then
31+ VERSION="${BASH_REMATCH[1]}"
5132 fi
52- fi
33+ if [[ "$line" =~ $EOL_RE ]]; then
34+ EOL="${BASH_REMATCH[1]}"
35+ if [[ "$VERSION" != "latest" && ! "$EOL" < "$TODAY" ]]; then
36+ ACTIVE_VERSIONS+=("$VERSION")
37+ fi
38+ VERSION=""
39+ fi
40+ done < site/hugo.toml
41+
42+ printf '%s\n' "Supported versions (EOL on or after ${TODAY}):" "${ACTIVE_VERSIONS[@]}"
5343
54- echo "month=${CURRENT_MONTH}" >> $GITHUB_OUTPUT
55- echo "year=${CURRENT_YEAR }" >> $GITHUB_OUTPUT
56- echo "month_name =${MONTH_NAME }" >> $GITHUB_OUTPUT
57- echo "n_version=${N_VERSION} " >> $GITHUB_OUTPUT
58- echo "n_minus_1_version=${N_MINUS_1_VERSION} " >> $GITHUB_OUTPUT
44+ # Export as JSON array for the matrix
45+ JSON=$(printf '%s\n' "${ACTIVE_VERSIONS[@] }" | jq -R . | jq -sc .)
46+ echo "matrix =${JSON }" >> $GITHUB_OUTPUT
47+ echo "month_name=$(date +%B) " >> $GITHUB_OUTPUT
48+ echo "year=$(date +%Y) " >> $GITHUB_OUTPUT
5949
6050 - name : Read issue template
6151 id : template
6252 run : |
63- # Read the template file and skip the YAML front matter
6453 TEMPLATE_CONTENT=$(awk '/^---$/,/^---$/{if (!/^---$/) next} /^---$/{p++; next} p==2' .github/ISSUE_TEMPLATE/release.md)
6554
66- # Save to output using multiline format
6755 {
6856 echo 'content<<EOF'
6957 echo "$TEMPLATE_CONTENT"
7058 echo 'EOF'
7159 } >> $GITHUB_OUTPUT
7260
73- - name : Create release issue for N version
74- env :
75- GH_TOKEN : ${{ github.token }}
76- run : |
77- MONTH_NAME="${{ steps.release_info.outputs.month_name }}"
78- YEAR="${{ steps.release_info.outputs.year }}"
79- N_VERSION="${{ steps.release_info.outputs.n_version }}"
80- TEMPLATE_CONTENT="${{ steps.template.outputs.content }}"
81-
82- gh issue create \
83- --title "Patch Release ${N_VERSION}.x for ${MONTH_NAME} ${YEAR}" \
84- --label "release-process" \
85- --body "## Patch Release Checklist for ${N_VERSION}.x (${MONTH_NAME} ${YEAR})
86-
87- ${TEMPLATE_CONTENT}
88-
89- ---
90- *This issue was automatically created by the monthly release workflow.*"
91-
92- - name : Create release issue for N-1 version
61+ - name : Create release issues for supported versions
9362 env :
9463 GH_TOKEN : ${{ github.token }}
9564 run : |
96- MONTH_NAME="${{ steps.release_info.outputs.month_name }}"
97- YEAR="${{ steps.release_info.outputs.year }}"
98- N_MINUS_1_VERSION="${{ steps.release_info.outputs.n_minus_1_version }}"
65+ MONTH_NAME="${{ steps.versions.outputs.month_name }}"
66+ YEAR="${{ steps.versions.outputs.year }}"
9967 TEMPLATE_CONTENT="${{ steps.template.outputs.content }}"
68+ VERSIONS='${{ steps.versions.outputs.matrix }}'
10069
101- gh issue create \
102- --title "Patch Release ${N_MINUS_1_VERSION}.x for ${MONTH_NAME} ${YEAR}" \
103- --label "release-process" \
104- --body "## Patch Release Checklist for ${N_MINUS_1_VERSION}.x (${MONTH_NAME} ${YEAR})
70+ for VERSION in $(echo "$VERSIONS" | jq -r '.[]'); do
71+ echo "Creating release issue for ${VERSION}.x ..."
72+ gh issue create \
73+ --title "Patch Release ${VERSION}.x for ${MONTH_NAME} ${YEAR}" \
74+ --label "release-process" \
75+ --body "## Patch Release Checklist for ${VERSION}.x (${MONTH_NAME} ${YEAR})
10576
10677 ${TEMPLATE_CONTENT}
10778
10879 ---
10980 *This issue was automatically created by the monthly release workflow.*"
81+ done
0 commit comments