Skip to content

Commit 4803e35

Browse files
committed
feat/ci: native arm64 build
1 parent b4cf11f commit 4803e35

File tree

1 file changed

+133
-24
lines changed

1 file changed

+133
-24
lines changed

.github/workflows/vib-build.yml

Lines changed: 133 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Vib Build
33
on:
44
push:
55
branches:
6-
- 'main'
6+
- 'dev'
77
tags:
88
- '*'
99
workflow_dispatch:
@@ -18,22 +18,35 @@ jobs:
1818

1919
steps:
2020
- name: Verify Base Image Integrity
21+
if: ${{ github.ref_type == 'tag' }}
2122
run:
22-
gh attestation verify oci://ghcr.io/vanilla-os/pico:main --owner Vanilla-OS
23+
gh attestation verify oci://ghcr.io/vanilla-os/desktop:main --owner Vanilla-OS
2324
env:
2425
GH_TOKEN: ${{ github.token }}
2526

2627
build:
27-
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
include:
32+
- runner: ubuntu-latest
33+
arch: amd64
34+
- runner: ubuntu-24.04-arm
35+
arch: arm64
36+
runs-on: ${{ matrix.runner }}
2837
needs: verify-image
2938
permissions:
30-
contents: write # Allow actions to create release
3139
packages: write # Allow pushing images to GHCR
3240
attestations: write # To create and write attestations
3341
id-token: write # Additional permissions for the persistence of the attestations
3442

3543
steps:
36-
- uses: actions/checkout@v4
44+
- uses: actions/checkout@v5
45+
46+
- name: Change tag in recipe.
47+
if: ${{ github.ref_type == 'tag' }}
48+
run: |
49+
sed 's/ghcr.io\/vanilla-os\/desktop:dev/ghcr.io\/vanilla-os\/desktop:main/' -i recipe.yml
3750
3851
- uses: vanilla-os/vib-gh-action@v1.0.6
3952
with:
@@ -42,8 +55,9 @@ jobs:
4255

4356
- uses: actions/upload-artifact@v4
4457
with:
45-
name: Containerfile
46-
path: Containerfile
58+
name: Containerfile
59+
path: Containerfile
60+
overwrite: true
4761

4862
- name: Generate image name
4963
run: |
@@ -52,17 +66,10 @@ jobs:
5266
echo "IMAGE_URL=ghcr.io/$REPO_OWNER_LOWERCASE/waydroid" >> "$GITHUB_ENV"
5367
5468
- name: Docker meta
55-
id: docker_meta
69+
id: meta
5670
uses: docker/metadata-action@v5
5771
with:
58-
images: |
59-
${{ env. IMAGE_URL }}
60-
tags: |
61-
type=semver,pattern={{version}}
62-
type=semver,pattern={{major}}.{{minor}}
63-
type=semver,pattern={{raw}}
64-
type=semver,pattern=v{{major}}
65-
type=ref,event=branch
72+
images: ${{ env.IMAGE_URL }}
6673

6774
- name: Set up Docker Buildx
6875
uses: docker/setup-buildx-action@v3
@@ -75,25 +82,127 @@ jobs:
7582
username: ${{ github.repository_owner }}
7683
password: ${{ secrets.GITHUB_TOKEN }}
7784

78-
- name: Build and Push the Docker image
79-
id: push
85+
- name: Build and push by digest
86+
id: build
8087
uses: docker/build-push-action@v6
8188
with:
8289
context: .
8390
file: Containerfile
84-
push: ${{ github.event_name != 'pull_request' }}
85-
tags: ${{ steps.docker_meta.outputs.tags }}
86-
labels: ${{ steps.docker_meta.outputs.labels }}
91+
tags: ${{ env.IMAGE_URL }}
92+
labels: ${{ steps.meta.outputs.labels }}
8793
cache-from: type=gha
8894
cache-to: type=gha,mode=max
89-
platforms: linux/amd64
95+
platforms: linux/${{ matrix.arch }}
9096
provenance: false
97+
outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
9198

