Skip to content

Commit b351b11

Browse files
committed
Split out publication to its own workflow
1 parent 2d95df9 commit b351b11

File tree

2 files changed

+106
-66
lines changed

2 files changed

+106
-66
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ on:
99

1010
env:
1111
JAVA_VERSION: "23"
12-
DOCKER_LAYER_CACHE: "/tmp/.buildx-cache"
13-
DOCKER_REGISTRY: "ghcr.io"
1412

1513
jobs:
1614
set_variables:
@@ -68,6 +66,17 @@ jobs:
6866
name: "mcw.jar"
6967
path: "target/mcw.jar"
7068

69+
publish_hotspot:
70+
needs: [ "set_variables", "build_hotspot" ]
71+
uses: "./.github/workflows/publish.yml"
72+
with:
73+
JAVA_VERSION: "${{ env.JAVA_VERSION }}"
74+
ARTIFACT_NAME: "mcw.jar"
75+
DOCKER_IMAGE: "${{ needs.set_variables.outputs.docker_image }}"
76+
DOCKER_TARGET: "hotspot"
77+
DOCKER_TAG_CANONICAL: "${{ needs.set_variables.outputs.build_version }}-hotspot"
78+
DOCKER_TAG_SHORT: "${{ needs.set_variables.outputs.image_version_short }}"
79+
7180
build_graal:
7281
name: "Build (GraalVM)"
7382
runs-on: "ubuntu-latest"
@@ -94,69 +103,16 @@ jobs:
94103
- name: "Archive binary"
95104
uses: "actions/upload-artifact@v4"
96105
with:
97-
name: "mcw-${{ runner.os }}-${{ runner.arch }}"
106+
name: "mcw-bin"
98107
path: "target/mcw"
99108

100-
publish:
101-
name: "Publish"
102-
runs-on: "ubuntu-latest"
103-
needs: [ "set_variables", "build_hotspot", "build_graal" ]
104-
permissions:
105-
contents: "read"
106-
packages: "write"
107-
108-
strategy:
109-
matrix:
110-
includes:
111-
- artifact: "mcw.jar"
112-
docker_target: "hotspot"
113-
- artifact: "mcw-${{ runner.os }}-${{ runner.arch }}"
114-
docker_target: "graal"
115-
116-
steps:
117-
- name: "Checkout repository"
118-
uses: "actions/checkout@v4"
119-
- name: "Download artifact"
120-
uses: "actions/download-artifact@v4"
121-
with:
122-
name: "${{ matrix.artifact }}"
123-
path: "${{ github.workspace }}/target"
124-
- name: "Set up QEMU"
125-
uses: "docker/setup-qemu-action@v3"
126-
- name: "Set up Docker Buildx"
127-
uses: "docker/setup-buildx-action@v3"
128-
- name: "Cache Docker layers"
129-
uses: "actions/cache@v4"
130-
with:
131-
path: "${{ env.DOCKER_LAYER_CACHE }}"
132-
key: "${{ runner.os }}-jdk-${{ env.JAVA_VERSION }}-${{ matrix.docker_target }}-${{ github.sha }}"
133-
restore-keys: |
134-
${{ runner.os }}-jdk-${{ env.JAVA_VERSION }}-${{ matrix.docker_target }}-
135-
- name: "Log in to the Container registry"
136-
uses: "docker/login-action@v3"
137-
with:
138-
registry: "${{ env.DOCKER_REGISTRY }}"
139-
username: "${{ github.actor }}"
140-
password: "${{ secrets.GITHUB_TOKEN }}"
141-
- name: "Extract metadata (tags, labels) for Docker"
142-
id: "meta"
143-
uses: "docker/metadata-action@v5"
144-
with:
145-
images: "${{ needs.set_variables.outputs.docker_image }}"
146-
tags: |
147-
type=raw,event=push,enable=true,value=${{ needs.set_variables.outputs.build_version }}-${{ matrix.docker_target }}
148-
type=raw,event=push,enable={{ is_default_branch }},value=${{ needs.set_variables.outputs.image_version_short }}-${{ matrix.docker_target }}
149-
- name: "Build and push Docker image"
150-
uses: "docker/build-push-action@v5"
151-
with:
152-
context: "."
153-
push: "true"
154-
platforms: "linux/amd64"
155-
provenance: false
156-
tags: ${{ steps.meta.outputs.tags }}
157-
labels: ${{ steps.meta.outputs.labels }}
158-
target: ${{ matrix.docker_target }}
159-
build-args: |
160-
JAVA_VERSION=${{ env.JAVA_VERSION }}
161-
cache-from: type=local,src=${{ env.DOCKER_LAYER_CACHE }}
162-
cache-to: type=local,dest=${{ env.DOCKER_LAYER_CACHE }}
109+
publish_graal:
110+
needs: [ "set_variables", "build_hotspot" ]
111+
uses: "./.github/workflows/publish.yml"
112+
with:
113+
JAVA_VERSION: "${{ env.JAVA_VERSION }}"
114+
ARTIFACT_NAME: "mcw-bin"
115+
DOCKER_IMAGE: "${{ needs.set_variables.outputs.docker_image }}"
116+
DOCKER_TARGET: "graal"
117+
DOCKER_TAG_CANONICAL: "${{ needs.set_variables.outputs.build_version }}-hotspot"
118+
DOCKER_TAG_SHORT: "${{ needs.set_variables.outputs.image_version_short }}"

