From 0938a90ed7c95cf2312d58bee378c755ecffc151 Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Sun, 26 Nov 2023 13:11:47 +0200 Subject: [PATCH] osx --- .github/scripts/build-osx-arm.sh | 5 + .github/scripts/build-osx.sh | 5 + build.sh => .github/scripts/build.sh | 0 ...{BUILD-REUSABLE.yml => REUSABLE-linux.yml} | 9 +- .github/workflows/REUSABLE-osx.yml | 123 ++++++++++++++++++ .github/workflows/build-osx.yml | 37 ++++++ .github/workflows/build.yml | 8 +- 7 files changed, 176 insertions(+), 11 deletions(-) create mode 100644 .github/scripts/build-osx-arm.sh create mode 100644 .github/scripts/build-osx.sh rename build.sh => .github/scripts/build.sh (100%) rename .github/workflows/{BUILD-REUSABLE.yml => REUSABLE-linux.yml} (96%) create mode 100644 .github/workflows/REUSABLE-osx.yml create mode 100644 .github/workflows/build-osx.yml diff --git a/.github/scripts/build-osx-arm.sh b/.github/scripts/build-osx-arm.sh new file mode 100644 index 0000000..2194277 --- /dev/null +++ b/.github/scripts/build-osx-arm.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +make -C redis/src all BUILD_TLS=yes \ + FINAL_LIBS="-lm -ldl ../deps/hiredis/libhiredis_ssl.a /opt/homebrew/opt/openssl/lib/libssl.a /opt/homebrew/opt/openssl/lib/libcrypto.a" \ + CFLAGS="-I /opt/homebrew/opt/openssl@3/include" \ No newline at end of file diff --git a/.github/scripts/build-osx.sh b/.github/scripts/build-osx.sh new file mode 100644 index 0000000..0ab45f0 --- /dev/null +++ b/.github/scripts/build-osx.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +make all \ + BUILD_TLS=yes \ + FINAL_LIBS="-lm -ldl ../deps/hiredis/libhiredis_ssl.a /usr/local/opt/openssl/lib/libssl.a /usr/local/opt/openssl/lib/libcrypto.a" diff --git a/build.sh b/.github/scripts/build.sh similarity index 100% rename from build.sh rename to .github/scripts/build.sh diff --git a/.github/workflows/BUILD-REUSABLE.yml b/.github/workflows/REUSABLE-linux.yml similarity index 96% rename from .github/workflows/BUILD-REUSABLE.yml rename to .github/workflows/REUSABLE-linux.yml index 3456d84..59c0bb8 100644 --- a/.github/workflows/BUILD-REUSABLE.yml +++ b/.github/workflows/REUSABLE-linux.yml @@ -1,4 +1,4 @@ -name: Build and Publish +name: Build on: workflow_call: @@ -26,15 +26,10 @@ on: type: string default: x86_64 - osname: - required: false - type: string - default: Linux - build_script: required: false type: string - default: build.sh + default: scripts/build.sh jobs: diff --git a/.github/workflows/REUSABLE-osx.yml b/.github/workflows/REUSABLE-osx.yml new file mode 100644 index 0000000..c203673 --- /dev/null +++ b/.github/workflows/REUSABLE-osx.yml @@ -0,0 +1,123 @@ +name: Build Mac + +on: + + workflow_call: + inputs: + + macos_type: + required: true + type: string + + # short version of the OS (ubuntu20.04, rhel7, etc) + osnick: + required: true + type: string + + deps: + required: true + type: string + + ##### optioanl inputs ##### + + # architecture + arch: + required: false + type: string + default: x86_64 + + osname: + required: false + type: string + default: macos + + build_script: + required: false + type: string + default: scripts/build-osx.sh + +jobs: + build: + runs-on: ${{inputs.macos_type}} + + steps: + - name: install dependencies + run: ${{inputs.deps}} + + - name: determine if in fork + id: iamafork + run: | + amfork=`jq '.pull_request.head.repo.fork' $GITHUB_EVENT_PATH` + echo "am I fork: ${amfork}" + echo "IAMAFORK=$amfork" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v3 + with: + path: redis-builder + + - name: load envvars + id: get_config_versions + run: | + . redis-builder/vars + echo VERSION=$REDISVERSION >> $GITHUB_OUTPUT + echo PACKAGEDREDISVERSION=$PACKAGEDREDISVERSION >> $GITHUB_OUTPUT + echo S3BASE=$S3BASE >> $GITHUB_OUTPUT + echo HTTPS3BASE=$HTTPS3BASE >> $GITHUB_OUTPUT + + - name: check if already built + id: redis-already-built + continue-on-error: true + run: | + wget -q ${{steps.get_config_versions.outputs.HTTPS3BASE}}/redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}}.tgz + + - uses: actions/checkout@v3 + if: steps.redis-already-built.outcome != 'success' + with: + repository: redis/redis + path: redis + ref: ${{steps.get_config_versions.outputs.VERSION}} + + - name: make + if: steps.redis-already-built.outcome != 'success' + run: bash redis-builder/${{inputs.build_script}} + + - name: package redis for s3 + if: steps.redis-already-built.outcome != 'success' + run: | + mkdir redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}} + cp redis/src/redis-server \ + redis/src/redis-sentinel \ + redis/src/redis-check-aof \ + redis/src/redis-check-rdb \ + redis/src/redis-benchmark \ + redis/src/redis-cli \ + redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}} + tar -czvf redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}}.tgz \ + redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}} + + - name: perist redis + if: steps.redis-already-built.outcome != 'success' + uses: actions/upload-artifact@v3 + with: + name: redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.arch}} + path: | + redis/src/redis-server + redis/src/redis-sentinel + redis/src/redis-check-aof + redis/src/redis-check-rdb + redis/src/redis-benchmark + redis/src/redis-cli + + - name: install s3cmd + if: steps.redis-already-built.outcome != 'success' + run: | + pip3 install s3cmd + + - name: persist redis to s3 + if: steps.redis-already-built.outcome != 'success' && steps.iamafork.outputs.IAMAFORK != 'false' + run: | + s3cmd --access_key=${{secrets.AWS_S3_ACCESS_KEY_ID}} \ + --secret_key=${{secrets.AWS_S3_SECRET_ACCESS_KEY}} \ + --region=us-east-1 \ + put -P redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}}.tgz \ + ${{steps.get_config_versions.outputs.S3BASE}}/redis-${{steps.get_config_versions.outputs.PACKAGEDREDISVERSION}}-${{inputs.osnick}}-${{inputs.arch}}.tgz diff --git a/.github/workflows/build-osx.yml b/.github/workflows/build-osx.yml new file mode 100644 index 0000000..3de1ab8 --- /dev/null +++ b/.github/workflows/build-osx.yml @@ -0,0 +1,37 @@ +name: Build redis + +on: + push: + paths-ignore: + - 'docs/**' + - 'README.md' + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-linuxx64 + cancel-in-progress: true + + +permissions: + contents: read + packages: write + +jobs: + + macos-arm64: + uses: ./.github/workflows/REUSABLE-osx.yml + with: + macos_type: macos-latest-large + deps: brew install openssl@3 coreutils + arch: arm64 + build_script: scripts/build-osx-arm.sh + osnick: monterey + + macos-x86_64: + uses: ./.github/workflows/REUSABLE-osx.yml + with: + macos_type: macos-latest-large + deps: brew install openssl@3 coreutils + build_script: scripts/build-osx.sh + osnick: monterey diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0ee030..d085edc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-linuxx64 cancel-in-progress: true @@ -20,7 +20,7 @@ permissions: jobs: ubuntu-bionic-x86-64: - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml with: docker_image: ubuntu:18.04 deps: apt-get update -qq && apt-get install -qqy build-essential libssl-dev python3 python3-pip jq wget @@ -28,7 +28,7 @@ jobs: secrets: inherit rhel7-x86-64: - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml with: docker_image: centos:7 deps: | @@ -38,7 +38,7 @@ jobs: secrets: inherit rhel8-x86-64: - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml with: docker_image: oraclelinux:8 deps: |