-
-
Notifications
You must be signed in to change notification settings - Fork 290
169 lines (147 loc) Β· 5.42 KB
/
publish-stable.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
name: Publish stable release
# only one can tun at a time
concurrency: cd-publish-stable
# See for rationale https://github.com/ChainSafe/lodestar/blob/unstable/RELEASE.md
on:
push:
tags:
- v*
jobs:
tag:
name: Check tag
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get tag
id: get_tag
run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Assert tag == package.json version
run: .github/workflows/scripts/assert-same-package-version.sh
env:
TAG: ${{ steps.get_tag.outputs.tag }}
- name: Get previous tag
id: get_prev_tag
run: node scripts/get_prev_tag.js
env:
CURRENT_TAG: ${{ steps.get_tag.outputs.tag }}
IGNORE_PATTERN: rc
- name: Determine release type
id: release_type
run: |
STABLE_COMMIT=$(git log --pretty="%h" -n 1 refs/remotes/origin/stable)
TAG_COMMIT=$(git log --pretty="%h" -n 1 $GITHUB_REF)
echo "stable_commit=$STABLE_COMMIT" >> $GITHUB_OUTPUT
echo "tag_commit=$TAG_COMMIT" >> $GITHUB_OUTPUT
outputs:
is_stable: ${{ steps.release_type.outputs.stable_commit == steps.release_type.outputs.tag_commit }}
tag: ${{ steps.get_tag.outputs.tag }}
prev_tag: ${{ steps.get_prev_tag.outputs.prev_tag }}
binaries:
name: Build lodestar binaries
uses: ./.github/workflows/binaries.yml
needs: tag
with:
version: ${{ needs.tag.outputs.tag }}
npm:
name: Publish to NPM & Github
runs-on: buildjet-4vcpu-ubuntu-2204
needs: [tag, binaries]
if: needs.tag.outputs.is_stable == 'true'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needs full depth for changelog generation
- uses: "./.github/actions/setup-and-build"
with:
node: 22.4
- name: Generate changelog
run: node scripts/generate_changelog.mjs ${{ needs.tag.outputs.prev_tag }} ${{ needs.tag.outputs.tag }} CHANGELOG.md
- name: Get binaries
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*
fail_on_unmatched_files: true
tag_name: ${{ needs.tag.outputs.tag }}
body_path: "CHANGELOG.md"
name: Release ${{ needs.tag.outputs.tag }}
prerelease: false
# From https://github.com/lerna/lerna/issues/2404
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm registry (release)
run: yarn run release:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# In case of failure
- name: Rollback on failure
if: failure()
uses: author/action-rollback@9ec72a6af74774e00343c6de3e946b0901c23013
with:
id: ${{ steps.create_release.outputs.id }}
tag: ${{ needs.tag.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment:
name: Comment on included PRs
runs-on: buildjet-4vcpu-ubuntu-2204
needs: [tag, npm]
if: needs.tag.outputs.is_stable == 'true'
steps:
- uses: nflaig/release-comment-on-pr@v1
with:
token: ${{ secrets.GH_PAGES_TOKEN }}
docker:
name: Publish to Docker Hub
runs-on: buildjet-4vcpu-ubuntu-2204
needs: [tag, npm]
if: needs.tag.outputs.is_stable == 'true'
steps:
- uses: actions/checkout@v4
- run: scripts/await-release.sh ${{ needs.tag.outputs.tag }} latest 900
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
run: >
docker buildx build . --push
--tag chainsafe/lodestar:latest
--tag chainsafe/lodestar:${{ needs.tag.outputs.tag }}
--platform linux/amd64,linux/arm64
--build-arg COMMIT=$(git rev-parse HEAD)
- run: docker run chainsafe/lodestar:${{ needs.tag.outputs.tag }} --help
# Display history to know byte size of each layer
# Image is available only because of the previous `docker run` command
- run: docker image history chainsafe/lodestar:${{ needs.tag.outputs.tag }}
- name: Build and push custom Grafana
run: >
docker buildx build ./docker/grafana/ --push
--file ./docker/grafana/Dockerfile
--build-context dashboards=./dashboards
--tag chainsafe/lodestar-grafana:${{ needs.tag.outputs.tag }}
--platform linux/amd64,linux/arm64
- name: Build and push custom Prometheus
run: >
docker buildx build ./docker/prometheus/ --push
--file ./docker/prometheus/Dockerfile
--tag chainsafe/lodestar-prometheus:${{ needs.tag.outputs.tag }}
--platform linux/amd64,linux/arm64