Skip to content

Commit 5a9c956

Browse files
authored
test new flow
1 parent f98a63f commit 5a9c956

File tree

1 file changed

+88
-91
lines changed

1 file changed

+88
-91
lines changed
Lines changed: 88 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,117 @@
11
name: Build
2-
32
on:
43
push:
5-
branches:
6-
- 'main'
7-
tags:
8-
- 'v*'
4+
branches: [ "main" ]
5+
tags: [ "v*" ]
96
pull_request:
107

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE: ${{ github.repository }}
11+
VERSIONS_JSON: >-
12+
["v1.23.1","v1.23.2","v1.23.3","v1.23.4-rc1","v1.23.4-rc2",
13+
"v1.24.0-rc1","v1.25.0-rc1","v1.24.0","v1.25.0","v1.25.1","v1.25.2",
14+
"v1.26.0-rc1","v1.26.0","v1.26.1","v1.26.2","v1.26.3",
15+
"v1.27.0","v1.27.1","v1.27.2",
16+
"v1.28.0","v1.28.1","v1.28.2",
17+
"v1.29.0","v1.29.1","v1.29.2",
18+
"v1.30.0","v1.31.0",
19+
"v1.32.0-rc1","v1.32.0-rc3","v1.32.1","v1.32.2",
20+
"v1.33.0","v1.33.1"]
21+
NETS_JSON: >-
22+
[{"name":"mainnet","goflags":""},
23+
{"name":"devnet","goflags":"-tags=debug"}]
24+
ARCHES_JSON: >-
25+
[{"arch":"amd64","platform":"linux/amd64","runs_on":"ubuntu-latest"},
26+
{"arch":"arm64","platform":"linux/arm64","runs_on":"ubuntu-24.04-arm"}] # adjust to your native ARM runner
27+
1128
jobs:
1229
build:
13-
name: Containers
14-
runs-on: ubuntu-latest
30+
name: Build ${{ matrix.version }} • ${{ matrix.net.name }} • ${{ matrix.arch.arch }}
31+
runs-on: ${{ matrix.arch.runs_on }}
1532
permissions:
1633
contents: read
1734
packages: write
1835
strategy:
1936
fail-fast: false
2037
matrix:
21-
version:
22-
- v1.23.1
23-
- v1.23.2
24-
- v1.23.3
25-
- v1.23.4-rc1
26-
- v1.23.4-rc2
27-
- v1.24.0-rc1
28-
- v1.25.0-rc1
29-
- v1.24.0
30-
- v1.25.0
31-
- v1.25.1
32-
- v1.25.2
33-
- v1.26.0-rc1
34-
- v1.26.0
35-
- v1.26.1
36-
- v1.26.2
37-
- v1.26.3
38-
- v1.27.0
39-
- v1.27.1
40-
- v1.27.2
41-
- v1.28.0
42-
- v1.28.1
43-
- v1.28.2
44-
- v1.29.0
45-
- v1.29.1
46-
- v1.29.2
47-
- v1.30.0
48-
- v1.31.0
49-
- v1.32.0-rc1
50-
- v1.32.0-rc3
51-
- v1.32.1
52-
- v1.32.2
53-
- v1.33.0
54-
- v1.33.1
55-
net:
56-
- name: mainnet
57-
goflags: ''
58-
- name: devnet
59-
goflags: '-tags=debug'
60-
platform:
61-
- linux/amd64,linux/arm64
38+
version: ${{ fromJSON(env.VERSIONS_JSON) }}
39+
net: ${{ fromJSON(env.NETS_JSON) }}
40+
arch: ${{ fromJSON(env.ARCHES_JSON) }}
6241
steps:
63-
- name: Log in to the Container registry
64-
uses: docker/login-action@v2
42+
- uses: docker/login-action@v2
6543
with:
66-
registry: ghcr.io
44+
registry: ${{ env.REGISTRY }}
6745
username: ${{ github.actor }}
6846
password: ${{ secrets.GITHUB_TOKEN }}
69-
- name: Extract metadata for Lotus ${{ matrix.version }} ${{ matrix.net.name }}
70-
id: meta
71-
uses: docker/metadata-action@v4
72-
with:
73-
images: ghcr.io/${{ github.repository }}
74-
tags: |
75-
type=raw,value=lotus-${{ matrix.version }}-${{ matrix.net.name }}
76-
- name: Check if image exists
77-
id: checker
47+
48+
- name: Check if arch image exists
49+
id: check
7850
run: |
79-
if ! docker manifest inspect ${{ steps.meta.outputs.tags }}
80-
then
81-
echo "IMAGE_EXISTS=false" >> $GITHUB_ENV
51+
TAG="${{ env.REGISTRY }}/${{ env.IMAGE }}:lotus-${{ matrix.version }}-${{ matrix.net.name }}-${{ matrix.arch.arch }}"
52+
if docker manifest inspect "$TAG" >/dev/null 2>&1; then
53+
echo "exists=true" >> $GITHUB_OUTPUT
54+
else
55+
echo "exists=false" >> $GITHUB_OUTPUT
8256
fi
83-
- name: Free Disk Space (Ubuntu)
84-
uses: jlumbroso/free-disk-space@main
85-
if: env.IMAGE_EXISTS == 'false'
86-
with:
87-
tool-cache: false
88-
android: true
89-
dotnet: true
90-
haskell: true
91-
- name: Checkout
92-
uses: actions/checkout@v3
93-
if: env.IMAGE_EXISTS == 'false'
57+
58+
- uses: actions/checkout@v3
59+
if: steps.check.outputs.exists == 'false'
9460
with:
9561
repository: filecoin-project/lotus
9662
ref: ${{ matrix.version }}
9763
path: lotus
98-
- name: Set up QEMU
99-
uses: docker/setup-qemu-action@v2
100-
if: env.IMAGE_EXISTS == 'false'
101-
- name: Set up Docker Buildx
102-
uses: docker/setup-buildx-action@v2
103-
if: env.IMAGE_EXISTS == 'false'
104-
with:
105-
platforms: ${{ matrix.platform }}
106-
- name: Build Lotus ${{ matrix.version }} ${{ matrix.net.name }}
64+
65+
- uses: docker/setup-buildx-action@v2
66+
if: steps.check.outputs.exists == 'false'
67+
68+
- name: Build & push (native)
69+
if: steps.check.outputs.exists == 'false'
10770
uses: docker/build-push-action@v4
108-
if: env.IMAGE_EXISTS == 'false'
109-
env:
110-
REGISTRY_CACHE_REF: ghcr.io/${{ github.repository }}:cache
11171
with:
11272
context: lotus
113-
cache-from: type=registry,ref=${{ env.REGISTRY_CACHE_REF }}
114-
cache-to: type=registry,mode=max,ref=${{ env.REGISTRY_CACHE_REF }}
73+
platforms: ${{ matrix.arch.platform }}
11574
push: ${{ github.event_name != 'pull_request' }}
116-
tags: ${{ steps.meta.outputs.tags }}
117-
labels: ${{ steps.meta.outputs.labels }}
118-
platforms: ${{ matrix.platform }}
75+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:lotus-${{ matrix.version }}-${{ matrix.net.name }}-${{ matrix.arch.arch }}
11976
build-args: |
12077
GOFLAGS=${{ matrix.net.goflags }}
78+
79+
manifest:
80+
name: Manifest ${{ matrix.version }} • ${{ matrix.net.name }}
81+
if: github.event_name != 'pull_request'
82+
runs-on: ubuntu-latest
83+
needs: build
84+
permissions:
85+
contents: read
86+
packages: write
87+
strategy:
88+
fail-fast: false
89+
matrix:
90+
version: ${{ fromJSON(env.VERSIONS_JSON) }}
91+
net: ${{ fromJSON(env.NETS_JSON) }}
92+
steps:
93+
- uses: docker/login-action@v2
94+
with:
95+
registry: ${{ env.REGISTRY }}
96+
username: ${{ github.actor }}
97+
password: ${{ secrets.GITHUB_TOKEN }}
98+
99+
- name: Create/Update multi-arch manifest
100+
shell: bash
101+
env:
102+
BASE_TAG: ${{ env.REGISTRY }}/${{ env.IMAGE }}:lotus-${{ matrix.version }}-${{ matrix.net.name }}
103+
run: |
104+
AMD="${BASE_TAG}-amd64"
105+
ARM="${BASE_TAG}-arm64"
106+
107+
ARGS=""
108+
docker manifest inspect "$AMD" >/dev/null 2>&1 && ARGS="$ARGS $AMD"
109+
docker manifest inspect "$ARM" >/dev/null 2>&1 && ARGS="$ARGS $ARM"
110+
111+
if [ -z "$ARGS" ]; then
112+
echo "No arch images found for $BASE_TAG"
113+
exit 0
114+
fi
115+
116+
docker buildx imagetools create -t "$BASE_TAG" $ARGS
117+
docker buildx imagetools inspect "$BASE_TAG"

0 commit comments

Comments
 (0)