@@ -56,76 +56,72 @@ jobs:
5656 - name : run semantic release
5757 id : set_semantic_version
5858 run : |
59- # qqqq
60- # Set error to not instantly fail so we can check if error is semantic-release classifying no version bump required as an error
61- # set +e
62- # OUTPUT=$(npx semantic-release 2>&1) || STATUS=$?
63- # echo "status = $STATUS"
64- # set -e
65- # echo "$OUTPUT"
6659
6760 echo "running semantic-release"
6861 SEMVER_OUTPUT_RAW=$(npx semantic-release 2>&1)
6962 STATUS=$?
7063 echo "status = $STATUS"
7164 echo "$SEMVER_OUTPUT_RAW"
7265
73- # # Check for no changes and set SEMVER_VERSION accordingly
74- # if echo "$SEMVER_OUTPUT_RAW" | grep -q 'There are no relevant changes'; then
75- # DEV_SEMVER_VERSION="$FALLBACK_VERSION"
76- # echo "No relevant changes found - DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION"
77- # echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV
78- # # Check if version bump expected
79- # elif echo "$SEMVER_OUTPUT_RAW" | grep -q 'Dry run: would publish version'; then
80- # # Extract the actual version
81- # DEV_SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Dry run: would publish version \K[^\s]+' || echo "extract-failed")
82- # echo "Version change detected - DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION"
83- # echo "version change required true"
84- # echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV
85- # # Fallback
86- # else
87- # echo " ⚠️ Neither 'no changes' nor 'would publish' found. (using fallback)."
88- # DEV_SEMVER_VERSION="$FALLBACK_VERSION"
89- # echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION"
90- # echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV
91- # fi
92-
93-
94- # 0 not exclusively due to no version bump so check output
95- if [ "${STATUS:-0}" -ne 0 ]; then
96- echo "Status code is not 0"
97- if echo "$SEMVER_OUTPUT_RAW" | grep -q "No release published"; then
98- echo "no version change detected"
99- # No new version, but we can find the current version
100- #echo "No new version required getting current version from git tags"
101- #SEMVER_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0-version-placeholder") # last git tag
102- echo "semantic-release-version=$SEMVER_VERSION"
103- SEMVER_CHANGED=false
104- echo "Changes do not warrant a version change. gh_pages and packages won't be updated."
105- #echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
106- echo "semantic-version-change-required=$SEMVER_CHANGED" >> $GITHUB_OUTPUT
107- exit 0 # treat as success code didnt fail there just was no version increment required
108- else
109- echo "exit using status outcome of semver"
110- exit $STATUS # real error → fail pipeline
111- fi
112- else
113- echo "grep semver version"
66+ # Check for no changes and set SEMVER_VERSION accordingly
67+ if echo "$SEMVER_OUTPUT_RAW" | grep -q 'There are no relevant changes'; then
68+ echo "No relevant changes found"
69+ SEMVER_CHANGED=false
70+ echo "Changes do not warrant a version change. gh_pages and packages won't be updated."
71+ echo "semantic-version-change-required=$SEMVER_CHANGED" >> $GITHUB_OUTPUT
72+ echo "Changes do not warrant a version change. gh_pages and packages won't be updated."
73+ # Check if version bump expected
74+ elif echo "$SEMVER_OUTPUT_RAW" | grep -q 'Published release'; then
75+ # Extract the actual version, if it fails here we want to know
11476 SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Published release \K[\d.]+')
115- echo "semantic-release-version=$SEMVER_VERSION"
116- # qqqq VERSION=$(echo "$OUTPUT" | grep "Published release" | awk '{print $NF}') - AI suggestion try if issues
117- # awk is a text-processing tool that splits each line into fields using whitespace by default.
118- # $NF is a special variable in awk that means “the last field” of the current line.
119- # print $NF prints just that last field.
120- SEMVER_CHANGED=true
121- echo "semantic-version-change-required=$SEMVER_CHANGED"
77+ echo "Version change detected - SEMVER_VERSION=$SEMVER_VERSION"
12278 echo "version change required true"
79+ SEMVER_CHANGED=true
12380 echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
12481 echo "semantic-version-change-required=$SEMVER_CHANGED" >> $GITHUB_OUTPUT
125- # Just because weve been handling errors
126- exit 0
82+ else
83+ echo "⚠️ Semver-release not successfully parsed ⚠️"
84+ echo "Output did not match expected patterns"
85+ echo "Raw output was: $SEMVER_OUTPUT_RAW"
86+ exit 1
12787 fi
12888
89+
90+ # 0 not exclusively due to no version bump so check output
91+ # if [ "${STATUS:-0}" -ne 0 ]; then
92+ # echo "Status code is not 0"
93+ # if echo "$SEMVER_OUTPUT_RAW" | grep -q "No release published"; then
94+ # echo "no version change detected"
95+ # # No new version, but we can find the current version
96+ # #echo "No new version required getting current version from git tags"
97+ # #SEMVER_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0-version-placeholder") # last git tag
98+ # echo "semantic-release-version=$SEMVER_VERSION"
99+ # SEMVER_CHANGED=false
100+ # echo "Changes do not warrant a version change. gh_pages and packages won't be updated."
101+ # #echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
102+ # echo "semantic-version-change-required=$SEMVER_CHANGED" >> $GITHUB_OUTPUT
103+ # exit 0 # treat as success code didnt fail there just was no version increment required
104+ # else
105+ # echo "exit using status outcome of semver"
106+ # exit $STATUS # real error → fail pipeline
107+ # fi
108+ # else
109+ # echo "grep semver version"
110+ # SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Published release \K[\d.]+')
111+ # echo "semantic-release-version=$SEMVER_VERSION"
112+ # # qqqq VERSION=$(echo "$OUTPUT" | grep "Published release" | awk '{print $NF}') - AI suggestion try if issues
113+ # # awk is a text-processing tool that splits each line into fields using whitespace by default.
114+ # # $NF is a special variable in awk that means “the last field” of the current line.
115+ # # print $NF prints just that last field.
116+ # SEMVER_CHANGED=true
117+ # echo "semantic-version-change-required=$SEMVER_CHANGED"
118+ # echo "version change required true"
119+ # echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
120+ # echo "semantic-version-change-required=$SEMVER_CHANGED" >> $GITHUB_OUTPUT
121+ # # Just because weve been handling errors
122+ # exit 0
123+ # fi
124+
129125 # configured with .releaseserc
130126 # qqqq- name: Run semantic release
131127 # id: set_semantic_version
0 commit comments