forked from cloudflare/workerd
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (166 loc) · 6.84 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
name: Build & Release
on:
push:
branches:
- main
jobs:
version:
outputs:
version: ${{ steps.echo.outputs.version }}
# version job uses ubuntu 22.04, this way we don't have to install the updated clang while
# the build job uses 20.04 for libc compatibility.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Cache
id: cache
uses: actions/cache@v3
with:
path: ~/bazel-disk-cache
key: capnp-cache-${{ runner.os }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }}
- 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 "::set-output name=version::1.$(bazel-bin/external/capnp-cpp/src/capnp/capnp_tool eval src/workerd/io/compatibility-date.capnp supportedCompatibilityDate | tr -d '-' | tr -d '"').0"
build:
strategy:
matrix:
os: [ubuntu-20.04, macos-latest, windows-2022]
include:
- os-name: linux
os: ubuntu-20.04
- os-name: macOS
os: macos-latest
- os-name: windows
os: windows-2022
runs-on: ${{ matrix.os }}
name: build (${{ matrix.os-name }})
steps:
- uses: actions/checkout@v3
- name: Cache
id: cache
uses: actions/cache@v3
with:
path: ~/bazel-disk-cache
# Use a different cache key than for tests here, otherwise the release cache could end up
# being used for test builds, where it provides little benefit.
key: bazel-disk-cache-release-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE') }}
- name: Setup Linux
if: runner.os == 'Linux'
run: |
export DEBIAN_FRONTEND=noninteractive
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 14
sudo apt-get install -y libunwind-14 libc++abi1-14 libc++1-14 libc++-14-dev
echo "build:linux --action_env=CC=/usr/lib/llvm-14/bin/clang --action_env=CXX=/usr/lib/llvm-14/bin/clang++" >> .bazelrc
echo "build:linux --host_action_env=CC=/usr/lib/llvm-14/bin/clang --host_action_env=CXX=/usr/lib/llvm-14/bin/clang++" >> .bazelrc
- name: Setup Windows
if: runner.os == 'Windows'
run: |
# Set a custom output root directory to avoid long file name issues.
[System.IO.File]::WriteAllLines((Join-Path -Path $env:USERPROFILE -ChildPath '.bazelrc'), 'startup --output_user_root=C:/tmp')
- name: Configure download mirrors
shell: bash
run: |
if [ ! -z "${{ secrets.WORKERS_MIRROR_URL }}" ] ; then
# Strip comment in front of WORKERS_MIRROR_URL, then substitute secret to use it.
sed -e '/WORKERS_MIRROR_URL/ { s@# *@@; s@WORKERS_MIRROR_URL@${{ secrets.WORKERS_MIRROR_URL }}@; }' -i.bak WORKSPACE
fi
- name: Bazel build
run: |
bazelisk build --disk_cache=~/bazel-disk-cache --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev -c opt //src/workerd/server:workerd
- name: Strip debug symbols
if: runner.os != 'Windows'
run: |
# bazel makes the output directory read-only, fix permissions for binary
chmod +w bazel-bin/src/workerd/server/workerd
# Strip debug information from the binary, this is acceptable as debug symbols are not
# generated for the release configuration. Regular symbols are still included.
strip -S bazel-bin/src/workerd/server/workerd
- name: Upload binary
uses: actions/[email protected]
with:
name: ${{ runner.os }}-${{ runner.arch }}-binary
path: bazel-bin/src/workerd/server/workerd${{ runner.os == 'Windows' && '.exe' || '' }}
check-tag:
name: Check tag is new
outputs:
exists: ${{ steps.check_tag.outputs.exists }}
needs: [version, build]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: mukunku/[email protected]
id: check_tag
with:
tag: v${{ needs.version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag-and-release:
name: Tag & Release
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
needs: [check-tag, version, build]
runs-on: ubuntu-latest
if: needs.check-tag.outputs.exists != 'true'
steps:
- run: echo ${{ needs.check-tag.outputs.exists }}
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git tag v${{ needs.version.outputs.version }} && git push origin v${{ needs.version.outputs.version }}
- uses: ncipollo/release-action@v1
id: create_release
with:
generateReleaseNotes: true
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ needs.version.outputs.version }}
upload-artifacts:
name: Upload Artifacts
needs: [tag-and-release]
runs-on: ubuntu-latest
strategy:
matrix:
arch: [linux-64, darwin-64, windows-64]
include:
- arch: linux-64
name: Linux-X64
- arch: darwin-64
name: macOS-X64
- arch: windows-64
name: Windows-X64
steps:
- name: Download ${{ matrix.name }}
uses: actions/[email protected]
with:
name: ${{ matrix.name }}-binary
path: /tmp
# Set execute permissions before compressing the binary
- if: matrix.arch != 'windows-64'
run: chmod +x /tmp/workerd
- name: Compress release binary
run: |
# As of release v1.20230404.0 the Linux x64 binary after debug_strip is 65.8 MB,
# 21.0 MB with gzip and 17.3 MB with brotli -9. Use gzip as a widely supported format
# which still produces an acceptable compressed size.
gzip -9N /tmp/workerd${{ matrix.arch == 'windows-64' && '.exe' || '' }}
- run: mv /tmp/workerd${{ matrix.arch == 'windows-64' && '.exe' || '' }}.gz /tmp/workerd-${{ matrix.arch }}.gz
# Upload compressed release binaries – one set of artifacts is sufficient with gzip being
# widely supported
- name: Upload Release Assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.tag-and-release.outputs.upload_url }}
asset_path: /tmp/workerd-${{ matrix.arch }}.gz
asset_name: workerd-${{ matrix.arch }}.gz
asset_content_type: application/gzip