Skip to content

Merge pull request #732 from cloudflare/felix/web-compression-errors #4

Merge pull request #732 from cloudflare/felix/web-compression-errors

Merge pull request #732 from cloudflare/felix/web-compression-errors #4

Workflow file for this run

name: Build & Release
on:
push:
branches:
- main
jobs:
version:
outputs:
version: ${{ steps.echo.outputs.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 "::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:
# TODO(soon): Using windows-2019 as build is broken on windows-latest runner, develop a
# fix and go back to the latest version
os: [ubuntu-22.04, macos-latest, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Cache
id: cache
uses: actions/cache@v2
with:
path: ~/bazel-disk-cache
key: ${{ runner.os }}-${{ runner.arch }}-bazel-disk-cache
- name: Setup Linux
if: runner.os == 'Linux'
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get install -y build-essential git clang libc++-dev
- name: Setup Windows
if: runner.os == 'Windows'
run: |
[System.IO.File]::WriteAllLines((Join-Path -Path $env:USERPROFILE -ChildPath '.bazelrc'), 'startup --output_user_root=C:/tmp')
- 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/upload-artifact@v3.1.0
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/tag-exists-action@v1.1.0
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/download-artifact@v3.0.0
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