-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (178 loc) · 5.78 KB
/
release.yml
File metadata and controls
190 lines (178 loc) · 5.78 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
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@v4
- uses: actions/cache@v3
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@v4
if: ${{ github.ref_type == 'tag' }}
with:
name: icp-cli-network-launcher-${{ matrix.relname }}-${{ env.VER }}
path: dist/icp-cli-network-launcher-${{ matrix.relname }}-${{ env.VER }}.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
strategy:
matrix:
relname: [x86_64-linux, arm64-linux, arm64-darwin, x86_64-darwin]
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: icp-cli-network-launcher-${{ matrix.relname }}-${{ github.ref_name }}
- name: Upload tarball and sha256
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: icp-*.tar.*
file_glob: true
tag: ${{ github.ref_name }}
prerelease: true
make_latest: false
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
- platform: linux/arm64
runner: ubuntu-22.04-arm
arch_tag: arm64
cache_suffix: cache-arm64
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@v5
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@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
with:
install: true
- name: "Build and push ${{ matrix.platform }} image"
id: build
uses: docker/build-push-action@v6
with:
push: true
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"
if: ${{ github.ref_type == 'tag' }}
needs: docker-build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Docker metadata"
id: meta
uses: docker/metadata-action@v5
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@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Create and push multi-arch manifest"
uses: int128/docker-manifest-create-action@v2.8.0
with:
tags: ${{ steps.meta.outputs.tags }}
sources: |
ghcr.io/${{ github.repository }}:amd64
ghcr.io/${{ github.repository }}:arm64