391 lines
13 KiB
YAML
391 lines
13 KiB
YAML
|
on:
|
||
|
workflow_call:
|
||
|
inputs:
|
||
|
# i.e. nightly, 1.0.0
|
||
|
name:
|
||
|
required: false
|
||
|
type: string
|
||
|
description: "The name of this release version. It can be a 'nightly' version or a semver version that represents a tag (i.e. 'v1.0.0')"
|
||
|
git-ref:
|
||
|
required: true
|
||
|
type: string
|
||
|
description: "The git ref of this release version. All 'actions/checkout' steps will use it"
|
||
|
latest:
|
||
|
required: false
|
||
|
type: boolean
|
||
|
default: false
|
||
|
description: "Consider this release as the latest one and update the Docker image tag and the binary pointer for the installers"
|
||
|
publish:
|
||
|
required: false
|
||
|
type: boolean
|
||
|
default: false
|
||
|
description: "Whether to publish this release"
|
||
|
create-release:
|
||
|
required: false
|
||
|
type: boolean
|
||
|
default: false
|
||
|
description: "Create a GitHub release"
|
||
|
|
||
|
defaults:
|
||
|
run:
|
||
|
shell: bash
|
||
|
|
||
|
jobs:
|
||
|
prepare-vars:
|
||
|
name: Prepare vars
|
||
|
runs-on: ubuntu-latest
|
||
|
outputs:
|
||
|
git-ref: ${{ steps.outputs.outputs.git-ref }}
|
||
|
name: ${{ steps.outputs.outputs.name }}
|
||
|
steps:
|
||
|
- name: Set outputs
|
||
|
id: outputs
|
||
|
run: |
|
||
|
echo "git-ref=${{ inputs.git-ref || github.ref_name }}" >> $GITHUB_OUTPUT
|
||
|
# If the name is not provided, use the git_ref (i.e. v1.0.0)
|
||
|
echo "name=${{ inputs.name || inputs.git-ref || github.ref_name }}" >> $GITHUB_OUTPUT
|
||
|
test:
|
||
|
name: Test
|
||
|
needs: [prepare-vars]
|
||
|
runs-on: ubuntu-latest-16-cores
|
||
|
steps:
|
||
|
- name: Install stable toolchain
|
||
|
uses: dtolnay/rust-toolchain@stable
|
||
|
with:
|
||
|
toolchain: 1.71.1
|
||
|
|
||
|
- name: Checkout sources
|
||
|
uses: actions/checkout@v4
|
||
|
with:
|
||
|
ref: ${{ needs.prepare-vars.outputs.git-ref }}
|
||
|
|
||
|
- name: Setup cache
|
||
|
uses: Swatinem/rust-cache@v2
|
||
|
with:
|
||
|
save-if: ${{ needs.prepare-vars.outputs.git-ref == 'main' }}
|
||
|
|
||
|
- name: Install cargo-llvm-cov
|
||
|
uses: taiki-e/install-action@cargo-llvm-cov
|
||
|
|
||
|
- name: Install cargo-make
|
||
|
run: cargo install --debug --locked cargo-make
|
||
|
|
||
|
- name: Test workspace + coverage
|
||
|
run: cargo make ci-workspace-coverage
|
||
|
|
||
|
- name: Debug info
|
||
|
if: always()
|
||
|
run: |
|
||
|
set -x
|
||
|
free -m
|
||
|
df -h
|
||
|
ps auxf
|
||
|
cat /tmp/surrealdb.log || true
|
||
|
|
||
|
- name: Upload coverage report
|
||
|
uses: actions/upload-artifact@v3
|
||
|
with:
|
||
|
name: code-coverage-report
|
||
|
path: target/llvm-cov/html/
|
||
|
retention-days: 5
|
||
|
|
||
|
lint:
|
||
|
name: Lint
|
||
|
needs: [prepare-vars]
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
|
||
|
- name: Checkout sources
|
||
|
uses: actions/checkout@v4
|
||
|
with:
|
||
|
ref: ${{ needs.prepare-vars.outputs.git-ref }}
|
||
|
|
||
|
- name: Install stable toolchain
|
||
|
uses: dtolnay/rust-toolchain@stable
|
||
|
with:
|
||
|
toolchain: 1.71.1
|
||
|
targets: wasm32-unknown-unknown
|
||
|
components: rustfmt, clippy
|
||
|
|
||
|
- name: Install cargo-make
|
||
|
run: cargo install --debug --locked cargo-make
|
||
|
|
||
|
- name: Check workspace
|
||
|
run: cargo make ci-check
|
||
|
|
||
|
- name: Check format
|
||
|
run: cargo make ci-format
|
||
|
|
||
|
- name: Check wasm
|
||
|
run: cargo make ci-check-wasm
|
||
|
|
||
|
- name: Check clippy
|
||
|
run: cargo make ci-clippy
|
||
|
|
||
|
docker-build:
|
||
|
name: Build Docker images
|
||
|
needs: [prepare-vars]
|
||
|
uses: ./.github/workflows/reusable_docker.yml
|
||
|
with:
|
||
|
git-ref: ${{ needs.prepare-vars.outputs.git-ref }}
|
||
|
tag-prefix: ${{ needs.prepare-vars.outputs.name }}
|
||
|
build: true
|
||
|
push: false
|
||
|
secrets: inherit
|
||
|
|
||
|
build:
|
||
|
name: Build ${{ matrix.arch }} binary
|
||
|
needs: [prepare-vars]
|
||
|
strategy:
|
||
|
fail-fast: false
|
||
|
matrix:
|
||
|
include:
|
||
|
# MacOS amd64
|
||
|
- arch: x86_64-apple-darwin
|
||
|
runner: macos-latest-xl
|
||
|
file: surreal-${{ needs.prepare-vars.outputs.name }}.darwin-amd64
|
||
|
build-step: |
|
||
|
# Prepare deps
|
||
|
brew install protobuf
|
||
|
|
||
|
# Build
|
||
|
cargo build --features storage-tikv,http-compression --release --locked --target x86_64-apple-darwin
|
||
|
|
||
|
# Package
|
||
|
cp target/x86_64-apple-darwin/release/surreal surreal
|
||
|
chmod +x surreal
|
||
|
tar -zcvf surreal-${{ needs.prepare-vars.outputs.name }}.darwin-amd64.tgz surreal
|
||
|
echo $(shasum -a 256 surreal-${{ needs.prepare-vars.outputs.name }}.darwin-amd64.tgz | cut -f1 -d' ') > surreal-${{ needs.prepare-vars.outputs.name }}.darwin-amd64.txt
|
||
|
|
||
|
# MacOS arm64
|
||
|
- arch: aarch64-apple-darwin
|
||
|
runner: macos-latest-xl
|
||
|
file: surreal-${{ needs.prepare-vars.outputs.name }}.darwin-arm64
|
||
|
build-step: |
|
||
|
# Prepare deps
|
||
|
brew install protobuf
|
||
|
|
||
|
# Build
|
||
|
cargo build --features storage-tikv,http-compression --release --locked --target aarch64-apple-darwin
|
||
|
|
||
|
# Package
|
||
|
cp target/aarch64-apple-darwin/release/surreal surreal
|
||
|
chmod +x surreal
|
||
|
tar -zcvf surreal-${{ needs.prepare-vars.outputs.name }}.darwin-arm64.tgz surreal
|
||
|
echo $(shasum -a 256 surreal-${{ needs.prepare-vars.outputs.name }}.darwin-arm64.tgz | cut -f1 -d' ') > surreal-${{ needs.prepare-vars.outputs.name }}.darwin-arm64.txt
|
||
|
|
||
|
# Linux amd64
|
||
|
- arch: x86_64-unknown-linux-gnu
|
||
|
runner: ubuntu-latest-16-cores
|
||
|
file: surreal-${{ needs.prepare-vars.outputs.name }}.linux-amd64
|
||
|
build-step: |
|
||
|
# Build
|
||
|
docker build \
|
||
|
--platform linux/amd64 \
|
||
|
--build-arg="CARGO_EXTRA_FEATURES=storage-tikv,http-compression" \
|
||
|
-t binary \
|
||
|
-f docker/Dockerfile.binary \
|
||
|
.
|
||
|
docker create --name binary binary
|
||
|
docker cp binary:/surrealdb/target/release/surreal surreal
|
||
|
|
||
|
# Package
|
||
|
chmod +x surreal
|
||
|
tar -zcvf surreal-${{ needs.prepare-vars.outputs.name }}.linux-amd64.tgz surreal
|
||
|
echo $(shasum -a 256 surreal-${{ needs.prepare-vars.outputs.name }}.linux-amd64.tgz | cut -f1 -d' ') > surreal-${{ needs.prepare-vars.outputs.name }}.linux-amd64.txt
|
||
|
|
||
|
# Linux arm64
|
||
|
- arch: aarch64-unknown-linux-gnu
|
||
|
runner: ["self-hosted", "arm64", "4-cores"]
|
||
|
file: surreal-${{ needs.prepare-vars.outputs.name }}.linux-arm64
|
||
|
build-step: |
|
||
|
# Build
|
||
|
docker build \
|
||
|
--platform linux/arm64 \
|
||
|
--build-arg="CARGO_EXTRA_FEATURES=storage-tikv,http-compression" \
|
||
|
-t binary \
|
||
|
-f docker/Dockerfile.binary \
|
||
|
.
|
||
|
docker create --name binary binary
|
||
|
docker cp binary:/surrealdb/target/release/surreal surreal
|
||
|
|
||
|
# Package
|
||
|
chmod +x surreal
|
||
|
tar -zcvf surreal-${{ needs.prepare-vars.outputs.name }}.linux-arm64.tgz surreal
|
||
|
echo $(shasum -a 256 surreal-${{ needs.prepare-vars.outputs.name }}.linux-arm64.tgz | cut -f1 -d' ') > surreal-${{ needs.prepare-vars.outputs.name }}.linux-arm64.txt
|
||
|
|
||
|
# Windows amd64
|
||
|
- arch: x86_64-pc-windows-msvc
|
||
|
runner: windows-latest
|
||
|
file: surreal-${{ needs.prepare-vars.outputs.name }}.windows-amd64
|
||
|
build-step: |
|
||
|
# Prepare deps
|
||
|
vcpkg integrate install
|
||
|
|
||
|
# Build
|
||
|
cargo build --features storage-tikv,http-compression --release --locked --target x86_64-pc-windows-msvc
|
||
|
|
||
|
# Package
|
||
|
cp target/x86_64-pc-windows-msvc/release/surreal.exe surreal-${{ needs.prepare-vars.outputs.name }}.windows-amd64.exe
|
||
|
echo $(shasum -a 256 surreal-${{ needs.prepare-vars.outputs.name }}.windows-amd64.exe | cut -f1 -d' ') > surreal-${{ needs.prepare-vars.outputs.name }}.windows-amd64.txt
|
||
|
|
||
|
runs-on: ${{ matrix.runner }}
|
||
|
steps:
|
||
|
- name: Checkout sources
|
||
|
uses: actions/checkout@v4
|
||
|
with:
|
||
|
ref: ${{ needs.prepare-vars.outputs.git-ref }}
|
||
|
|
||
|
- name: Checkout docker
|
||
|
uses: actions/checkout@v4
|
||
|
with:
|
||
|
path: _docker
|
||
|
|
||
|
# Replace docker files. It allows us to test new Dockerfiles with workflow_dispatch and a custom git ref.
|
||
|
# When triggered by a push or a schedule, this git ref will be the same as 'inputs.git-ref'
|
||
|
- name: Replace docker files
|
||
|
env:
|
||
|
GH_TOKEN: ${{ github.token }}
|
||
|
run: |
|
||
|
rm -rf docker .dockerignore
|
||
|
mv _docker/docker .
|
||
|
mv _docker/.dockerignore .
|
||
|
rm -rf _docker
|
||
|
|
||
|
- name: Install stable toolchain
|
||
|
uses: dtolnay/rust-toolchain@stable
|
||
|
with:
|
||
|
toolchain: 1.71.1
|
||
|
targets: ${{ matrix.arch }}
|
||
|
|
||
|
- name: Output package versions
|
||
|
run: |
|
||
|
set -x
|
||
|
set +e
|
||
|
go version ; cargo version ; rustc --version ; cmake --version ; gcc --version ; g++ --version ; perl -v
|
||
|
|
||
|
- name: Build step
|
||
|
run: ${{ matrix.build-step }}
|
||
|
|
||
|
- name: Upload artifacts
|
||
|
uses: actions/upload-artifact@v3
|
||
|
with:
|
||
|
name: ${{ matrix.file }}
|
||
|
path: |
|
||
|
surreal
|
||
|
${{ matrix.file }}.tgz
|
||
|
${{ matrix.file }}.txt
|
||
|
${{ matrix.file }}.exe
|
||
|
|
||
|
publish:
|
||
|
name: Publish artifacts binaries
|
||
|
needs: [prepare-vars, test, lint, build, docker-build]
|
||
|
if: ${{ inputs.publish }}
|
||
|
environment: ${{ needs.prepare-vars.outputs.name == 'nightly' && 'nightly' || 'release' }}
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
- name: Download artifacts
|
||
|
uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
path: artifacts
|
||
|
|
||
|
- name: Publish release
|
||
|
uses: softprops/action-gh-release@v1
|
||
|
if: ${{ inputs.create-release }}
|
||
|
with:
|
||
|
name: "Release ${{ github.ref_name }}"
|
||
|
files: |
|
||
|
LICENSE
|
||
|
artifacts/*.tgz
|
||
|
artifacts/*.exe
|
||
|
|
||
|
- name: Set latest version
|
||
|
if: ${{ inputs.create-release }}
|
||
|
run: |
|
||
|
echo ${{ github.ref_name }} > latest.txt
|
||
|
aws s3 cp --cache-control 'no-store' latest.txt s3://download.surrealdb.com/latest.txt
|
||
|
|
||
|
- name: Configure AWS
|
||
|
uses: aws-actions/configure-aws-credentials@v4
|
||
|
with:
|
||
|
aws-region: us-east-2
|
||
|
aws-access-key-id: ${{ secrets.AMAZON_ACCESS_KEY }}
|
||
|
aws-secret-access-key: ${{ secrets.AMAZON_SECRET_KEY }}
|
||
|
|
||
|
- name: Publish binaries
|
||
|
run: |
|
||
|
for file in artifacts/**/*.{tgz,txt,exe}; do
|
||
|
aws s3 cp --cache-control 'no-store' $file s3://download.surrealdb.com/${{ needs.prepare-vars.outputs.name }}/
|
||
|
done
|
||
|
|
||
|
docker-publish:
|
||
|
name: Publish Docker images
|
||
|
needs: [prepare-vars, publish]
|
||
|
uses: ./.github/workflows/reusable_docker.yml
|
||
|
with:
|
||
|
git-ref: ${{ needs.prepare-vars.outputs.git-ref }}
|
||
|
tag-prefix: ${{ needs.prepare-vars.outputs.name }}
|
||
|
latest: ${{ inputs.latest }}
|
||
|
build: false
|
||
|
push: true
|
||
|
secrets: inherit
|
||
|
|
||
|
package-macos:
|
||
|
name: Package and publish macOS universal binary
|
||
|
needs: [prepare-vars, publish]
|
||
|
runs-on: macos-latest
|
||
|
env:
|
||
|
FILE: surreal-${{ needs.prepare-vars.outputs.name }}.darwin-universal
|
||
|
steps:
|
||
|
- name: Download amd64 binary
|
||
|
uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
name: surreal-${{ needs.prepare-vars.outputs.name }}.darwin-amd64
|
||
|
path: amd64
|
||
|
|
||
|
- name: Download arm64 binary
|
||
|
uses: actions/download-artifact@v3
|
||
|
with:
|
||
|
name: surreal-${{ needs.prepare-vars.outputs.name }}.darwin-arm64
|
||
|
path: arm64
|
||
|
|
||
|
- name: Configure AWS
|
||
|
uses: aws-actions/configure-aws-credentials@v4
|
||
|
with:
|
||
|
aws-region: us-east-2
|
||
|
aws-access-key-id: ${{ secrets.AMAZON_ACCESS_KEY }}
|
||
|
aws-secret-access-key: ${{ secrets.AMAZON_SECRET_KEY }}
|
||
|
|
||
|
- name: Package universal MacOS binary
|
||
|
run: |
|
||
|
lipo -create -output surreal amd64/surreal arm64/surreal
|
||
|
chmod +x surreal
|
||
|
tar -zcvf $FILE.tgz surreal
|
||
|
echo $(shasum -a 256 $FILE.tgz | cut -f1 -d' ') > $FILE.txt
|
||
|
|
||
|
- name: Publish universal MacOS binary
|
||
|
if: ${{ inputs.publish }}
|
||
|
run: |
|
||
|
aws s3 cp --cache-control 'no-store' $FILE.tgz s3://download.surrealdb.com/${{ needs.prepare-vars.outputs.name }}/
|
||
|
aws s3 cp --cache-control 'no-store' $FILE.txt s3://download.surrealdb.com/${{ needs.prepare-vars.outputs.name }}/
|
||
|
|
||
|
propagate:
|
||
|
name: Propagate binaries to all regions
|
||
|
if: ${{ inputs.publish }}
|
||
|
needs: [publish, package-macos]
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
- name: Configure AWS
|
||
|
uses: aws-actions/configure-aws-credentials@v4
|
||
|
with:
|
||
|
aws-region: us-east-2
|
||
|
aws-access-key-id: ${{ secrets.AMAZON_ACCESS_KEY }}
|
||
|
aws-secret-access-key: ${{ secrets.AMAZON_SECRET_KEY }}
|
||
|
|
||
|
- name: Distribute binaries
|
||
|
run: |
|
||
|
regions=("af-south-1" "ap-east-1" "ap-south-1" "ap-southeast-1" "ap-southeast-2" "ca-central-1" "eu-central-1" "eu-west-2" "me-south-1" "sa-east-1" "us-west-2")
|
||
|
for region in ${regions[@]}; do
|
||
|
aws s3 sync --delete --storage-class INTELLIGENT_TIERING --source-region eu-west-2 --region ${region} s3://download.surrealdb.com s3://download.${region}.surrealdb.com
|
||
|
done
|