Skip to content

Commit 9b0fe81

Browse files
committed
Refactoring workflow
1 parent f9e2338 commit 9b0fe81

File tree

1 file changed

+77
-69
lines changed

1 file changed

+77
-69
lines changed

.github/workflows/build.yml

Lines changed: 77 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,60 @@ jobs:
6969
name: target
7070
path: target
7171

72+
- name: Lowercase github.repository
73+
run: echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
74+
7275
- name: Build and push [jvm-edge]
73-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:jvm-edge -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
76+
run: |
77+
docker buildx build \
78+
-t ghcr.io/${{ env.IMAGE_NAME }}:jvm-edge \
79+
-f src/main/docker/Dockerfile.jvm \
80+
--platform linux/amd64,linux/arm64 \
81+
--push .
7482
7583
- name: Build and push [edge]
76-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:edge -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
84+
run: |
85+
docker buildx build \
86+
-t ghcr.io/${{ env.IMAGE_NAME }}:edge \
87+
-f src/main/docker/Dockerfile.jvm \
88+
--platform linux/amd64,linux/arm64 \
89+
--push .
7790
7891
- name: Build and push [jvm-version]
7992
if: startsWith(github.ref, 'refs/tags/v')
80-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:jvm-${{ env.PROJECT_VERSION }} -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
93+
run: |
94+
docker buildx build \
95+
-t ghcr.io/${{ env.IMAGE_NAME }}:jvm-${{ env.PROJECT_VERSION }} \
96+
-f src/main/docker/Dockerfile.jvm \
97+
--platform linux/amd64,linux/arm64 \
98+
--push .
8199
82100
- name: Build and push [version]
83101
if: startsWith(github.ref, 'refs/tags/v')
84-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:${{ env.PROJECT_VERSION }} -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
102+
run: |
103+
docker buildx build \
104+
-t ghcr.io/${{ env.IMAGE_NAME }}:${{ env.PROJECT_VERSION }} \
105+
-f src/main/docker/Dockerfile.jvm \
106+
--platform linux/amd64,linux/arm64 \
107+
--push .
85108
86109
- name: Build and push [jvm-latest]
87110
if: startsWith(github.ref, 'refs/tags/v')
88-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:jvm-latest -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
111+
run: |
112+
docker buildx build \
113+
-t ghcr.io/${{ env.IMAGE_NAME }}:jvm-latest \
114+
-f src/main/docker/Dockerfile.jvm \
115+
--platform linux/amd64,linux/arm64 \
116+
--push .
89117
90118
- name: Build and push [latest]
91119
if: startsWith(github.ref, 'refs/tags/v')
92-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:latest -f src/main/docker/Dockerfile.jvm --platform linux/amd64,linux/arm64 .
120+
run: |
121+
docker buildx build \
122+
-t ghcr.io/${{ env.IMAGE_NAME }}:latest \
123+
-f src/main/docker/Dockerfile.jvm \
124+
--platform linux/amd64,linux/arm64 \
125+
--push .
93126
94127
uber-jar:
95128
name: Uber-JAR
@@ -134,61 +167,19 @@ jobs:
134167
type: application/java-archive
135168
label: Uber-JAR
136169

137-
native-amd64:
138-
name: Native [amd64]
170+
native:
171+
name: Native
139172
runs-on: ubuntu-latest
140173
needs:
141174
- build
142175

143-
steps:
144-
- name: Checkout
145-
uses: actions/checkout@v4
146-
147-
- name: Prepare version labels
148-
uses: k15g/action-version-labels@edge
149-
with:
150-
prefix: project
151-
152-
- name: Set up QEMU
153-
uses: docker/setup-qemu-action@v3
154-
155-
- name: Set up Docker Buildx
156-
uses: docker/setup-buildx-action@v3
157-
158-
- name: Download artifact [target]
159-
uses: actions/download-artifact@v4
160-
with:
161-
name: target
162-
path: target
163-
164-
- name: Build native
165-
run: make native
166-
167-
- name: Rename file
168-
run: mv target/submit-runner target/submit-runner-linux-x86_64
169-
170-
- name: Upload artifact [native-amd64]
171-
uses: actions/upload-artifact@v4
172-
with:
173-
name: native-amd64
174-
path: target/submit-runner-linux-x86_64
175-
if-no-files-found: error
176-
retention-days: 7
177-
178-
- name: Upload asset
179-
uses: k15g/action-github-asset-upload@edge
180-
if: startsWith(github.ref, 'refs/tags/v')
181-
with:
182-
token: ${{ secrets.GITHUB_TOKEN }}
183-
file: target/submit-runner-linux-x86_64
184-
name: submit-${{ env.PROJECT_VERSION }}-native-linux-x86_64
185-
label: Native [amd64]
186-
187-
native-arm64:
188-
name: Native [arm64]
189-
runs-on: ubuntu-24.04-arm
190-
needs:
191-
- build
176+
strategy:
177+
matrix:
178+
include:
179+
- arch: amd64
180+
ident: x86_64
181+
- arch: arm64
182+
ident: aarch64
192183

