Skip to content

Commit e59cf81

Browse files
authored
Merge pull request #106 from TechnologyEnhancedLearning/refactor-logging
chore(cicd): release yml
2 parents 5a80a1c + db20c6c commit e59cf81

File tree

2 files changed

+46
-12
lines changed

2 files changed

+46
-12
lines changed

.github/workflows/dev.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ jobs:
153153
npm ls --depth=0 # Debug: List installed packages
154154
155155
#configured with .releaseserc
156-
# qqqq if we are not versioning the repo why arnt we dry running
156+
# Dry run we are not versioning the repo
157157
- name: Run dev semantic version (None Blocking)
158158
id: detect_semantic_version
159159
run: |
@@ -184,14 +184,16 @@ jobs:
184184
DEV_SEMVER_VERSION="$FALLBACK_VERSION"
185185
echo "No relevant changes found - DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION"
186186
echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV
187+
# Check if version bump expected
187188
elif echo "$SEMVER_OUTPUT_RAW" | grep -q 'Dry run: would publish version'; then
188189
# Extract the actual version
189190
DEV_SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Dry run: would publish version \K[^\s]+' || echo "extract-failed")
190191
echo "Version change detected - DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION"
191192
echo "version change required true"
192193
echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV
194+
# Fallback
193195
else
194-
echo "Neither 'no changes' nor 'would publish' found, using fallback"
196+
echo " ⚠️ Neither 'no changes' nor 'would publish' found. (using fallback)."
195197
DEV_SEMVER_VERSION="$FALLBACK_VERSION"
196198
echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION"
197199
echo "DEV_SEMVER_VERSION=$DEV_SEMVER_VERSION" >> $GITHUB_ENV

.github/workflows/release.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,62 @@ jobs:
5656
- name: run semantic release
5757
id: set_semantic_version
5858
run: |
59+
# qqqq
5960
# Set error to not instantly fail so we can check if error is semantic-release classifying no version bump required as an error
60-
set +e
61-
OUTPUT=$(npx semantic-release 2>&1) || STATUS=$?
61+
# set +e
62+
# OUTPUT=$(npx semantic-release 2>&1) || STATUS=$?
63+
# echo "status = $STATUS"
64+
# set -e
65+
# echo "$OUTPUT"
66+
67+
echo "running semantic-release"
68+
SEMVER_OUTPUT_RAW=$(npx semantic-release 2>&1)
69+
STATUS=$?
6270
echo "status = $STATUS"
63-
set -e
64-
echo "$OUTPUT"
71+
echo "$SEMVER_OUTPUT_RAW"
72+
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+
6593
6694
# 0 not exclusively due to no version bump so check output
6795
if [ "${STATUS:-0}" -ne 0 ]; then
68-
if echo "$OUTPUT" | grep -q "No release published"; 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"
6999
# No new version, but we can find the current version
70-
echo "No new version required getting current version from git tags"
71-
SEMVER_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0-version-placeholder") # last git tag
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
72102
echo "semantic-release-version=$SEMVER_VERSION"
73103
SEMVER_CHANGED=false
74104
echo "Changes do not warrant a version change. gh_pages and packages won't be updated."
75-
echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
105+
#echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
76106
echo "semantic-version-change-required=$SEMVER_CHANGED" >> $GITHUB_OUTPUT
77107
exit 0 # treat as success code didnt fail there just was no version increment required
78108
else
109+
echo "exit using status outcome of semver"
79110
exit $STATUS # real error → fail pipeline
80111
fi
81112
else
82-
SEMVER_VERSION=$(echo "$OUTPUT" | grep -oP 'Published release \K[\d.]+')
113+
echo "grep semver version"
114+
SEMVER_VERSION=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Published release \K[\d.]+')
83115
echo "semantic-release-version=$SEMVER_VERSION"
84116
# qqqq VERSION=$(echo "$OUTPUT" | grep "Published release" | awk '{print $NF}') - AI suggestion try if issues
85117
# awk is a text-processing tool that splits each line into fields using whitespace by default.
@@ -204,7 +236,7 @@ jobs:
204236
name: Update the production TELBlazor ShowCase page (on this repo)
205237
needs: [build-telblazor-package-and-publish, generate-semantic-version]
206238
runs-on: ubuntu-latest
207-
if: ${{ needs.generate-semantic-version.outputs.semantic-release-version != '' }} # Only run if there's a version
239+
if: ${{ needs.generate-semantic-version.outputs.semantic-version-change-required == 'true' }} # Only run if there's a version
208240
env:
209241
TELBLAZOR_PACKAGE_VERSION: ${{ needs.generate-semantic-version.outputs.semantic-release-version }}
210242
steps:

0 commit comments

Comments
 (0)