-
Notifications
You must be signed in to change notification settings - Fork 26
198 lines (182 loc) · 8.73 KB
/
release.yaml
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
name: Build and release binaries
on:
workflow_dispatch:
inputs:
ref:
description: "Git REF to use for manual pre-release. Keep it empty to use the workflow branch."
required: false
type: string
prerelease_suffix:
description: "Suffix which has been used for manual pre-release name"
required: false
type: string
default: "notag"
release_macos_amd64:
description: "Release for MacOS amd64?"
required: false
type: boolean
default: true
release_macos_arm64:
description: "Release for MacOS arm64?"
required: false
type: boolean
default: true
release_linux_amd64_musl:
description: "Release for Linux amd64 musl?"
required: false
type: boolean
default: true
release_linux_arm64_musl:
description: "Release for Linux arm64 musl?"
required: false
type: boolean
default: true
release_linux_amd64_gnu:
description: "Release for Linux amd64 gnu?"
required: false
type: boolean
default: true
release_linux_arm64_gnu:
description: "Release for Linux arm64 gnu?"
required: false
type: boolean
default: true
release_windows_amd64:
description: "Release for Windows amd64?"
required: false
type: boolean
default: true
push:
tags:
- "*.*.*"
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.prepare-matrix.outputs.matrix }}
steps:
- name: Prepare matrix
id: prepare-matrix
run: |
# Define general matrix parameters
WINDOWS='{"name":"Windows","runner":"windows-2022-github-hosted-64core","release-suffix":"windows-amd64-gnu"}'
MACOS_AMD64='{"name":"MacOS-x86","runner":"macos-12-large","release-suffix":"macosx-amd64"}'
MACOS_ARM64='{"name":"MacOS-arm64","runner":["self-hosted","macOS","ARM64"],"release-suffix":"macosx-arm64"}'
LINUX_AMD64_GNU='{"name":"Linux-AMD64-gnu","runner":"matterlabs-ci-runner-high-performance","image":"ghcr.io/matter-labs/zksync-llvm-runner:latest","target":"x86_64-unknown-linux-gnu","release-suffix":"linux-amd64-gnu"}'
LINUX_ARM64_GNU='{"name":"Linux-ARM64-gnu","runner":"matterlabs-ci-runner-arm","image":"ghcr.io/matter-labs/zksync-llvm-runner:latest","target":"aarch64-unknown-linux-gnu","release-suffix":"linux-arm64-gnu"}'
LINUX_AMD64_MUSL='{"name":"Linux-AMD64-musl","runner":"matterlabs-ci-runner-high-performance","image":"ghcr.io/matter-labs/zksync-llvm-runner:latest","target":"x86_64-unknown-linux-musl","release-suffix":"linux-amd64-musl"}'
LINUX_ARM64_MUSL='{"name":"Linux-ARM64-musl","runner":"matterlabs-ci-runner-arm","image":"ghcr.io/matter-labs/zksync-llvm-runner:latest","target":"aarch64-unknown-linux-musl","release-suffix":"linux-arm64-musl"}'
# Disable platforms for non-tag builds if user requested
if [ ${GITHUB_REF_TYPE} != tag ]; then
[ ${{ github.event.inputs.release_windows_amd64 }} != true ] && WINDOWS=
[ ${{ github.event.inputs.release_macos_amd64 }} != true ] && MACOS_AMD64=
[ ${{ github.event.inputs.release_macos_arm64 }} != true ] && MACOS_ARM64=
[ ${{ github.event.inputs.release_linux_amd64_gnu }} != true ] && LINUX_AMD64_GNU=
[ ${{ github.event.inputs.release_linux_arm64_gnu }} != true ] && LINUX_ARM64_GNU=
[ ${{ github.event.inputs.release_linux_amd64_musl }} != true ] && LINUX_AMD64_MUSL=
[ ${{ github.event.inputs.release_linux_arm64_musl }} != true ] && LINUX_ARM64_MUSL=
fi
PLATFORMS=(${WINDOWS} ${MACOS_AMD64} ${MACOS_ARM64} ${LINUX_AMD64_GNU} ${LINUX_ARM64_GNU} ${LINUX_AMD64_MUSL} ${LINUX_ARM64_MUSL})
echo "matrix={ \"include\": [ $(IFS=, ; echo "${PLATFORMS[*]}") ] }" | tee -a "${GITHUB_OUTPUT}"
build:
needs: prepare-matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.image || '' }} # Special workaround to allow matrix builds with optional container
name: ${{ matrix.name }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || '' }}
- name: Prepare Windows env
if: runner.os == 'Windows'
uses: matter-labs/era-compiler-ci/.github/actions/prepare-msys@v1
- name: Build LLVM
uses: matter-labs/era-compiler-ci/.github/actions/build-llvm@v1
with:
target-env: ${{ contains(matrix.target, 'musl') && 'musl' || 'gnu' }}
enable-assertions: 'false'
build-type: Release
ccache-key: ${{ format('llvm-{0}-{1}-{2}', runner.os, runner.arch, contains(matrix.target, 'musl') && 'musl' || 'gnu') }}
save-ccache: 'false'
- name: Build zksolc
uses: ./.github/actions/build
with:
target: ${{ matrix.target }}
release-suffix: ${{ format('{0}-{1}', matrix.release-suffix, inputs.prerelease_suffix || format('v{0}', github.ref_name)) }}
prepare-release:
name: Prepare release
runs-on: matterlabs-ci-runner-high-performance
container:
image: ghcr.io/matter-labs/zksync-llvm-runner:latest
needs: build
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || '' }}
- name: Get changelog
if: github.ref_type == 'tag'
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_level: warn
path: ./CHANGELOG.md
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: release*
path: releases
- name: Identify release name
id: release
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
if [ '${{ github.event_name }}' = 'workflow_dispatch' ]; then
VERSION_OR_SHA=$(git rev-parse --short HEAD)
echo "version_or_sha=${VERSION_OR_SHA}" >> $GITHUB_OUTPUT
echo "full_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "release_title=prerelease-${VERSION_OR_SHA}-${{ github.event.inputs.prerelease_suffix }}" >> $GITHUB_OUTPUT
else
VERSION_OR_SHA="${GITHUB_REF#refs/tags/}"
echo "version_or_sha=${VERSION_OR_SHA}" >> $GITHUB_OUTPUT
echo "release_title=${VERSION_OR_SHA}" >> $GITHUB_OUTPUT
fi
- name: Check release version
if: github.ref_type == 'tag'
run: |
TAG="${{ steps.release.outputs.version_or_sha }}"
CARGO_PACKAGE_VERSION="$(cargo pkgid --manifest-path era-compiler-solidity/Cargo.toml | cut -d "#" -f2)"
CHANGELOG_VERSION="${{ steps.changelog_reader.outputs.version }}"
# All versions must be equal
if [ "${CARGO_PACKAGE_VERSION}" != "${TAG}" ] || [ "${CARGO_PACKAGE_VERSION}" != "${CHANGELOG_VERSION}" ]; then
echo "Version mismatch: TAG=${TAG}, CARGO_PACKAGE_VERSION=${CARGO_PACKAGE_VERSION}, CHANGELOG_VERSION=${CHANGELOG_VERSION}"
echo "Please update the version in Cargo.toml, CHANGELOG.md and tag the commit with the same version."
exit 1
fi
- name: Prepare universal macos binary
if: github.ref_type == 'tag' || (inputs.release_macos_amd64 && inputs.release_macos_arm64)
env:
MACOSX_UNIVERSAL_SUFFIX: "macosx"
RELEASE_SUFFIX: ${{ inputs.prerelease_suffix || format('v{0}', github.ref_name) }}
run: |
OUTDIR="./releases/release-${MACOSX_UNIVERSAL_SUFFIX}-${RELEASE_SUFFIX}/${MACOSX_UNIVERSAL_SUFFIX}-${RELEASE_SUFFIX}"
mkdir -p "${OUTDIR}"
OUTPUT="${OUTDIR}/zksolc-${MACOSX_UNIVERSAL_SUFFIX}-${RELEASE_SUFFIX}"
llvm-lipo -create -output "${OUTPUT}" \
./releases/release-macosx-amd64-${RELEASE_SUFFIX}/macosx-amd64-${RELEASE_SUFFIX}/zksolc-macosx-amd64-${RELEASE_SUFFIX} \
./releases/release-macosx-arm64-${RELEASE_SUFFIX}/macosx-arm64-${RELEASE_SUFFIX}/zksolc-macosx-arm64-${RELEASE_SUFFIX}
- name: Prepare release
uses: softprops/action-gh-release@v2
with:
name: ${{ steps.release.outputs.release_title }}
body: ${{ steps.changelog_reader.outputs.changes }}
generate_release_notes: false
tag_name: ${{ steps.release.outputs.version_or_sha }}
target_commitish: ${{ steps.release.outputs.full_sha }}
prerelease: true
files: releases/**/**