9299
- name: Attest pushed image
93-
uses: actions/attest-build-provenance@v1
100+
uses: actions/attest-build-provenance@v3
94101
id: attest
95102
if: ${{ github.event_name != 'pull_request' }}
96103
with:
97104
subject-name: ${{ env.IMAGE_URL }}
98-
subject-digest: ${{ steps.push.outputs.digest }}
105+
subject-digest: ${{ steps.build.outputs.digest }}
99106
push-to-registry: false
107+
108+
- name: Export digest
109+
if: ${{ github.event_name != 'pull_request' }}
110+
run: |
111+
mkdir -p ${{ runner.temp }}/digests
112+
digest="${{ steps.build.outputs.digest }}"
113+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
114+
115+
- name: Upload digest
116+
uses: actions/upload-artifact@v4
117+
if: ${{ github.event_name != 'pull_request' }}
118+
with:
119+
name: digests-${{ matrix.arch }}
120+
path: ${{ runner.temp }}/digests/*
121+
if-no-files-found: error
122+
retention-days: 1
123+
124+
merge:
125+
runs-on: ubuntu-latest
126+
if: ${{ github.event_name != 'pull_request' }}
127+
needs: build
128+
permissions:
129+
contents: write # Allow actions to create release
130+
packages: write # Allow pushing images to GHCR
131+
132+
steps:
133+
- name: Generate image name
134+
run: |
135+
REPO_OWNER_LOWERCASE="$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')"
136+
echo "REPO_OWNER_LOWERCASE=$REPO_OWNER_LOWERCASE" >> "$GITHUB_ENV"
137+
echo "IMAGE_URL=ghcr.io/$REPO_OWNER_LOWERCASE/waydroid" >> "$GITHUB_ENV"
138+
139+
- name: Download digests
140+
uses: actions/download-artifact@v4
141+
with:
142+
path: ${{ runner.temp }}/digests
143+
pattern: digests-*
144+
merge-multiple: true
145+
146+
- name: Extra image tag branch
147+
if: ${{ github.ref_type != 'tag' }}
148+
run: |
149+
echo "EXTRA_TAG=ref,event=branch" >> "$GITHUB_ENV"
150+
151+
- name: Extra image tag release
152+
if: ${{ github.ref_type == 'tag' }}
153+
run: |
154+
echo "EXTRA_TAG=raw,main" >> "$GITHUB_ENV"
155+
156+
- name: Docker meta
157+
id: meta
158+
uses: docker/metadata-action@v5
159+
with:
160+
images: ${{ env.IMAGE_URL }}
161+
tags: |
162+
type=semver,pattern={{version}}
163+
type=semver,pattern={{major}}.{{minor}}
164+
type=semver,pattern={{raw}}
165+
type=semver,pattern=v{{major}}
166+
type=${{ env.EXTRA_TAG }}
167+
168+
- name: Set up Docker Buildx
169+
uses: docker/setup-buildx-action@v3
170+
171+
- name: Login to GitHub Package Registry
172+
uses: docker/login-action@v3
173+
with:
174+
registry: ghcr.io
175+
username: ${{ github.repository_owner }}
176+
password: ${{ secrets.GITHUB_TOKEN }}
177+
178+
- name: Create manifest list and push
179+
working-directory: ${{ runner.temp }}/digests
180+
run: |
181+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
182+
$(printf '${{ env.IMAGE_URL }}@sha256:%s ' *)
183+
184+
differ:
185+
runs-on: ubuntu-latest
186+
if: github.repository == 'vanilla-os/waydroid-image' && github.ref_type == 'tag'
187+
needs: merge
188+
container:
189+
image: ghcr.io/vanilla-os/waydroid:main
190+
191+
steps:
192+
- uses: actions/checkout@v5
193+
194+
- name: Generate package diff
195+
run: |
196+
lpkg --unlock
197+
PACKAGE_LIST=$(.github/gen_package_list.sh)
198+
apt-get install -y curl
199+
IMAGE_DIGEST=$(curl -s -L -H "Accept: application/vnd.github+json" \
200+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
201+
-H "X-GitHub-Api-Version: 2022-11-28" \
202+
https://api.github.com/orgs/Vanilla-OS/packages/container/waydroid/versions | grep -m1 name | sed -E 's/^\s*"name": "(.+)".*$/\1/')
203+
curl -X POST \
204+
-H 'Accept:application/json' \
205+
-H "Authorization:Basic $(echo -n "${{ secrets.DIFFER_USER }}:${{ secrets.DIFFER_PSW }}" | base64)" \
206+
-d "{\"digest\":\"${IMAGE_DIGEST}\",${PACKAGE_LIST}}" \
207+
${{ vars.DIFFER_URL }}/images/waydroid/new
208+
lpkg --lock

0 commit comments

Comments
 (0)