forked from cloudflare/workerd
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (124 loc) · 6.17 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
127
128
129
130
name: Publish to NPM
on:
# Since we still need to manually upload binaries, use manual run
# Ideally this would trigger off `release`
workflow_dispatch:
inputs:
patch:
description: 'Patch Version'
required: true
default: '0'
prerelease:
description: 'Is Prerelease'
type: boolean
default: false
jobs:
version:
outputs:
version: ${{ steps.echo.outputs.version }}
date: ${{ steps.echo.outputs.date }}
release_version: ${{ steps.echo.outputs.release_version }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: bazelbuild/setup-bazelisk@v2
- name: Cache
id: cache
uses: actions/cache@v2
with:
path: ~/bazel-disk-cache
key: capnp-cache
- name: build capnp
run: |
bazel build --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev @capnp-cpp//src/capnp:capnp_tool
- id: echo
run: |
echo "date=$(bazel-bin/external/capnp-cpp/src/capnp/capnp_tool eval src/workerd/io/compatibility-date.capnp supportedCompatibilityDate | tr -d '"')" >> $GITHUB_OUTPUT;
echo "version=${{ inputs.prerelease == false && '1' || '0'}}.$(bazel-bin/external/capnp-cpp/src/capnp/capnp_tool eval src/workerd/io/compatibility-date.capnp supportedCompatibilityDate | tr -d '-' | tr -d '"').${{ inputs.patch }}" >> $GITHUB_OUTPUT;
echo "release_version=1.$(bazel-bin/external/capnp-cpp/src/capnp/capnp_tool eval src/workerd/io/compatibility-date.capnp supportedCompatibilityDate | tr -d '-' | tr -d '"').0" >> $GITHUB_OUTPUT;
publish-arch-specific:
# if: github.repository_owner == 'cloudflare'
name: Publish arch-specific packages to npm
needs: version
runs-on: ubuntu-latest
strategy:
matrix:
arch: [darwin-64, darwin-arm64, linux-64, linux-arm64, windows-64]
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Modify package.json version
run: node npm/scripts/bump-version.mjs npm/workerd-${{ matrix.arch }}/package.json
env:
WORKERD_VERSION: ${{ needs.version.outputs.version }}
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }}
- uses: robinraju/[email protected]
with:
tag: v${{ needs.version.outputs.release_version }}
fileName: workerd-${{ matrix.arch }}.gz
tarBall: false
zipBall: false
out-file-path: "release-downloads"
token: ${{ secrets.GITHUB_TOKEN }}
# release-downloader does not support .gz files (unlike .tar.gz), decompress manually
# Using the -N flag the right file name should be restored
- run: gzip -dN $GITHUB_WORKSPACE/release-downloads/workerd-${{ matrix.arch }}.gz
- run: chmod +x $GITHUB_WORKSPACE/release-downloads/workerd
if: matrix.arch != 'windows-64'
- run: mkdir npm/workerd-${{ matrix.arch }}/bin
- run: cp $GITHUB_WORKSPACE/release-downloads/workerd${{ matrix.arch == 'windows-64' && '.exe' || '' }} npm/workerd-${{ matrix.arch }}/bin/workerd${{ matrix.arch == 'windows-64' && '.exe' || '' }}
- run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > npm/workerd-${{ matrix.arch }}/.npmrc
- run: cd npm/workerd-${{ matrix.arch }} && npm publish --access public --tag ${{ inputs.prerelease == true && 'beta' || 'latest'}}
env:
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
publish-wrapper:
# if: github.repository_owner == 'cloudflare'
name: Publish `workerd` to NPM
needs: [version, publish-arch-specific]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Modify package.json version
run: node npm/scripts/bump-version.mjs npm/workerd/package.json
env:
WORKERD_VERSION: ${{ needs.version.outputs.version }}
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }}
- run: mkdir -p npm/workerd/lib
- run: mkdir -p npm/workerd/bin
- name: Build node-install
run: npx esbuild npm/lib/node-install.ts --outfile=npm/workerd/install.js --bundle --target=node16 --define:LATEST_COMPATIBILITY_DATE="\"${LATEST_COMPATIBILITY_DATE}\"" --define:WORKERD_VERSION="\"${WORKERD_VERSION}\"" --platform=node --external:workerd --log-level=warning
env:
WORKERD_VERSION: ${{ needs.version.outputs.version }}
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }}
- name: Build node-shim
run: npx esbuild npm/lib/node-shim.ts --outfile=npm/workerd/bin/workerd --bundle --target=node16 --define:LATEST_COMPATIBILITY_DATE="\"${LATEST_COMPATIBILITY_DATE}\"" --define:WORKERD_VERSION="\"${WORKERD_VERSION}\"" --platform=node --external:workerd --log-level=warning
env:
WORKERD_VERSION: ${{ needs.version.outputs.version }}
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }}
- name: Build node-path
run: npx esbuild npm/lib/node-path.ts --outfile=npm/workerd/lib/main.js --bundle --target=node16 --define:LATEST_COMPATIBILITY_DATE="\"${LATEST_COMPATIBILITY_DATE}\"" --define:WORKERD_VERSION="\"${WORKERD_VERSION}\"" --platform=node --external:workerd --log-level=warning
env:
WORKERD_VERSION: ${{ needs.version.outputs.version }}
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }}
- name: Build package
run: node npm/scripts/build-shim-package.mjs
env:
WORKERD_VERSION: ${{ needs.version.outputs.version }}
LATEST_COMPATIBILITY_DATE: ${{ needs.version.outputs.date }}
- run: echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > npm/workerd/.npmrc
- run: cd npm/workerd && npm publish --access public --tag ${{ inputs.prerelease == true && 'beta' || 'latest'}}
env:
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}