-
Notifications
You must be signed in to change notification settings - Fork 44
126 lines (117 loc) · 3.74 KB
/
npm.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
name: Publish npm binary packages
on:
workflow_call:
inputs:
version:
description: 'version to label npm packages'
required: true
type: string
jobs:
publish-npm-binaries:
permissions:
contents: read
packages: read
runs-on: ubuntu-latest
strategy:
matrix:
build:
- target: aarch64-apple-darwin
node_arch: arm64
node_os: darwin
- target: x86_64-apple-darwin
node_arch: x64
node_os: darwin
- target: x86_64-unknown-linux-musl
node_arch: x64
node_os: linux
- target: aarch64-unknown-linux-musl
node_arch: arm64
node_os: linux
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: 'https://registry.npmjs.org'
- name: Download binary build from in-progress workflow
uses: actions/download-artifact@v4
with:
name: restate.${{ matrix.build.target }}.tar.gz
- name: Extract binaries
run: tar -xvzf restate.${{ matrix.build.target }}.tar.gz
- name: Publish to NPM
shell: bash
run: |
cd npm
for bin in restate restate-server
do
export node_os="${{ matrix.build.node_os }}"
export node_os
node_arch="${{ matrix.build.node_arch }}"
export node_arch
# set the version
node_version="${{ inputs.version }}"
node_version="${node_version#v}"
export node_version
# set the package name
export node_pkg="${bin}-${node_os}-${node_arch}"
if npm view "@restatedev/${node_pkg}@${node_version}"
then
continue
fi
# create the package directory
mkdir -p "${node_pkg}/bin"
# generate package.json from the template
envsubst < package.json.tmpl > "${node_pkg}/package.json"
# copy the binary into the package
cp "../${bin}" "${node_pkg}/bin"
cp ../NOTICE "${node_pkg}"
cp ../LICENSE "${node_pkg}"
cp ../README.md "${node_pkg}"
# publish the package
pushd "${node_pkg}"
npm publish --access public
popd
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-npm-base:
needs: publish-npm-binaries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
shell: bash
run: |
node_version="${{ inputs.version }}"
node_version="${node_version#v}"
cd npm
for bin in restate restate-server
do
if npm view "@restatedev/${bin}@${node_version}"
then
continue
fi
pushd "${bin}"
sed -i "s/\"version\": \".*\",/\"version\": \"${node_version}\",/" package.json
for os in linux darwin
do
for arch in x64 arm64
do
sed -i "s|\"@restatedev/${bin}-${os}-${arch}\": \".*\"|\"@restatedev/${bin}-${os}-${arch}\": \"${node_version}\"|" package.json
done
done
curl https://raw.githubusercontent.com/restatedev/restate/main/README.md -o README.md
npm install
npm run build
npm publish --access public
popd
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}