Skip to content

Commit 4b0630b

Browse files
committed
split action
1 parent 3823812 commit 4b0630b

File tree

1 file changed

+60
-20
lines changed

1 file changed

+60
-20
lines changed

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

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ jobs:
6060
run: |
6161
NEED_RELEASE="false"
6262
NEW_WSL_VERSION="1.0"
63-
64-
# Always build when manually triggered
63+
64+
# Always build when manually triggered via workflow_dispatch
6565
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
6666
NEED_RELEASE="true"
6767
echo "Manual trigger detected - forcing release"
@@ -119,15 +119,63 @@ jobs:
119119
draft: false
120120
prerelease: false
121121

122-
build-and-publish:
122+
# This job runs when triggered by a release event (manual release)
123+
build-and-publish-from-release:
123124
runs-on: ubuntu-22.04
124-
# Run this job if triggered by a release event or if the check-and-release job determined a release is needed
125-
# The needs clause is conditional to avoid dependency on a job that might be skipped
126-
needs: [check-and-release]
127-
if: >
128-
github.event_name == 'release' ||
129-
(github.event_name != 'release' && needs.check-and-release.outputs.NEED_RELEASE == 'true')
125+
if: github.event_name == 'release'
126+
steps:
127+
- name: Checkout Repository
128+
uses: actions/checkout@v4
129+
130+
- name: Set up Docker Buildx
131+
uses: docker/setup-buildx-action@v2
132+
133+
- name: Build Docker Image
134+
run: |
135+
docker build . --tag clab-wsl-debian
130136
137+
- name: Run Docker Container and Export Filesystem
138+
run: |
139+
# Run the Docker container
140+
docker run -t --name wsl_export clab-wsl-debian ls /
141+
# Export the container's filesystem to a tar file
142+
docker export wsl_export -o clab.tar
143+
# Remove the container to clean up
144+
docker rm wsl_export
145+
146+
- name: Rename tar to .wsl file
147+
run: |
148+
# Rename the tar file to have a .wsl extension
149+
mv clab.tar clab.wsl
150+
151+
- name: Upload WSL Image Artifact
152+
uses: actions/upload-artifact@v4
153+
with:
154+
name: clab-wsl2
155+
path: clab.wsl
156+
157+
- name: Get release tag
158+
id: get_tag
159+
run: |
160+
# For releases triggered by the release event
161+
REF_NAME="${{ github.ref }}"
162+
TAG="${REF_NAME#refs/tags/}"
163+
echo "Using release tag: $TAG"
164+
echo "TAG=$TAG" >> $GITHUB_OUTPUT
165+
166+
- name: Upload Release Asset
167+
uses: svenstaro/upload-release-action@v2
168+
with:
169+
repo_token: ${{ secrets.GITHUB_TOKEN }}
170+
file: clab.wsl
171+
asset_name: clab-${{ steps.get_tag.outputs.TAG }}.wsl
172+
tag: ${{ steps.get_tag.outputs.TAG }}
173+
174+
# This job runs when triggered by a schedule or workflow_dispatch event and a release is needed
175+
build-and-publish-from-check:
176+
runs-on: ubuntu-22.04
177+
needs: [check-and-release]
178+
if: needs.check-and-release.outputs.NEED_RELEASE == 'true'
131179
steps:
132180
- name: Checkout Repository
133181
uses: actions/checkout@v4
@@ -162,17 +210,9 @@ jobs:
162210
- name: Get release tag
163211
id: get_tag
164212
run: |
165-
if [[ "${{ github.event_name }}" == "release" ]]; then
166-
# For releases triggered by the release event
167-
REF_NAME="${{ github.ref }}"
168-
TAG="${REF_NAME#refs/tags/}"
169-
echo "Using release tag: $TAG"
170-
echo "TAG=$TAG" >> $GITHUB_OUTPUT
171-
else
172-
# For releases created by the check-and-release job
173-
echo "Using new tag: ${{ needs.check-and-release.outputs.NEW_TAG }}"
174-
echo "TAG=${{ needs.check-and-release.outputs.NEW_TAG }}" >> $GITHUB_OUTPUT
175-
fi
213+
# For releases created by the check-and-release job
214+
echo "Using new tag: ${{ needs.check-and-release.outputs.NEW_TAG }}"
215+
echo "TAG=${{ needs.check-and-release.outputs.NEW_TAG }}" >> $GITHUB_OUTPUT
176216
177217
- name: Upload Release Asset
178218
uses: svenstaro/upload-release-action@v2

0 commit comments

Comments
 (0)