Skip to content

Commit 3823812

Browse files
committed
Enhance release logic to support manual triggers and increment WSL version accordingly
1 parent 187e865 commit 3823812

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

.github/workflows/build-wsl-image.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,34 @@ jobs:
6060
run: |
6161
NEED_RELEASE="false"
6262
NEW_WSL_VERSION="1.0"
63-
63+
64+
# Always build when manually triggered
65+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
66+
NEED_RELEASE="true"
67+
echo "Manual trigger detected - forcing release"
6468
# Check if containerlab version is different
65-
if [[ "${{ steps.current_release.outputs.CURRENT_CONTAINERLAB_VERSION }}" != "${{ steps.containerlab.outputs.CONTAINERLAB_VERSION }}" ]]; then
69+
elif [[ "${{ steps.current_release.outputs.CURRENT_CONTAINERLAB_VERSION }}" != "${{ steps.containerlab.outputs.CONTAINERLAB_VERSION }}" ]]; then
6670
NEED_RELEASE="true"
6771
elif [[ "${{ steps.current_release.outputs.CURRENT_CONTAINERLAB_VERSION }}" == "none" ]]; then
6872
# No previous releases
6973
NEED_RELEASE="true"
7074
fi
7175
76+
# For manual triggers with no version change, use current containerlab version with bumped WSL version
77+
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ steps.current_release.outputs.CURRENT_CONTAINERLAB_VERSION }}" == "${{ steps.containerlab.outputs.CONTAINERLAB_VERSION }}" ]]; then
78+
# Increment the WSL version
79+
if [[ "${{ steps.current_release.outputs.CURRENT_WSL_VERSION }}" != "none" ]]; then
80+
CURRENT_WSL_VERSION="${{ steps.current_release.outputs.CURRENT_WSL_VERSION }}"
81+
# Extract major and minor version parts
82+
WSL_MAJOR=$(echo $CURRENT_WSL_VERSION | cut -d'.' -f1)
83+
WSL_MINOR=$(echo $CURRENT_WSL_VERSION | cut -d'.' -f2)
84+
# Increment minor version
85+
NEW_WSL_MINOR=$((WSL_MINOR + 1))
86+
NEW_WSL_VERSION="$WSL_MAJOR.$NEW_WSL_MINOR"
87+
fi
88+
echo "Using existing containerlab version with incremented WSL version: $NEW_WSL_VERSION"
89+
fi
90+
7291
# Set output variables
7392
echo "NEED_RELEASE=$NEED_RELEASE" >> $GITHUB_OUTPUT
7493
echo "NEW_TAG=${{ steps.containerlab.outputs.CONTAINERLAB_VERSION }}-$NEW_WSL_VERSION" >> $GITHUB_OUTPUT
@@ -93,13 +112,16 @@ jobs:
93112
with:
94113
tag_name: ${{ steps.release.outputs.NEW_TAG }}
95114
name: "Release ${{ steps.release.outputs.NEW_TAG }}"
96-
body: "WSL2 image for containerlab version ${{ steps.containerlab.outputs.CONTAINERLAB_VERSION }}\n\nThis release was automatically generated based on the latest containerlab release."
115+
body: |
116+
WSL2 image for containerlab version ${{ steps.containerlab.outputs.CONTAINERLAB_VERSION }}
117+
118+
${{ github.event_name == 'workflow_dispatch' && 'This release was manually triggered.' || 'This release was automatically generated based on the latest containerlab release.' }}
97119
draft: false
98120
prerelease: false
99121

100122
build-and-publish:
101123
runs-on: ubuntu-22.04
102-
# Run this job if triggered by a release event or if the check-and-release job completed successfully
124+
# Run this job if triggered by a release event or if the check-and-release job determined a release is needed
103125
# The needs clause is conditional to avoid dependency on a job that might be skipped
104126
needs: [check-and-release]
105127
if: >

0 commit comments

Comments
 (0)