forked from protolambda/erigon
-
Notifications
You must be signed in to change notification settings - Fork 16
232 lines (212 loc) · 10.8 KB
/
release.yml
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Release
env:
APPLICATION: "op-erigon"
BUILDER_IMAGE: "golang:1.22-bookworm"
DOCKER_BASE_IMAGE: "debian:12.7-slim"
APP_REPO: "testinprod-io/op-erigon"
PACKAGE: "github.com/testinprod-io/op-erigon"
DOCKERHUB_REPOSITORY: "testinprod/op-erigon"
DOCKERFILE_PATH: "Dockerfile.release"
LABEL_DESCRIPTION: "Erigon is an implementation of Ethereum (execution layer with embeddable consensus layer), on the efficiency frontier. Archive Node by default."
on:
workflow_dispatch:
inputs:
checkout_ref:
required: true
type: string
default: 'op-erigon'
description: 'The branch to checkout and build artifacts from. By default "op-erigon".'
release_version:
required: true
type: string
description: 'Release version number (Pattern - v#.#.# , f.e. v2.60.1 or v3.0.0 or v3.0.0-alpha1 for pre-releases. Use prefix "v".)'
perform_release:
required: false
type: boolean
default: false
description: 'perform_release: when set then all artifacts will be published and the DRAFT of the release
notes will be created.'
publish_latest_tag:
required: false
type: boolean
default: false
description: 'publish_latest_tag: when set then docker image with tag :latest will be also published'
jobs:
build-release:
#runs-on: ubuntu-latest-devops-xxlarge
runs-on: ubuntu-latest
timeout-minutes: 60
name: Build Artifacts and multi-platform Docker image, publish draft of the Release Notes
steps:
- name: Checkout git repository ${{ env.APP_REPO }}
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 ## 4.1.7 release
with:
repository: ${{ env.APP_REPO }}
fetch-depth: 0
ref: ${{ inputs.checkout_ref }}
path: 'erigon'
- name: Check if tag ${{ inputs.release_version }} already exists in case perform_release is set.
if: ${{ (inputs.perform_release) && (inputs.release_version != '') }}
run: |
if git ls-remote --exit-code --quiet --tags origin '${{ inputs.release_version }}'; then
echo "ERROR: tag ${{ inputs.release_version }} exists and workflow is performing release. Exit."
exit 1
else
echo "OK: tag ${{ inputs.release_version }} does not exists. Proceeding."
fi
- name: Run some commands, get commit id
id: getCommitId
run: |
mkdir $GITHUB_WORKSPACE/build-arm64 $GITHUB_WORKSPACE/build-amd64 $GITHUB_WORKSPACE/build-amd64v2
echo "id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "short_commit_id=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
echo "week_of_the_year=$(/bin/date -u "+%Y-%W")" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB }}
password: ${{ secrets.DOCKERHUB_KEY }}
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf ## v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db ## v3.6.1
- name: Setup GO build and pkg cache for one week only
id: cache
uses: actions/cache@v4
with:
key: cache-year-week-${{ steps.getCommitId.outputs.week_of_the_year }}-go.mod-hash:${{ hashFiles('erigon/go.mod') }}
path: |
~/go/pkg
~/.cache
- name: Build for linux/arm64
run: >
docker run --platform linux/arm64
--rm
-v $(pwd)/erigon:/erigon:ro
-v ${GITHUB_WORKSPACE}/build-arm64:/erigon-build
-v ${HOME}/.cache:/root/.cache
-v ${HOME}/go/pkg/mod:/go/pkg/mod
-w /erigon --entrypoint /bin/bash
${{ env.BUILDER_IMAGE }}
-c "git config --global --add safe.directory /erigon;
make GOARCH=arm64 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb,nosilkworm
erigon downloader devnet evm caplin diag integration rpcdaemon sentry txpool"
- name: Build for linux/amd64
run: >
docker run --platform linux/amd64
--rm
-v $(pwd)/erigon:/erigon:ro
-v ${GITHUB_WORKSPACE}/build-amd64:/erigon-build
-v ${HOME}/.cache:/root/.cache
-v ${HOME}/go/pkg/mod:/go/pkg/mod
-w /erigon --entrypoint /bin/bash
${{ env.BUILDER_IMAGE }}
-c "git config --global --add safe.directory /erigon;
make GOARCH=amd64 GOAMD64=v1 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb
erigon downloader devnet evm caplin diag integration rpcdaemon sentry txpool;
find / -name libsilkworm_capi.so -exec install {} /erigon-build \; "
- name: Build for linux/amd64/v2
run: >
docker run --platform linux/amd64/v2
--rm
-v $(pwd)/erigon:/erigon:ro
-v ${GITHUB_WORKSPACE}/build-amd64v2:/erigon-build
-v ${HOME}/.cache:/root/.cache
-v ${HOME}/go/pkg/mod:/go/pkg/mod
-w /erigon --entrypoint /bin/bash
${{ env.BUILDER_IMAGE }}
-c "git config --global --add safe.directory /erigon;
make GOARCH=amd64 GOAMD64=v2 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb
erigon downloader devnet evm caplin diag integration rpcdaemon sentry txpool;
find / -name libsilkworm_capi.so -exec install {} /erigon-build \; "
- name: Create archives and checksums
env:
RELEASE_VERSION: ${{ inputs.release_version }}
run: |
cd ${GITHUB_WORKSPACE}
mkdir $GITHUB_WORKSPACE/release
for dir in build-*; do
cd $dir
echo Current directory is $(pwd) . Checksum file and archive will be created for this directory
sha256sum * > checksums.txt
tar czvf $GITHUB_WORKSPACE/release/${APPLICATION}_${RELEASE_VERSION}_linux_$(echo $dir | sed 's,build-,,').tar.gz \
--transform "s,^./,${APPLICATION}_${RELEASE_VERSION}_linux_$(echo $dir | sed 's,build-,,')/," .
cd -
done
cd $GITHUB_WORKSPACE/release
sha256sum * > ${APPLICATION}_${RELEASE_VERSION}_checksums.txt
echo Content of release directory:
find . -type f -ls
- name: Build and push multi-platform docker images (${{ env.BUILD_VERSION }} and latest) in case perform_release is true
if: ${{ inputs.perform_release }}
env:
BUILD_VERSION: ${{ inputs.release_version }}
DOCKER_URL: ${{ env.DOCKERHUB_REPOSITORY }}
DOCKER_PUBLISH_LATEST_CONDITION: ${{ inputs.publish_latest_tag && format('--tag {0}:latest ',env.DOCKERHUB_REPOSITORY) || '' }}
run: |
cd ${GITHUB_WORKSPACE}/release
echo "Current directory is $(pwd) ."
docker buildx build \
--file ${{ github.workspace }}/erigon/${{ env.DOCKERFILE_PATH }} \
--build-arg RELEASE_DOCKER_BASE_IMAGE=${{ env.DOCKER_BASE_IMAGE }} \
--build-arg VERSION=${{ env.BUILD_VERSION }} \
--build-arg APPLICATION=${{ env.APPLICATION }} \
--tag ${{ env.DOCKER_URL }}:${{ env.BUILD_VERSION }} \
${{ env.DOCKER_PUBLISH_LATEST_CONDITION }} \
--target release \
--attest type=provenance,mode=max \
--sbom=true \
--label org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--label org.opencontainers.image.authors="https://github.com/testinprod-io/op-erigon/graphs/contributors" \
--label org.opencontainers.image.url="https://github.com/testinprod-io/op-erigon/blob/main/Dockerfile" \
--label org.opencontainers.image.documentation="https://github.com/testinprod-io/op-erigon/blob/main/Dockerfile" \
--label org.opencontainers.image.source="https://github.com/testinprod-io/op-erigon/blob/main/Dockerfile" \
--label org.opencontainers.image.version=${{ inputs.release_version }} \
--label org.opencontainers.image.revision=${{ steps.getCommitId.outputs.id }} \
--label org.opencontainers.image.vcs-ref-short=${{ steps.getCommitId.outputs.short_commit_id }} \
--label org.opencontainers.image.vendor="${{ github.repository_owner }}" \
--label org.opencontainers.image.description="${{ env.LABEL_DESCRIPTION }}" \
--label org.opencontainers.image.base.name="${{ env.DOCKER_BASE_IMAGE }}" \
--push \
--platform linux/amd64,linux/amd64/v2,linux/arm64 .
- name: Upload artifact -- linux/arm64
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a ## v4.3.6
with:
name: ${{ env.APPLICATION }}_${{ inputs.release_version }}_linux_arm64.tar.gz
path: ${{ github.workspace }}/release/${{ env.APPLICATION }}_${{ inputs.release_version }}_linux_arm64.tar.gz
retention-days: 1
compression-level: 0
if-no-files-found: error
- name: Upload artifact -- linux/amd64
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a ## v4.3.6
with:
name: ${{ env.APPLICATION }}_${{ inputs.release_version }}_linux_amd64.tar.gz
path: ${{ github.workspace }}/release/${{ env.APPLICATION }}_${{ inputs.release_version }}_linux_amd64.tar.gz
retention-days: 1
compression-level: 0
if-no-files-found: error
- name: Upload artifact -- linux/amd64/v2
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a ## v4.3.6
with:
name: ${{ env.APPLICATION }}_${{ inputs.release_version }}_linux_amd64v2.tar.gz
path: ${{ github.workspace }}/release/${{ env.APPLICATION }}_${{ inputs.release_version }}_linux_amd64v2.tar.gz
retention-days: 1
compression-level: 0
if-no-files-found: error
- name: Publish draft of the Release Notes with assets in case perform_release is set
if: ${{ inputs.perform_release }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
DOCKER_TAGS: ${{ env.DOCKERHUB_REPOSITORY }}:${{ inputs.release_version }}
GITHUB_RELEASE_TARGET: ${{ inputs.checkout_ref }}
run: |
cd $GITHUB_WORKSPACE/release
gh release create \
--generate-notes \
--target ${GITHUB_RELEASE_TARGET} \
--draft=true \
--title "${{ inputs.release_version }}" \
--notes "**Improvements:**<br>- ...coming soon <br><br>**Bugfixes:**<br><br>- ...coming soon<br><br>**Docker images:**<br><br>Docker image released:<br> ${{ env.DOCKER_TAGS }}<br><br>... coming soon<br>" \
${{ inputs.release_version }} \
*.tar.gz ${{ env.APPLICATION }}_${{ inputs.release_version }}_checksums.txt