-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (164 loc) · 5.74 KB
/
Copy pathrelease-s390x.yaml
File metadata and controls
193 lines (164 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Release s390x
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.5)'
required: true
type: string
permissions:
contents: write
packages: write
concurrency:
group: release-s390x-${{ github.event.inputs.version || github.ref }}
cancel-in-progress: false
env:
GHCR_IMAGE: ghcr.io/${{ github.repository }}
UPSTREAM_IMAGE: docker.io/rancher/system-agent
jobs:
build-binary:
runs-on: self-hosted
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.version.outputs.version }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build s390x binary
env:
GOOS: linux
GOARCH: s390x
CGO_ENABLED: "0"
run: |
go build -ldflags "-s -w -X main.Version=${{ steps.version.outputs.version }}" \
-o bin/rancher-system-agent ./
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: binary-s390x
path: bin/rancher-system-agent
if-no-files-found: error
github-release:
runs-on: self-hosted
needs: build-binary
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Download binary
uses: actions/download-artifact@v4
with:
name: binary-s390x
path: dist
- name: Rename and generate checksums
working-directory: dist
run: |
mv rancher-system-agent rancher-system-agent-s390x
sha256sum rancher-system-agent-s390x > sha256sum-s390x.txt
cat sha256sum-s390x.txt
- name: Create or update GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ needs.build-binary.outputs.version }}"
# Check if release exists
if gh release view "$VERSION" >/dev/null 2>&1; then
echo "Release $VERSION exists, uploading s390x assets..."
gh release upload "$VERSION" dist/* --clobber
else
echo "Creating release $VERSION..."
gh release create "$VERSION" \
--title "Release $VERSION" \
--notes "s390x binary release synced from rancher/system-agent $VERSION" \
dist/*
fi
build-push-s390x-image:
runs-on: self-hosted
needs: build-binary
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binary
uses: actions/download-artifact@v4
with:
name: binary-s390x
path: bin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push s390x image
uses: docker/build-push-action@v5
with:
context: .
file: package/Dockerfile
platforms: linux/s390x
push: true
tags: |
${{ env.GHCR_IMAGE }}:${{ needs.build-binary.outputs.version }}-s390x
create-multiarch-manifest:
runs-on: self-hosted
needs: [build-binary, build-push-s390x-image]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch manifest
env:
VERSION: ${{ needs.build-binary.outputs.version }}
run: |
echo "Creating multi-arch manifest for $VERSION"
# Upstream publishes single multi-arch manifest - extract platform digests
AMD64_DIGEST=$(docker buildx imagetools inspect ${{ env.UPSTREAM_IMAGE }}:${VERSION} --raw | \
jq -r '.manifests[] | select(.platform.architecture=="amd64" and .platform.os=="linux") | .digest')
ARM64_DIGEST=$(docker buildx imagetools inspect ${{ env.UPSTREAM_IMAGE }}:${VERSION} --raw | \
jq -r '.manifests[] | select(.platform.architecture=="arm64" and .platform.os=="linux") | .digest')
echo "amd64 digest: $AMD64_DIGEST"
echo "arm64 digest: $ARM64_DIGEST"
if [ -z "$AMD64_DIGEST" ] || [ -z "$ARM64_DIGEST" ]; then
echo "::error::Failed to extract upstream digests"
exit 1
fi
# Combine upstream platform images with our s390x image
docker buildx imagetools create \
-t ${{ env.GHCR_IMAGE }}:${VERSION} \
-t ${{ env.GHCR_IMAGE }}:latest \
${{ env.UPSTREAM_IMAGE }}@${AMD64_DIGEST} \
${{ env.UPSTREAM_IMAGE }}@${ARM64_DIGEST} \
${{ env.GHCR_IMAGE }}:${VERSION}-s390x
- name: Inspect manifest
env:
VERSION: ${{ needs.build-binary.outputs.version }}
run: |
docker buildx imagetools inspect ${{ env.GHCR_IMAGE }}:${VERSION}