-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (198 loc) · 7.24 KB
/
release.yml
File metadata and controls
210 lines (198 loc) · 7.24 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: Release
on:
push:
tags:
- "v*"
pull_request:
jobs:
build:
name: Build release artifacts
strategy:
matrix:
include:
- os: ubuntu-22.04
relname: x86_64-linux
- os: ubuntu-22.04-arm
relname: arm64-linux
- os: macos-latest
relname: arm64-darwin
- os: macos-15-intel
relname: x86_64-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock', 'rust-toolchain.toml') }}-1
- name: Setup environment variables
run: |
echo "RUSTFLAGS=--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" >> $GITHUB_ENV
ver="v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name=="icp-cli-network-launcher") | .version')"
echo "VER=$ver" >> "$GITHUB_ENV"
- name: Verify version tag
if: ${{ github.ref_type == 'tag' }}
run: |
if [ "${GITHUB_REF_NAME}" != "${VER}" ]; then
echo "Tag ${GITHUB_REF_NAME} does not match package version ${VER}"
exit 1
fi
- name: Build and package
run: ./package.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ github.ref_type == 'tag' }}
with:
name: icp-cli-network-launcher-${{ matrix.relname }}-${{ github.ref_name }}
path: dist/icp-cli-network-launcher-${{ matrix.relname }}-${{ github.ref_name }}.tar.gz
aggregate:
name: build:required
runs-on: ubuntu-latest
needs: build
if: ${{ always() }}
steps:
- if: ${{ needs.build.result != 'success' }}
run: exit 1
release:
name: Create release
if: ${{ github.ref_type == 'tag' }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: icp-cli-network-launcher-*-${{ github.ref_name }}
merge-multiple: true
- name: Create release and upload assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "${{ github.ref_name }}" --repo "${{ github.repository }}" --prerelease icp-*.tar.*
docker-build:
name: "Build Docker image for ${{ matrix.platform }}"
if: ${{ github.ref_type == 'tag' }}
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch_tag: amd64
cache_suffix: cache-amd64
dockerfile: Dockerfile
- platform: linux/arm64
runner: ubuntu-22.04-arm
arch_tag: arm64
cache_suffix: cache-arm64
dockerfile: Dockerfile
- platform: linux/amd64
runner: ubuntu-latest
arch_tag: amd64-engine
cache_suffix: cache-amd64-engine
dockerfile: cloudengine.Dockerfile
- platform: linux/arm64
runner: ubuntu-22.04-arm
arch_tag: arm64-engine
cache_suffix: cache-arm64-engine
dockerfile: cloudengine.Dockerfile
steps:
- name: "Checkout code"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=${{ github.sha }},enable=true
- name: "Log in to GitHub Container Registry"
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: "Build and push ${{ matrix.platform }} image"
id: build
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
push: true
file: ${{ matrix.dockerfile }}
platforms: ${{ matrix.platform }}
tags: |
ghcr.io/${{ github.repository }}:${{ matrix.arch_tag }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:${{ matrix.cache_suffix }}
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:${{ matrix.cache_suffix }},mode=max,platform=${{ matrix.platform }}
build-args: |
BUILDKIT_INLINE_CACHE=1
docker-manifest:
name: "Create and push multi-arch manifest (${{ matrix.variant }})"
if: ${{ github.ref_type == 'tag' }}
needs: docker-build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- variant: standard
amd64_tag: amd64
arm64_tag: arm64
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=${{ github.sha }},enable=true
type=raw,value=latest,enable=true
- variant: engine
amd64_tag: amd64-engine
arm64_tag: arm64-engine
tags: |
type=semver,pattern={{version}},suffix=-engine
type=raw,value=engine-beta,enable=true
steps:
- name: "Checkout code"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: |
ghcr.io/${{ github.repository }}
tags: ${{ matrix.tags }}
- name: "Log in to GitHub Container Registry"
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Create and push multi-arch manifest"
uses: int128/docker-manifest-create-action@736aaa0f6ae97b2fb7f43e8dcef3ab47a02ea96e # v2.8.0
with:
tags: ${{ steps.meta.outputs.tags }}
sources: |
ghcr.io/${{ github.repository }}:${{ matrix.amd64_tag }}
ghcr.io/${{ github.repository }}:${{ matrix.arm64_tag }}