|
53 | 53 |
|
54 | 54 |
|
55 | 55 |
|
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +####### qqqq |
| 60 | + # 0 not exclusively due to no version bump so check output |
| 61 | + # dry release seems not to error 1 qqqq! |
| 62 | + # if [ "${STATUS:-0}" -ne 0 ]; then |
| 63 | + # echo "in if status 0" |
| 64 | + # if echo "$SEMVER_OUTPUT_RAW" | grep -q "There are no relevant changes"; then |
| 65 | + # echo "in if no release published" |
| 66 | + # # No new version, but we can find the current version |
| 67 | + # echo "No new version required getting current version from git tags" |
| 68 | + # DEV_SEMVER_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0-version-not-found") # last git tag so if multiple bumps in other branches making package version there will be some discrepancy but the purpose is distinguishing them for dev purposes. |
| 69 | + # echo "DEV_SEMVER_VERSION = $DEV_SEMVER_VERSION" |
| 70 | + # exit 0 # treat as success code didnt fail there just was no version increment required |
| 71 | + # else |
| 72 | + # echo "in else no release published" |
| 73 | + # exit $STATUS # real error → fail pipeline |
| 74 | + # fi |
| 75 | + # else |
| 76 | + # # Get version include prerelease tag |
| 77 | + # # Dry run returns different text DEV_SEMVER_VERSION=$(echo "$OUTPUT" | grep -oP 'Published release \K[^\s]+') |
| 78 | + # echo "in else so status was zero for error" |
| 79 | + # DEV_SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Dry run: would publish version \K[^\s]+') |
| 80 | + # echo "DEV_SEMVER_VERSION = $DEV_SEMVER_VERSION" |
| 81 | + # echo "version change required true" |
| 82 | + # # Just because weve been handling errors |
| 83 | + # exit 0 |
| 84 | + # fi |
| 85 | + |
| 86 | + |
| 87 | + # qqqq - name: Run semantic version (None Blocking) |
| 88 | + # run: | |
| 89 | + # # If no version is required we can get an error so here we handle it |
| 90 | + # set +e |
| 91 | + |
| 92 | + # SEMVER_OUTPUT_RAW=$(npx semantic-release) |
| 93 | + # echo "Raw SEMVER_OUTPUT_RAW=$SEMVER_OUTPUT_RAW" |
| 94 | + |
| 95 | + # SEMVER_OUTPUT=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Published release \K[^\s]+') |
| 96 | + |
| 97 | + # # In development, we always package and update the website—even if there’s no version change. |
| 98 | + # # This ensures the CI process runs consistently and the latest code is deployed. |
| 99 | + # # It's especially useful when squashing commits, as it guarantees the package is still rebuilt and published. |
| 100 | + # echo "Packaging and updating the website in development, even without version changes, to ensure consistent CI behavior and updated packages after squashed commits." |
| 101 | + |
| 102 | + # STATUS=$? |
| 103 | + # if [ -z "$SEMVER_OUTPUT" ]; then |
| 104 | + # SEMVER_OUTPUT=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Found git tag v\K[^\s]+') |
| 105 | + # # Note: If Semver falls back to using a Git tag, it will pick the most recent one. |
| 106 | + # # This tag may not belong to the current branch, so the result isn't guaranteed to reflect the latest changes on this branch. |
| 107 | + # echo "Semver fallback: using latest Git tag, which may not be from the current branch." |
| 108 | + # fi |
| 109 | + |
| 110 | + # if [ -z "$SEMVER_OUTPUT" ]; then |
| 111 | + # SEMVER_OUTPUT="0.0.0" |
| 112 | + # echo "No semantic version or tag, defaulting to 0.0.0 $SEMVER_OUTPUT" |
| 113 | + # fi |
| 114 | + |
| 115 | + # # Export the result to the environment |
| 116 | + # echo "SEMVER_OUTPUT=$SEMVER_OUTPUT" >> $GITHUB_ENV |
| 117 | + # set -e |
| 118 | +################ |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
56 | 123 | # Now we've done due diligence |
57 | 124 | # The checks have been allowed to run if the workflow fails so if there a multiple fails we know. |
58 | 125 | # We do not proceed from the point if there is a fail. |
@@ -88,76 +155,53 @@ jobs: |
88 | 155 | #configured with .releaseserc |
89 | 156 | # qqqq if we are not versioning the repo why arnt we dry running |
90 | 157 | - name: Run dev semantic version (None Blocking) |
| 158 | + id: detect_semantic_version |
91 | 159 | run: | |
92 | | - # Set pipefail so we can check if pipefail is semantic-release classifying no version bump required as an error |
93 | | - # qqqq set -o pipefail |
94 | | - # qqqq now were dry running do we need to error handle? |
95 | | - set +e |
| 160 | +
|
| 161 | + #set +e |
96 | 162 | # Due to dry-run need to catch error differently : SEMVER_OUTPUT_RAW=$(npx semantic-release --dry-run 2>&1) || STATUS=$? |
| 163 | + echo "running semantic-release" |
97 | 164 | SEMVER_OUTPUT_RAW=$(npx semantic-release --dry-run 2>&1) |
98 | 165 | STATUS=$? |
| 166 | + echo "status = $STATUS" |
| 167 | + #set -e |
| 168 | + echo "$SEMVER_OUTPUT_RAW" |
| 169 | + |
| 170 | + # Get fallback version by grabbing the git tag dropping the first character, the "v", or use hardcoded fallback |
| 171 | + FALLBACK_VERSION=$(git describe --tags --abbrev=0 2>/dev/null | cut -c2- || echo "0.0.0-version-not-found") |
| 172 | + echo "FALLBACK_VERSION=$FALLBACK_VERSION" |
| 173 | + |
| 174 | + set +e |
| 175 | + # Check what's in the output |
| 176 | + GREP_NO_CHANGES=$(echo "$SEMVER_OUTPUT_RAW" | grep -q 'There are no relevant changes' && echo "true" || echo "false") |
| 177 | + GREP_WOULD_PUBLISH=$(echo "$SEMVER_OUTPUT_RAW" | grep -q 'Dry run: would publish version' && echo "true" || echo "false") |
| 178 | + echo "GREP_NO_CHANGES=$GREP_NO_CHANGES" |
| 179 | + echo "GREP_WOULD_PUBLISH=$GREP_WOULD_PUBLISH" |
99 | 180 | set -e |
100 | | - echo "$SEMVER_OUTPUT_RAW" |
101 | | -
|
102 | | - # 0 not exclusively due to no version bump so check output |
103 | | - if [ "${STATUS:-0}" -ne 0 ]; then |
104 | | - if echo "$SEMVER_OUTPUT_RAW" | grep -q "No release published"; then |
105 | | - # No new version, but we can find the current version |
106 | | - echo "No new version required getting current version from git tags" |
107 | | - DEV_SEMVER_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0-version-not-found") # last git tag so if multiple bumps in other branches making package version there will be some discrepancy but the purpose is distinguishing them for dev purposes. |
108 | | - echo "DEV_SEMVER_VERSION = $DEV_SEMVER_VERSION" |
109 | | - exit 0 # treat as success code didnt fail there just was no version increment required |
110 | | - else |
111 | | - exit $STATUS # real error → fail pipeline |
112 | | - fi |
113 | | - else |
114 | | - # Get version include prerelease tag |
115 | | - # Dry run returns different text DEV_SEMVER_VERSION=$(echo "$OUTPUT" | grep -oP 'Published release \K[^\s]+') |
116 | | - DEV_SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Dry run: would publish version \K[^\s]+') |
117 | | - echo "DEV_SEMVER_VERSION = $DEV_SEMVER_VERSION" |
| 181 | + |
| 182 | + # Check for no changes and set DEV_SEMVER_VERSION accordingly |
| 183 | + if echo "$SEMVER_OUTPUT_RAW" | grep -q 'There are no relevant changes'; then |
| 184 | + DEV_SEMVER_VERSION="$FALLBACK_VERSION" |
| 185 | + echo "No relevant changes found - DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" |
| 186 | + echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV |
| 187 | + elif echo "$SEMVER_OUTPUT_RAW" | grep -q 'Dry run: would publish version'; then |
| 188 | + # Extract the actual version |
| 189 | + DEV_SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Dry run: would publish version \K[^\s]+' || echo "extract-failed") |
| 190 | + echo "Version change detected - DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" |
118 | 191 | echo "version change required true" |
119 | | - # Just because weve been handling errors |
120 | | - exit 0 |
| 192 | + echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV |
| 193 | + else |
| 194 | + echo "Neither 'no changes' nor 'would publish' found, using fallback" |
| 195 | + DEV_SEMVER_VERSION="$FALLBACK_VERSION" |
| 196 | + echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" |
| 197 | + echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV |
121 | 198 | fi |
122 | | - |
123 | | - |
124 | | - # qqqq - name: Run semantic version (None Blocking) |
125 | | - # run: | |
126 | | - # # If no version is required we can get an error so here we handle it |
127 | | - # set +e |
128 | | - |
129 | | - # SEMVER_OUTPUT_RAW=$(npx semantic-release) |
130 | | - # echo "Raw SEMVER_OUTPUT_RAW=$SEMVER_OUTPUT_RAW" |
131 | | - |
132 | | - # SEMVER_OUTPUT=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Published release \K[^\s]+') |
133 | | - |
134 | | - # # In development, we always package and update the website—even if there’s no version change. |
135 | | - # # This ensures the CI process runs consistently and the latest code is deployed. |
136 | | - # # It's especially useful when squashing commits, as it guarantees the package is still rebuilt and published. |
137 | | - # echo "Packaging and updating the website in development, even without version changes, to ensure consistent CI behavior and updated packages after squashed commits." |
138 | | - |
139 | | - # STATUS=$? |
140 | | - # if [ -z "$SEMVER_OUTPUT" ]; then |
141 | | - # SEMVER_OUTPUT=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Found git tag v\K[^\s]+') |
142 | | - # # Note: If Semver falls back to using a Git tag, it will pick the most recent one. |
143 | | - # # This tag may not belong to the current branch, so the result isn't guaranteed to reflect the latest changes on this branch. |
144 | | - # echo "Semver fallback: using latest Git tag, which may not be from the current branch." |
145 | | - # fi |
146 | | - |
147 | | - # if [ -z "$SEMVER_OUTPUT" ]; then |
148 | | - # SEMVER_OUTPUT="0.0.0" |
149 | | - # echo "No semantic version or tag, defaulting to 0.0.0 $SEMVER_OUTPUT" |
150 | | - # fi |
151 | | - |
152 | | - # # Export the result to the environment |
153 | | - # echo "SEMVER_OUTPUT=$SEMVER_OUTPUT" >> $GITHUB_ENV |
154 | | - # set -e |
155 | | - |
156 | 199 |
|
157 | 200 | - name: Rename Semver Version with branch date time dev |
158 | 201 | id: set_dev_semantic_version |
159 | 202 | run: | |
160 | | - echo "Dev Semantic Release Output $DEV_SEMVER_VERSION" |
| 203 | + # DEV_SEMVER_VERSION="${{ steps.detect_semantic_version.outputs.DEV_SEMVER_VERSION }}" |
| 204 | + echo "Dev Semantic Version Output = $DEV_SEMVER_VERSION" |
161 | 205 |
|
162 | 206 | # In development, we always package and update the website—even if there’s no version change. |
163 | 207 | # This ensures the CI process runs consistently and the latest code is deployed. |
|
0 commit comments