mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 18:05:37 +02:00
There were two problems: - Writing the date on Windows used the wrong syntax. In Powershell, env variables are addressed as $env:NAME, not $NAME. - Use different caches for opt vs fastbuild. We are currently using opt caches for fastbuilds, which results in lots of cache misses.
143 lines
4.8 KiB
YAML
143 lines
4.8 KiB
YAML
name: Create Release
|
|
|
|
on:
|
|
push:
|
|
# Note: It's branch main OR tags v*, not AND! Tags are not per-branch.
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
Build-And-Test-Linux:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Initialize submodules
|
|
run: git submodule update --init --recursive
|
|
|
|
- name: Create timestamp
|
|
run: |
|
|
printf -v date '%(%Y-%m)T' -1
|
|
echo "date=$date" >> $GITHUB_ENV
|
|
|
|
- name: Restore build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: bazel-cache
|
|
key: ${{ runner.os }}-bazel-cache-opt-${{ env.date }}
|
|
|
|
- name: Build (opt)
|
|
run: |
|
|
bazel build --config=linux --disk_cache=bazel-cache --compilation_mode=opt --linkopt=-Wl,--strip-all --copt=-fdata-sections --copt=-ffunction-sections --linkopt=-Wl,--gc-sections \
|
|
//cdc_fuse_fs //cdc_rsync_server
|
|
|
|
- name: Test (opt)
|
|
run: |
|
|
bazel test --config=linux --disk_cache=bazel-cache --compilation_mode=opt --linkopt=-Wl,--strip-all --copt=-fdata-sections --copt=-ffunction-sections --linkopt=-Wl,--gc-sections \
|
|
--test_output=errors --local_test_jobs=1 \
|
|
-- //... -//third_party/... -//cdc_rsync_server:file_finder_test
|
|
|
|
# The artifact collector doesn't like the fact that bazel-bin is a symlink.
|
|
- name: Copy artifacts
|
|
run: |
|
|
mkdir artifacts
|
|
cp bazel-bin/cdc_fuse_fs/cdc_fuse_fs artifacts
|
|
cp bazel-bin/cdc_rsync_server/cdc_rsync_server artifacts
|
|
cp bazel-bin/external/com_github_fuse/libfuse.so artifacts
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: Linux-Artifacts
|
|
path: artifacts
|
|
|
|
Build-And-Test-Windows:
|
|
runs-on: windows-2019
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Initialize submodules
|
|
run: git submodule update --init --recursive
|
|
|
|
- name: Create timestamp
|
|
run: |
|
|
$date = Get-Date -Format "yyyy-MM"
|
|
echo "date=$date" >> $env:GITHUB_ENV
|
|
|
|
- name: Restore build cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: bazel-cache
|
|
key: ${{ runner.os }}-bazel-cache-opt-${{ env.date }}
|
|
|
|
- name: Build (opt)
|
|
run: |
|
|
bazel build --config=windows --disk_cache=bazel-cache --compilation_mode=opt --copt=/GL `
|
|
//cdc_rsync //cdc_stream //tests_common //tests_cdc_stream //tests_cdc_rsync
|
|
|
|
- name: Test (opt)
|
|
run: |
|
|
bazel-bin\tests_common\tests_common.exe
|
|
bazel-bin\tests_cdc_stream\tests_cdc_stream.exe
|
|
bazel-bin\tests_cdc_rsync\tests_cdc_rsync.exe
|
|
bazel test --config=windows --disk_cache=bazel-cache --compilation_mode=opt --copt=/GL --test_output=errors --local_test_jobs=1 `
|
|
//cdc_fuse_fs/... `
|
|
//cdc_rsync/... `
|
|
//cdc_rsync/base/... `
|
|
//cdc_rsync_server/... `
|
|
//cdc_stream/... `
|
|
//common/... `
|
|
//data_store/... `
|
|
//fastcdc/... `
|
|
//manifest/... `
|
|
//metrics/...
|
|
|
|
# The artifact collector doesn't like the fact that bazel-bin is a symlink.
|
|
- name: Copy artifacts
|
|
run: |
|
|
mkdir artifacts
|
|
cp bazel-bin/cdc_rsync/cdc_rsync.exe artifacts
|
|
cp bazel-bin/cdc_stream/cdc_stream.exe artifacts
|
|
cp LICENSE artifacts
|
|
cp README.md artifacts
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: Windows-Artifacts
|
|
path: artifacts
|
|
|
|
Create-Release:
|
|
runs-on: ubuntu-latest
|
|
needs: [Build-And-Test-Windows, Build-And-Test-Linux]
|
|
steps:
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@v3
|
|
|
|
- name: Zip binaries
|
|
run: |
|
|
# The ref resolves to "main" for latest and e.g. "v0.1.0" for tagged.
|
|
BINARIES_ZIP_NAME=cdc-file-transfer-binaries-${GITHUB_REF#refs/*/}-x64.zip
|
|
echo "BINARIES_ZIP_NAME=$BINARIES_ZIP_NAME" >> $GITHUB_ENV
|
|
zip -j $BINARIES_ZIP_NAME Windows-Artifacts/* Linux-Artifacts/*
|
|
|
|
- name: Publish latest release
|
|
if: "!startsWith(github.ref, 'refs/tags/v')"
|
|
uses: "marvinpinto/action-automatic-releases@latest"
|
|
with:
|
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
|
automatic_release_tag: "latest"
|
|
prerelease: true
|
|
title: "Development Build"
|
|
files: ${{ env.BINARIES_ZIP_NAME }}
|
|
|
|
- name: Publish tagged release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
uses: "marvinpinto/action-automatic-releases@latest"
|
|
with:
|
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
|
prerelease: false
|
|
files: ${{ env.BINARIES_ZIP_NAME }}
|