193184
steps:
194185
- name: Checkout
@@ -215,13 +206,13 @@ jobs:
215206
run: make native
216207

217208
- name: Rename file
218-
run: mv target/submit-runner target/submit-runner-linux-aarch64
209+
run: mv target/submit-runner target/submit-runner-linux-${{ matrix.ident }}
219210

220-
- name: Upload artifact [native-arm64]
211+
- name: Upload artifact [native-${{ matrix.arch }}]
221212
uses: actions/upload-artifact@v4
222213
with:
223-
name: native-arm64
224-
path: target/submit-runner-linux-aarch64
214+
name: native-${{ matrix.arch }}
215+
path: target/submit-runner-linux-${{ matrix.ident }}
225216
if-no-files-found: error
226217
retention-days: 7
227218

@@ -230,16 +221,15 @@ jobs:
230221
if: startsWith(github.ref, 'refs/tags/v')
231222
with:
232223
token: ${{ secrets.GITHUB_TOKEN }}
233-
file: target/submit-runner-linux-aarch64
234-
name: submit-${{ env.PROJECT_VERSION }}-native-linux-aarch64
235-
label: Native [arm64]
224+
file: target/submit-runner-linux-${{ matrix.ident }}
225+
name: submit-${{ env.PROJECT_VERSION }}-native-linux-${{ matrix.ident }}
226+
label: Native [${{ matrix.arch }}]
236227

237228
docker-native:
238229
name: Docker [Native]
239230
runs-on: ubuntu-latest
240231
needs:
241-
- native-amd64
242-
- native-arm64
232+
- native
243233

244234
steps:
245235
- name: Checkout
@@ -275,13 +265,31 @@ jobs:
275265
name: native-amd64
276266
path: target
277267

268+
- name: Lowercase github.repository
269+
run: echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV}
270+
278271
- name: Build and push [native-edge]
279-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:native-edge -f src/main/docker/Dockerfile.native-micro --platform linux/amd64,linux/arm64 .
272+
run: |
273+
docker buildx build \
274+
-t ghcr.io/${{ env.IMAGE_NAME }}:native-edge \
275+
-f src/main/docker/Dockerfile.native-micro \
276+
--platform linux/amd64,linux/arm64 \
277+
--push .
280278
281279
- name: Build and push [native-version]
282280
if: startsWith(github.ref, 'refs/tags/v')
283-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:native-${{ env.PROJECT_VERSION }} -f src/main/docker/Dockerfile.native-micro --platform linux/amd64,linux/arm64 .
281+
run: |
282+
docker buildx build \
283+
-t ghcr.io/${{ env.IMAGE_NAME }}:native-${{ env.PROJECT_VERSION }} \
284+
-f src/main/docker/Dockerfile.native-micro \
285+
--platform linux/amd64,linux/arm64 \
286+
--push .
284287
285288
- name: Build and push [native-latest]
286289
if: startsWith(github.ref, 'refs/tags/v')
287-
run: docker buildx build --push -t ghcr.io/javabin/submittheforce:native-latest -f src/main/docker/Dockerfile.native-micro --platform linux/amd64,linux/arm64 .
290+
run: |
291+
docker buildx build \
292+
-t ghcr.io/${{ env.IMAGE_NAME }}:native-latest \
293+
-f src/main/docker/Dockerfile.native-micro \
294+
--platform linux/amd64,linux/arm64 \
295+
--push .

0 commit comments

Comments
 (0)