memgraph/.github/workflows/reusable_package.yaml
2024-03-19 16:25:23 +01:00

138 lines
4.4 KiB
YAML

name: Reusable package make and upload
on:
workflow_call:
inputs:
os:
type: string
description: "Target os. Default value is debian-11."
default: 'debian-11'
arch:
type: string
description: "Target architecture. Default value is amd."
default: 'amd'
runner_arch_label:
type: string
description: "Runner architecture label. Amd is built on X64, arm on ARM64. Default value is X64."
default: 'X64'
toolchain:
type: string
description: "Toolchain version. Default value is v5."
default: 'v5'
build_type:
type: string
description: "Memgraph Build type. Default value is Release."
default: 'Release'
artifact_name:
type: string
description: "Unique artifact name, pass it in to override the default. Default value is os name."
default: ''
additional_build_args:
type: string
description: "Additional build flags (--for-platform, --for-docker ...). Default value is empty."
default: ''
timeout_minutes:
type: number
description: "Timeout in minutes for the job. Default value is 60."
default: 60
push_to_s3:
type: boolean
description: "Should the final package be pushed to an S3 bucket. Default value is false"
default: false
s3_bucket:
type: string
description: "Name of the target S3 bucket."
s3_region:
type: string
description: "Region for the target S3 bucket."
s3_dest_dir:
type: string
description: "Target dir path in S3 bucket."
env:
ARTIFACT_NAME: ${{ inputs.artifact_name || inputs.os }}
jobs:
package:
runs-on: [self-hosted, DockerMgBuild, "${{ inputs.runner_arch_label }}"]
timeout-minutes: ${{ inputs.timeout_minutes }}
steps:
- name: "Set up repository"
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required because of release/get_version.py
- name: "Unlock keychain for current session" # Required beacuse ARM builds run on macos
if: ${{ inputs.arch == 'arm' }}
run: security -v unlock-keychain -p ${{ secrets.SELF_HOSTED_RUNNER_PASSWORD }} ~/Library/Keychains/login.keychain-db
- name: "Spin up mgbuild container"
run: |
./release/package/mgbuild.sh \
--toolchain ${{ inputs.toolchain }} \
--os ${{ inputs.os }} \
--arch ${{ inputs.arch }} \
run
- name: "Build Memgraph binaries"
run: |
./release/package/mgbuild.sh \
--toolchain ${{ inputs.toolchain }} \
--os ${{ inputs.os }} \
--arch ${{ inputs.arch }} \
--build-type ${{ inputs.build_type }} \
build-memgraph ${{ inputs.additional_build_args }}
- name: "Make package"
run: |
./release/package/mgbuild.sh \
--toolchain ${{ inputs.toolchain }} \
--os ${{ inputs.os }} \
--arch ${{ inputs.arch }} \
--build-type ${{ inputs.build_type }} \
package-memgraph
- name: "Copy package"
run: |
./release/package/mgbuild.sh \
--toolchain ${{ inputs.toolchain }} \
--os ${{ inputs.os }} \
--arch ${{ inputs.arch }} \
copy --package
- name: "Upload package"
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: "build/output/${{ inputs.os }}/memgraph*"
- name: "Stop mgbuild container"
if: always()
run: |
./release/package/mgbuild.sh \
--toolchain ${{ inputs.toolchain }} \
--os ${{ inputs.os }} \
--arch ${{ inputs.arch }} \
stop --remove
upload-to-s3:
if: ${{ inputs.push_to_s3 == 'true' }}
needs: [package]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: "build/output/release"
- name: Upload to S3
uses: jakejarvis/s3-sync-action@v0.5.1
env:
AWS_S3_BUCKET: ${{ inputs.s3_bucket }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ inputs.s3_region }}
SOURCE_DIR: "build/output/release"
DEST_DIR: ${{ inputs.s3_dest_dir }}