-
-
Notifications
You must be signed in to change notification settings - Fork 439
119 lines (109 loc) · 4.56 KB
/
publish-dev.yml
File metadata and controls
119 lines (109 loc) · 4.56 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
name: Publish dev release
# only one per github sha can be run
concurrency:
group: cd-publish-dev
on:
workflow_call:
permissions:
contents: write # Required for OIDC
id-token: write # Required to create a Github release
pull-requests: write # Required to add tags to pull requests
jobs:
npm:
name: Publish to NPM Registry
# To support npm provenance we must use github-hosted runners
runs-on: ubuntu-latest
steps:
# <common-build> - Uses YAML anchors in the future
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Install pnpm before setup node
uses: pnpm/action-setup@c5ba7f7862a0f64c1b1a05fbac13e0b8e86ba08c # v4
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
check-latest: true
cache: pnpm
- name: Node.js version
id: node
run: echo "v8CppApiVersion=$(node --print "process.versions.modules")" >> $GITHUB_OUTPUT
- name: Restore dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
id: cache-deps
with:
path: |
node_modules
packages/*/node_modules
key: ${{ runner.os }}-${{ steps.node.outputs.v8CppApiVersion }}-${{ hashFiles('**/pnpm-lock.yaml', '**/package.json') }}
- name: Install & build
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pnpm install --frozen-lockfile && pnpm build
- name: Build
run: pnpm build
if: steps.cache-deps.outputs.cache-hit == 'true'
# </common-build>
- name: Get version
id: version
run: |
PACKAGE_VERSION=$(node -p "require('./packages/cli/package.json').version")
NEXT_VERSION=$(npx --yes semver --increment minor $PACKAGE_VERSION)
export VERSION=${NEXT_VERSION}-dev.${GITHUB_SHA:0:10}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo PACKAGE_VERSION $PACKAGE_VERSION GITHUB_SHA $GITHUB_SHA VERSION $VERSION
- name: Change and commit version
# Write version before publishing so it's picked up by `lerna publish from-package`.
# It must also be committed to ensure a clean git tree, otherwise `lerna publish` errors.
# This "temp" commit doesn't change the actually release commit which is captured above.
# git-data is also correct, since it's generated at build time, before `lerna version` run.
run: |
pnpm lerna version ${{ steps.version.outputs.version }} \
--force-publish \
--exact \
--yes \
--no-git-tag-version
git config user.name 'temp'
git config user.email 'temp@github.com'
git commit -am "${{ steps.version.outputs.version }}"
- name: Publish to npm registry
# Note: before https://github.com/ChainSafe/lodestar/commit/28e2c74cf0f1bede8b09c8c9fec26f54b367e3fd
# We used `lerna publish --canary` option. However, since we now publish must version on branches,
# i.e. v0.35.x branch, lerna fails to detect the latest version and publishes canary versions as
# `0.34.0-dev.173+28e2c74cf0` instead of `0.36.0-dev.4+28e2c74cf0`, which creates confusion.
#
# --no-git-reset:
# Do not delete code version artifacts so the next step can pick the version
#
# --dist-tag next:
# Make this dev version installable with `@next`
#
# --preid dev:
# Tag version with `dev` instead of `alpha`
#
# --force-publish:
# lerna doesn't want to publish anything otherwise - "lerna success No changed packages
# to publish"
# --exact
# lerna will link the dependencies of monorepo packages without ^ operator as npm
# is apparently bad at resolving ^ dependencies of the canary versions. For e.g
# @chainsafe/lodestar@^0.34.0-dev.4 resolves to => 0.34.0
#
# NOTE: Using --preid dev.$(git rev-parse --short=7 HEAD) results in `0.24.3-dev.3ddb91d.0+3ddb91d`
run: |
pnpm lerna publish from-package \
--yes \
--no-verify-access \
--dist-tag next \
--no-git-reset \
--force-publish \
--exact
outputs:
version: ${{ steps.version.outputs.version }}
docker:
name: Publish to Docker Hub
needs: npm
uses: ./.github/workflows/docker.yml
with:
tag: next
secrets: inherit