.github/workflows/publish.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
JAVA_VERSION:
5+
type: string
6+
required: true
7+
ARTIFACT_NAME:
8+
type: string
9+
required: true
10+
DOCKER_IMAGE:
11+
type: string
12+
required: true
13+
DOCKER_TARGET:
14+
type: string
15+
required: true
16+
DOCKER_TAG_CANONICAL:
17+
type: string
18+
required: true
19+
DOCKER_TAG_SHORT:
20+
type: string
21+
required: true
22+
23+
name: "Publish (${{ inputs.DOCKER_TARGET }})"
24+
25+
concurrency:
26+
group: "${{ inputs.DOCKER_TAG_CANONICAL }}-${{ inputs.DOCKER_TARGET }}"
27+
28+
env:
29+
DOCKER_LAYER_CACHE: "/tmp/.buildx-cache"
30+
DOCKER_REGISTRY: "ghcr.io"
31+
32+
jobs:
33+
docker:
34+
runs-on: "ubuntu-latest"
35+
permissions:
36+
contents: "read"
37+
packages: "write"
38+
steps:
39+
- name: "Checkout repository"
40+
uses: "actions/checkout@v4"
41+
- name: "Download artifact"
42+
uses: "actions/download-artifact@v4"
43+
with:
44+
name: "${{ inputs.ARTIFACT_NAME }}"
45+
path: "${{ github.workspace }}/target"
46+
- name: "Set up QEMU"
47+
uses: "docker/setup-qemu-action@v3"
48+
- name: "Set up Docker Buildx"
49+
uses: "docker/setup-buildx-action@v3"
50+
- name: "Cache Docker layers"
51+
uses: "actions/cache@v4"
52+
with:
53+
path: "${{ env.DOCKER_LAYER_CACHE }}"
54+
key: "${{ runner.os }}-${{ inputs.DOCKER_TARGET }}-${{ github.sha }}"
55+
restore-keys: |
56+
${{ runner.os }}-${{ inputs.DOCKER_TARGET }}-
57+
- name: "Log in to the Container registry"
58+
uses: "docker/login-action@v3"
59+
with:
60+
registry: "${{ env.DOCKER_REGISTRY }}"
61+
username: "${{ github.actor }}"
62+
password: "${{ secrets.GITHUB_TOKEN }}"
63+
- name: "Extract metadata (tags, labels) for Docker"
64+
id: "meta"
65+
uses: "docker/metadata-action@v5"
66+
with:
67+
images: "${{ inputs.DOCKER_IMAGE }}"
68+
tags: |
69+
type=raw,event=push,enable=true,value=${{ inputs.DOCKER_TAG_CANONICAL }}
70+
type=raw,event=push,enable={{ is_default_branch }},value=${{ inputs.DOCKER_TAG_SHORT }}
71+
- name: "Build and push Docker image"
72+
uses: "docker/build-push-action@v5"
73+
with:
74+
context: "."
75+
push: "true"
76+
platforms: "linux/amd64"
77+
provenance: false
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
target: "${{ inputs.DOCKER_TARGET }}"
81+
build-args: |
82+
JAVA_VERSION=${{ inputs.JAVA_VERSION }}
83+
cache-from: "type=local,src=${{ env.DOCKER_LAYER_CACHE }}"
84+
cache-to: "type=local,dest=${{ env.DOCKER_LAYER_CACHE }}"

0 commit comments

Comments
 (0)