Build #689
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
inputs: | |
alpha_version: | |
description: 'Alpha version' | |
default: '' | |
run-on-runner: | |
description: 'Specify the runner to use' | |
required: true | |
default: 'ARM64' | |
perf-test: | |
description: 'Run perf test times' | |
required: true | |
default: '0' | |
schedule: | |
- cron: '0 0 * * *' # every day at midnight | |
filters: | |
branches: | |
include: | |
- 'main' | |
permissions: | |
actions: 'write' | |
packages: 'write' | |
contents: 'write' | |
name: Build | |
jobs: | |
build: | |
runs-on: ${{ github.event_name == 'push' && 'macos-12' || (github.event.inputs.run-on-runner || 'ARM64') }} | |
steps: | |
- name: validate agent | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.run-on-runner }}" != "ARM64" ]]; then | |
echo "Invalid runner" | |
exit 1 | |
fi | |
- name: Install Go | |
uses: actions/setup-go@v1 | |
with: | |
go-version: 1.22 | |
if: github.event.inputs.run-on-runner != 'ARM64' && github.event_name != 'schedule' | |
- name: Setup GO | |
run: | | |
go version | |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV | |
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV | |
echo $(go env GOPATH)/bin >> $GITHUB_PATH | |
- name: Install patched gox | |
run: | | |
mkdir -p "$GOPATH/src/github.com/mitchellh" | |
cd "$GOPATH/src/github.com/mitchellh" | |
git clone https://github.com/aslakhellesoy/gox | |
cd gox | |
git fetch | |
git checkout db6184738b77fbd5089e5fa1112177f391c91b24 | |
go install github.com/mitchellh/gox | |
if: github.event.inputs.run-on-runner != 'ARM64' && github.event_name != 'schedule' | |
- name: Install brew and node deps | |
run: | | |
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/31b24d65a7210ea0a5689d5ad00dd8d1bf5211db/Formula/protobuf.rb --output protobuf.rb | |
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/d600b1f7119f6e6a4e97fb83233b313b0468b7e4/Formula/s/swift-protobuf.rb --output swift-protobuf.rb | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install ./protobuf.rb | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install --ignore-dependencies ./swift-protobuf.rb | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install mingw-w64 | |
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install grpcurl | |
npm i -g node-gyp | |
if: github.event.inputs.run-on-runner != 'ARM64' && github.event_name != 'schedule' | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ matrix.go-version }}- | |
- name: Install old MacOS SDK (for backward compatibility of CGO) | |
run: source .github/install_macos_sdk.sh 10.15 | |
if: github.event.inputs.run-on-runner != 'ARM64' && github.event_name != 'schedule' | |
- name: Set env vars | |
env: | |
UNSPLASH_KEY: ${{ secrets.UNSPLASH_KEY }} | |
INHOUSE_KEY: ${{ secrets.INHOUSE_KEY }} | |
run: | | |
GIT_SUMMARY=$(git describe --tags --always) | |
echo "FLAGS=-X github.com/anyproto/anytype-heart/util/vcs.GitSummary=${GIT_SUMMARY} -X github.com/anyproto/anytype-heart/metrics.DefaultInHouseKey=${INHOUSE_KEY} -X github.com/anyproto/anytype-heart/util/unsplash.DefaultToken=${UNSPLASH_KEY}" >> $GITHUB_ENV | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
VERSION=${{ github.event.inputs.alpha_version }} | |
if [ -z "$VERSION" ]; then | |
VERSION=$(git rev-parse --short HEAD) | |
fi | |
fi | |
if [ -z "$VERSION" ]; then | |
VERSION=${GITHUB_REF##*/} | |
fi | |
echo VERSION=${VERSION} >> $GITHUB_ENV | |
echo MAVEN_ARTIFACT_VERSION=${VERSION} >> $GITHUB_ENV | |
echo GOPRIVATE=github.com/anyproto >> $GITHUB_ENV | |
echo $(pwd)/deps >> $GITHUB_PATH | |
echo "${GOBIN}" >> $GITHUB_PATH | |
git config --global url."https://${{ secrets.ANYTYPE_PAT }}@github.com/".insteadOf "https://github.com/" | |
- name: Go mod download | |
run: | | |
go mod download | |
- name: install protoc | |
run: | | |
make setup-protoc | |
- name: setup go | |
run: | | |
make setup-go | |
make setup-gomobile | |
which gomobile | |
- name: Cross-compile library mac/win | |
run: | | |
make download-tantivy-all | |
echo $FLAGS | |
mkdir -p .release | |
echo $SDKROOT | |
gox -cgo -ldflags="$FLAGS" -osarch="darwin/amd64" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver | |
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path) | |
echo $SDKROOT | |
gox -cgo -ldflags="$FLAGS" -osarch="darwin/arm64" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver | |
make protos-server | |
CC="x86_64-w64-mingw32-gcc" CXX="x86_64-w64-mingw32-g++" gox -cgo -ldflags="$FLAGS -linkmode external -extldflags=-static" -osarch="windows/amd64" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector noheic" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver | |
ls -lha . | |
- name: run perf tests | |
run: | | |
echo "Running perf tests" | |
make download-tantivy-all | |
RUN_COUNT=${{ github.event.inputs.perf-test }} | |
if [[ "${{ github.event_name }}" == "schedule" ]]; then | |
RUN_COUNT=10 | |
fi | |
cd cmd/perftester/ | |
CGO_ENABLED="1" go run main.go $RUN_COUNT | |
env: | |
ANYTYPE_REPORT_MEMORY: 'true' | |
TEST_MNEMONIC: ${{ secrets.TEST_MNEMONIC }} | |
PROM_KEY: ${{ secrets.PROMETHEUS_USERNAME }} | |
PROM_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }} | |
if: github.event.inputs.perf-test != '0' || github.event_name == 'schedule' | |
- name: Archive perf tests results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pprofs | |
path: | | |
*.pprof | |
if: github.event.inputs.perf-test != '0' || github.event_name == 'schedule' | |
- name: end run perf tests | |
run: | | |
rm -rf *.pprof | |
echo "End running perf tests" | |
gh run cancel ${{ github.run_id }} | |
gh run watch ${{ github.run_id }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: github.event.inputs.perf-test != '0' || github.event_name == 'schedule' | |
- name: Make JS protos | |
run: | | |
make protos-js | |
mv dist/js/pb protobuf | |
mkdir -p protobuf/protos | |
cp pb/protos/*.proto ./protobuf/protos | |
cp pb/protos/service/*.proto ./protobuf/protos | |
cp pkg/lib/pb/model/protos/*.proto ./protobuf/protos | |
if: github.event_name == 'push' | |
- name: Add system relations/types jsons | |
run: | | |
mkdir -p json/ | |
cp pkg/lib/bundle/systemRelations.json ./json | |
cp pkg/lib/bundle/systemTypes.json ./json | |
cp pkg/lib/bundle/internalRelations.json ./json | |
cp pkg/lib/bundle/internalTypes.json ./json | |
- name: Pack server win | |
run: | | |
declare -a arr=("windows-amd64") | |
for i in "${arr[@]}" | |
do | |
OSARCH=${i%.*} | |
cp ./${i}* ./grpc-server.exe | |
zip -r js_${VERSION}_${OSARCH}.zip grpc-server.exe protobuf json | |
mv js_${VERSION}_${OSARCH}.zip .release/ | |
done | |
if: github.event_name == 'push' | |
- name: Pack server osx | |
run: | | |
declare -a arr=("darwin-amd64" "darwin-arm64") | |
for i in "${arr[@]}" | |
do | |
OSARCH=${i%.*} | |
cp ./${i}* ./grpc-server | |
tar -czf js_${VERSION}_${OSARCH}.tar.gz grpc-server protobuf json | |
mv js_${VERSION}_${OSARCH}.tar.gz .release/ | |
done | |
if: github.event_name == 'push' | |
- name: Make swift protos | |
run: | | |
mkdir -p .release | |
make protos-swift | |
rm -rf protobuf | |
mv dist/ios/protobuf protobuf | |
mkdir -p protobuf/protos | |
cp pb/protos/*.proto ./protobuf/protos | |
cp pb/protos/service/*.proto ./protobuf/protos | |
cp pkg/lib/pb/model/protos/*.proto ./protobuf/protos | |
- name: Add system relations/types jsons | |
run: | | |
mkdir -p json/ | |
cp pkg/lib/bundle/systemRelations.json ./json | |
cp pkg/lib/bundle/relations.json ./json | |
cp pkg/lib/bundle/systemTypes.json ./json | |
cp pkg/lib/bundle/internalRelations.json ./json | |
cp pkg/lib/bundle/internalTypes.json ./json | |
- name: Compile ios lib | |
run: | | |
go install github.com/vektra/mockery/v2@v2.42.2 | |
go install go.uber.org/mock/mockgen@v0.3.0 | |
make test-deps | |
gomobile bind -tags "envproduction nogrpcserver gomobile nowatchdog nosigar nomutexdeadlockdetector timetzdata" -ldflags "$FLAGS" -v -target=ios -o Lib.xcframework github.com/anyproto/anytype-heart/clientlibrary/service github.com/anyproto/anytype-heart/core || true | |
mkdir -p dist/ios/ && mv Lib.xcframework dist/ios/ | |
go run cmd/iosrepack/main.go | |
mv dist/ios/Lib.xcframework . | |
gtar --exclude ".*" -czvf ios_framework.tar.gz Lib.xcframework protobuf json | |
gradle publish | |
mv ios_framework.tar.gz .release/ios_framework_${VERSION}.tar.gz | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_USER: ${{ github.actor }} | |
MAVEN_ARTIFACT_ID: 'anytype-heart-ios' | |
MAVEN_ARTIFACT_NAME: 'ios_framework.tar.gz' | |
- name: Make java protos | |
run: | | |
make protos-java | |
rm -rf protobuf | |
mv dist/android/pb protobuf | |
mkdir -p protobuf/protos | |
cp pb/protos/*.proto ./protobuf/protos | |
cp pb/protos/service/*.proto ./protobuf/protos | |
cp pkg/lib/pb/model/protos/*.proto ./protobuf/protos | |
- name: Add system relations/types jsons | |
run: | | |
mkdir -p json/ | |
cp pkg/lib/bundle/systemRelations.json ./json | |
cp pkg/lib/bundle/systemTypes.json ./json | |
cp pkg/lib/bundle/internalRelations.json ./json | |
cp pkg/lib/bundle/internalTypes.json ./json | |
- name: Compile android lib | |
run: | | |
gomobile bind -tags "envproduction nogrpcserver gomobile nowatchdog nosigar nomutexdeadlockdetector timetzdata" -ldflags "$FLAGS" -v -target=android -androidapi 19 -o lib.aar github.com/anyproto/anytype-heart/clientlibrary/service github.com/anyproto/anytype-heart/core || true | |
gtar --exclude ".*" -czvf android_lib_${VERSION}.tar.gz lib.aar protobuf json | |
mv android_lib_${VERSION}.tar.gz .release/ | |
- name: Publish android lib to maven | |
run: | | |
gradle publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_USER: ${{ github.actor }} | |
MAVEN_ARTIFACT_ID: 'anytype-heart-android' | |
MAVEN_ARTIFACT_NAME: 'lib.aar' | |
- name: Release | |
if: github.event_name == 'push' | |
uses: softprops/action-gh-release@v1 | |
with: | |
prerelease: ${{ contains(github.ref, '-rc') }} | |
fail_on_unmatched_files: true | |
files: '.release/*' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build_linux: | |
if: github.event_name == 'push' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v1 | |
with: | |
go-version: 1.22 | |
- name: Setup GO | |
run: | | |
echo GOPATH=$(go env GOPATH) >> $GITHUB_ENV | |
echo GOBIN=$(go env GOPATH)/bin >> $GITHUB_ENV | |
echo $(go env GOPATH)/bin >> $GITHUB_PATH | |
- name: Setup license repositor | |
uses: actions/checkout@master | |
with: | |
repository: anyproto/open | |
ref: refs/heads/main | |
path: ./open | |
- name: Check licenses | |
run: | | |
cd open | |
python3 tools/generate.py --platform golang | |
cd .. | |
sudo gem install license_finder | |
license_finder inherited_decisions add open/decisions.yml | |
license_finder --enabled-package-managers gomodules | |
- name: Install patched gox | |
run: | | |
rm -rf $GOPATH/src/github.com/mitchellh | |
mkdir -p $GOPATH/src/github.com/mitchellh | |
cd $GOPATH/src/github.com/mitchellh | |
git clone https://github.com/aslakhellesoy/gox | |
cd gox | |
git fetch | |
git checkout db6184738b77fbd5089e5fa1112177f391c91b24 | |
go install github.com/mitchellh/gox | |
- name: Apt install and node deps | |
run: | | |
sudo apt update | |
sudo apt install -y protobuf-compiler libprotoc-dev | |
curl -O https://pub-c60a000d68b544109df4fe5837762101.r2.dev/linux-compiler-musl-x86.zip | |
unzip linux-compiler-musl-x86.zip -d $HOME | |
npm i -g node-gyp | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ matrix.go-version }}- | |
- name: Set env vars | |
env: | |
UNSPLASH_KEY: ${{ secrets.UNSPLASH_KEY }} | |
INHOUSE_KEY: ${{ secrets.INHOUSE_KEY }} | |
run: | | |
GIT_SUMMARY=$(git describe --tags --always) | |
echo GOPRIVATE=github.com/anyproto >> $GITHUB_ENV | |
echo "FLAGS=-X github.com/anyproto/anytype-heart/util/vcs.GitSummary=${GIT_SUMMARY} -X github.com/anyproto/anytype-heart/metrics.DefaultInHouseKey=${INHOUSE_KEY} -X github.com/anyproto/anytype-heart/util/unsplash.DefaultToken=${UNSPLASH_KEY}" >> $GITHUB_ENV | |
echo VERSION=${GITHUB_REF##*/} >> $GITHUB_ENV | |
git config --global url."https://${{ secrets.ANYTYPE_PAT }}@github.com/".insteadOf "https://github.com/" | |
- name: Go mod download | |
run: | | |
go mod download | |
- name: install protoc | |
run: | | |
HAS_SYSTEM_PROTOBUF=false make setup-protoc | |
- name: setup go | |
run: | | |
make setup-go | |
- name: Cross-compile library for linux amd64/arm64 | |
run: | | |
make download-tantivy-all | |
echo $FLAGS | |
mkdir -p .release | |
CXX=$HOME/linux-compiler-musl-x86/bin/x86_64-linux-musl-g++ CC=$HOME/linux-compiler-musl-x86/bin/x86_64-linux-musl-gcc gox -cgo -osarch="linux/amd64" -ldflags="$FLAGS -linkmode external -extldflags=-static" --tags="envproduction nographviz nowatchdog nosigar nomutexdeadlockdetector" -output="{{.OS}}-{{.Arch}}" github.com/anyproto/anytype-heart/cmd/grpcserver | |
make protos-server | |
- name: Make JS protos | |
run: | | |
make protos-js | |
mv dist/js/pb protobuf | |
mkdir -p protobuf/protos | |
cp pb/protos/*.proto ./protobuf/protos | |
cp pb/protos/service/*.proto ./protobuf/protos | |
cp pkg/lib/pb/model/protos/*.proto ./protobuf/protos | |
- name: Add system relations | |
run: | | |
mkdir -p json/ | |
cp pkg/lib/bundle/systemRelations.json ./json | |
cp pkg/lib/bundle/systemTypes.json ./json | |
cp pkg/lib/bundle/internalRelations.json ./json | |
cp pkg/lib/bundle/internalTypes.json ./json | |
- name: Upload protobuf artifact for linux build | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libs | |
path: | | |
protobuf | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Pack server unix | |
run: | | |
declare -a arr=("linux-amd64") | |
for i in "${arr[@]}" | |
do | |
OSARCH=${i%.*} | |
cp ./${i}* ./grpc-server | |
tar -czf js_${VERSION}_${OSARCH}.tar.gz grpc-server protobuf json | |
mv js_${VERSION}_${OSARCH}.tar.gz .release/ | |
done | |
- name: Release | |
if: github.event_name == 'push' | |
uses: softprops/action-gh-release@v1 | |
with: | |
prerelease: ${{ contains(github.ref, '-rc') }} | |
fail_on_unmatched_files: true | |
files: '.release/*' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |