Skip to content

Commit d798715

Browse files
committed
Refactor release workflow: split build and release steps into separate workflows
- Extracted the release process into a dedicated `release.yml`. - Simplified `build.yml` by focusing solely on scheduled and manual build triggers. - Retained artifact upload and preparation exclusively in the release workflow.
1 parent 4a3adfa commit d798715

File tree

2 files changed

+187
-174
lines changed

2 files changed

+187
-174
lines changed

.github/workflows/build.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Build
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0'
6+
workflow_dispatch:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
jobs:
12+
build-kernel:
13+
runs-on: ubuntu-latest
14+
env:
15+
LINUX_TARBALL_URL: https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.17.4.tar.xz
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Build Kernel
24+
id: build-and-push
25+
uses: docker/build-push-action@v5
26+
with:
27+
context: .
28+
build-args: |
29+
LINUX_TARBALL_URL=${{ env.LINUX_TARBALL_URL }}
30+
31+
file: kernel/vanilla.Dockerfile
32+
push: false
33+
outputs: type=local,dest=kernel/out
34+
cache-from: type=gha,scope=kernel
35+
cache-to: type=gha,mode=max,scope=kernel
36+
37+
- name: Upload kernel artifacts
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: kernel-artifacts
41+
path: kernel/out/out/
42+
retention-days: 1
43+
44+
build-rootfs:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v4
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
53+
54+
- name: Build rootfs
55+
id: build-and-push
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
file: rootfs/rootfs.Dockerfile
60+
push: false
61+
outputs: type=local,dest=rootfs/out
62+
cache-from: type=gha,scope=rootfs
63+
cache-to: type=gha,mode=max,scope=rootfs
64+
65+
- name: Upload rootfs artifacts
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: rootfs-artifacts
69+
path: rootfs/out/out/
70+
retention-days: 1
71+
72+
build-k8s:
73+
needs:
74+
- build-kernel
75+
- build-rootfs
76+
runs-on: ubuntu-latest
77+
strategy:
78+
matrix:
79+
k8s_version: [ '1.28', '1.29', '1.30', '1.31', '1.32', '1.33' ]
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Set up Docker Buildx
86+
uses: docker/setup-buildx-action@v3
87+
88+
- name: Download kernel artifacts
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: kernel-artifacts
92+
path: kernel/out/
93+
94+
- name: Download rootfs artifacts
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: rootfs-artifacts
98+
path: rootfs/out/
99+
100+
- name: Get latest patch version for k8s ${{ matrix.k8s_version }}
101+
id: k8s_version
102+
run: |
103+
MAJOR_MINOR="${{ matrix.k8s_version }}"
104+
LATEST=$(curl -sL "https://dl.k8s.io/release/stable-${MAJOR_MINOR}.txt" || echo "")
105+
106+
if [ -z "$LATEST" ] || [ "$LATEST" = "<?xml"* ]; then
107+
# Fallback: get all releases and filter by version
108+
LATEST=$(curl -sL https://api.github.com/repos/kubernetes/kubernetes/releases | \
109+
jq -r '.[].tag_name' | \
110+
grep "^v${MAJOR_MINOR}\." | \
111+
head -n 1)
112+
fi
113+
114+
echo "version=${LATEST}" >> $GITHUB_OUTPUT
115+
echo "version_short=${LATEST#v}" >> $GITHUB_OUTPUT
116+
117+
- name: Resolve k8s URLs
118+
id: resolve_k8s_urls
119+
run: |
120+
bash ./.github/utils/resolve.sh ${{ matrix.k8s_version }} ${{ steps.k8s_version.outputs.version }} >> $GITHUB_ENV
121+
122+
- name: Build rootfs k8s
123+
uses: docker/build-push-action@v5
124+
with:
125+
context: .
126+
file: rootfs-k8s/rootfs-k8s.Dockerfile
127+
push: false
128+
build-args: |
129+
KUBELET_URL
130+
KUBEADM_URL
131+
KUBECTL_URL
132+
CONTAINERD_TGZ_URL
133+
RUNC_URL
134+
CRICTL_TGZ_URL
135+
NERDCTL_TGZ_URL
136+
CNI_PLUGINS_TGZ_URL
137+
outputs: type=local,dest=rootfs-k8s/raw
138+
cache-from: type=gha,scope=rootfs-k8s-${{ matrix.k8s_version }}
139+
cache-to: type=gha,mode=max,scope=rootfs-k8s-${{ matrix.k8s_version }}
140+
141+
- name: Move raw rootfs k8s to out
142+
run: |
143+
mkdir -p rootfs-k8s/out
144+
mv --verbose rootfs-k8s/raw/out/* rootfs-k8s/out
145+
146+
- name: Build livecd
147+
uses: docker/build-push-action@v5
148+
with:
149+
context: .
150+
file: livecd/livecd.Dockerfile
151+
push: false
152+
outputs: type=local,dest=livecd/raw
153+
cache-from: type=gha,scope=livecd-${{ matrix.k8s_version }}
154+
cache-to: type=gha,mode=max,scope=livecd-${{ matrix.k8s_version }}
155+
156+
- name: Move raw livecd to out
157+
run: |
158+
mkdir -p livecd/out
159+
mv --verbose livecd/raw/out/* livecd/out
160+
161+
162+
- name: Rename artifact
163+
run: |
164+
mv livecd/out/node.iso node-k8s-${{ steps.k8s_version.outputs.version_short }}.iso
165+
166+
- name: Upload artifact
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: node-k8s-${{ steps.k8s_version.outputs.version_short }}
170+
path: node-k8s-${{ steps.k8s_version.outputs.version_short }}.iso
171+
retention-days: 1

.github/workflows/release.yml

Lines changed: 16 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,27 @@
1-
name: Build and Release
1+
name: Release
22

33
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
tags:
9-
- 'v*'
4+
workflow_run:
5+
workflows:
6+
- Build
7+
types:
8+
- completed
109

1110
jobs:
12-
build-kernel:
13-
runs-on: ubuntu-latest
14-
env:
15-
LINUX_TARBALL_URL: https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.17.4.tar.xz
16-
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v4
19-
20-
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@v3
22-
23-
- name: Build Kernel
24-
id: build-and-push
25-
uses: docker/build-push-action@v5
26-
with:
27-
context: .
28-
build-args: |
29-
LINUX_TARBALL_URL=${{ env.LINUX_TARBALL_URL }}
30-
31-
file: kernel/vanilla.Dockerfile
32-
push: false
33-
outputs: type=local,dest=kernel/out
34-
cache-from: type=gha,scope=kernel
35-
cache-to: type=gha,mode=max,scope=kernel
36-
37-
- name: Upload kernel artifacts
38-
uses: actions/upload-artifact@v4
39-
with:
40-
name: kernel-artifacts
41-
path: kernel/out/out/
42-
retention-days: 1
43-
44-
build-rootfs:
45-
runs-on: ubuntu-latest
46-
steps:
47-
- name: Checkout code
48-
uses: actions/checkout@v4
49-
50-
- name: Set up Docker Buildx
51-
uses: docker/setup-buildx-action@v3
52-
53-
54-
- name: Build rootfs
55-
id: build-and-push
56-
uses: docker/build-push-action@v5
57-
with:
58-
context: .
59-
file: rootfs/rootfs.Dockerfile
60-
push: false
61-
outputs: type=local,dest=rootfs/out
62-
cache-from: type=gha,scope=rootfs
63-
cache-to: type=gha,mode=max,scope=rootfs
64-
65-
- name: Upload rootfs artifacts
66-
uses: actions/upload-artifact@v4
67-
with:
68-
name: rootfs-artifacts
69-
path: rootfs/out/out/
70-
retention-days: 1
71-
72-
build-k8s:
73-
needs:
74-
- build-kernel
75-
- build-rootfs
76-
runs-on: ubuntu-latest
77-
strategy:
78-
matrix:
79-
k8s_version: ['1.28', '1.29', '1.30', '1.31', '1.32', '1.33']
80-
81-
steps:
82-
- name: Checkout code
83-
uses: actions/checkout@v4
84-
85-
- name: Set up Docker Buildx
86-
uses: docker/setup-buildx-action@v3
87-
88-
- name: Download kernel artifacts
89-
uses: actions/download-artifact@v4
90-
with:
91-
name: kernel-artifacts
92-
path: kernel/out/
93-
94-
- name: Download rootfs artifacts
95-
uses: actions/download-artifact@v4
96-
with:
97-
name: rootfs-artifacts
98-
path: rootfs/out/
99-
100-
- name: Get latest patch version for k8s ${{ matrix.k8s_version }}
101-
id: k8s_version
102-
run: |
103-
MAJOR_MINOR="${{ matrix.k8s_version }}"
104-
LATEST=$(curl -sL "https://dl.k8s.io/release/stable-${MAJOR_MINOR}.txt" || echo "")
105-
106-
if [ -z "$LATEST" ] || [ "$LATEST" = "<?xml"* ]; then
107-
# Fallback: get all releases and filter by version
108-
LATEST=$(curl -sL https://api.github.com/repos/kubernetes/kubernetes/releases | \
109-
jq -r '.[].tag_name' | \
110-
grep "^v${MAJOR_MINOR}\." | \
111-
head -n 1)
112-
fi
113-
114-
echo "version=${LATEST}" >> $GITHUB_OUTPUT
115-
echo "version_short=${LATEST#v}" >> $GITHUB_OUTPUT
116-
117-
- name: Resolve k8s URLs
118-
id: resolve_k8s_urls
119-
run: |
120-
bash ./.github/utils/resolve.sh ${{ matrix.k8s_version }} ${{ steps.k8s_version.outputs.version }} >> $GITHUB_ENV
121-
122-
- name: Build rootfs k8s
123-
uses: docker/build-push-action@v5
124-
with:
125-
context: .
126-
file: rootfs-k8s/rootfs-k8s.Dockerfile
127-
push: false
128-
build-args: |
129-
KUBELET_URL
130-
KUBEADM_URL
131-
KUBECTL_URL
132-
CONTAINERD_TGZ_URL
133-
RUNC_URL
134-
CRICTL_TGZ_URL
135-
NERDCTL_TGZ_URL
136-
CNI_PLUGINS_TGZ_URL
137-
outputs: type=local,dest=rootfs-k8s/raw
138-
cache-from: type=gha,scope=rootfs-k8s-${{ matrix.k8s_version }}
139-
cache-to: type=gha,mode=max,scope=rootfs-k8s-${{ matrix.k8s_version }}
140-
141-
- name: Move raw rootfs k8s to out
142-
run: |
143-
mkdir -p rootfs-k8s/out
144-
mv --verbose rootfs-k8s/raw/out/* rootfs-k8s/out
145-
146-
- name: Build livecd
147-
uses: docker/build-push-action@v5
148-
with:
149-
context: .
150-
file: livecd/livecd.Dockerfile
151-
push: false
152-
outputs: type=local,dest=livecd/raw
153-
cache-from: type=gha,scope=livecd-${{ matrix.k8s_version }}
154-
cache-to: type=gha,mode=max,scope=livecd-${{ matrix.k8s_version }}
155-
156-
- name: Move raw livecd to out
157-
run: |
158-
mkdir -p livecd/out
159-
mv --verbose livecd/raw/out/* livecd/out
160-
161-
162-
- name: Rename artifact
163-
run: |
164-
mv livecd/out/node.iso node-k8s-${{ steps.k8s_version.outputs.version_short }}.iso
165-
166-
- name: Upload artifact
167-
uses: actions/upload-artifact@v4
168-
with:
169-
name: node-k8s-${{ steps.k8s_version.outputs.version_short }}
170-
path: node-k8s-${{ steps.k8s_version.outputs.version_short }}.iso
171-
retention-days: 1
172-
17311
release:
174-
needs: build-k8s
12+
if: >
13+
github.event.workflow_run.conclusion == 'success' &&
14+
startsWith(github.event.workflow_run.head_branch, 'v')
15+
17516
runs-on: ubuntu-latest
17617
permissions:
17718
contents: write
17819

17920
steps:
180-
- name: Download all artifacts
21+
- name: Download build artifacts
18122
uses: actions/download-artifact@v4
18223
with:
24+
run-id: ${{ github.event.workflow_run.id }}
18325
path: artifacts
18426

18527
- name: Prepare release files
@@ -188,10 +30,10 @@ jobs:
18830
find artifacts -name "*.iso" -exec cp {} release/ \;
18931
ls -lh release/
19032
191-
- name: Upload assets to existing release
33+
- name: Upload assets to release
19234
env:
19335
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194-
TAG_NAME: ${{ github.ref_name }}
36+
TAG_NAME: ${{ github.event.workflow_run.head_branch }}
19537
run: |
196-
gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null
197-
gh release upload "$TAG_NAME" release/*.iso --repo "$GITHUB_REPOSITORY" --clobber
38+
gh release view "$TAG_NAME" >/dev/null
39+
gh release upload "$TAG_NAME" release/*.iso --clobber

0 commit comments

Comments
 (0)