diff --git a/.github/workflows/REUSABLE-bsd.yml b/.github/workflows/REUSABLE-bsd.yml new file mode 100644 index 0000000..411122e --- /dev/null +++ b/.github/workflows/REUSABLE-bsd.yml @@ -0,0 +1,145 @@ +name: Build + +on: + workflow_call: + inputs: + + machine_host: + required: true + type: string + + osname: + required: true + type: string + + osversion: + required: true + type: string + + # short version of the OS (ubuntu20.04, rhel7, etc) + osnick: + required: true + type: string + + deps: + required: true + type: string + + outside_deps: + required: false + type: string + default: "echo" + + ##### optioanl inputs ##### + + # architecture + arch: + required: false + type: string + default: x86_64 + + build_script: + required: false + type: string + default: scripts/build-bsd.sh + +jobs: + + build: + runs-on: ${{inputs.machine_host}} + + steps: + + - 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: Cache dependencies + uses: actions/cache@v3 + with: + path: | + /var/cache/apt/archives/**.deb + /var/cache/yum + key: cache-${{hashFiles('.github/workflows/*.yml')}}-${{inputs.arch}}-build + + - name: make + uses: cross-platform-actions/action@v0.21.1 + if: steps.redis-already-built.outcome != 'success' + with: + operating_system: ${{inputs.osname}} + version: ${{inputs.osversion}} + shell: bash + architecture: ${{inputs.arch}} + run: | + ${{inputs.deps}} + 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: install dependencies + run: ${{inputs.outside_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 + + - name: persist redis to s3 + if: steps.redis-already-built.outcome != 'success' && steps.iamafork.outputs.IAMAFORK != 'false' + run: | + s3cmd --access_key=${{secrets.AWS_ACCESS_KEY_ID}} --secret_key=${{secrets.AWS_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-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-bsd.yml b/.github/workflows/build-bsd.yml new file mode 100644 index 0000000..24b3549 --- /dev/null +++ b/.github/workflows/build-bsd.yml @@ -0,0 +1,46 @@ +name: Build (bsd) redis + +on: + push: + paths-ignore: + - 'docs/**' + - 'README.md' + branches: + - master + - '[0-9].[0-9]' + - '[0-9].[0-9].[0-9]' + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-bsd + cancel-in-progress: true + +permissions: + contents: read + packages: write + +jobs: + + freebsd-13_2-x86-64: + uses: ./.github/workflows/REUSABLE-bsd.yml + secrets: inherit + with: + osversion: 13.2 + osname: freebsd + machine_host: ubuntu-latest + osnick: freebsd13.2 + outside_deps: sudo apt-get update -qq && sudo apt-get install -qqy jq + deps: sudo pkg install -y bash gmake + + freebsd-13_2-arm64: + uses: ./.github/workflows/REUSABLE-bsd.yml + secrets: inherit + with: + osversion: 13.2 + osname: freebsd + machine_host: ubuntu-latest + arch: arm64 + osnick: freebsd13.2 + outside_deps: sudo apt-get update -qq && sudo apt-get install -qqy jq + deps: sudo pkg install -y bash gmake \ No newline at end of file diff --git a/.github/workflows/build-aarch64.yml b/.github/workflows/build-linux-aarch64.yml similarity index 94% rename from .github/workflows/build-aarch64.yml rename to .github/workflows/build-linux-aarch64.yml index 6313e48..babaa11 100644 --- a/.github/workflows/build-aarch64.yml +++ b/.github/workflows/build-linux-aarch64.yml @@ -1,4 +1,4 @@ -name: arm flow +name: Build (arm64) redis on: push: @@ -42,13 +42,13 @@ jobs: mode: start github-token: ${{ secrets.GH_ACCESS_TOKEN }} ec2-image-id: ${{ secrets.AWS_AMI_ID }} - ec2-instance-type: t4g.medium + ec2-instance-type: t4g.small subnet-id: ${{ secrets.AWS_SUBNET_ID }} security-group-id: ${{ secrets.AWS_SECGROUP_ID }} ubuntu-bionic-arm64: needs: start-arm64-runner - 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 @@ -58,7 +58,7 @@ jobs: ubuntu-focal-arm64: needs: start-arm64-runner - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml with: docker_image: ubuntu:20.04 deps: apt-get update -qq && apt-get install -qqy build-essential libssl-dev python3 python3-pip jq wget diff --git a/.github/workflows/build-x86_64.yml b/.github/workflows/build-linux-x86_64.yml similarity index 81% rename from .github/workflows/build-x86_64.yml rename to .github/workflows/build-linux-x86_64.yml index 4335b78..2476846 100644 --- a/.github/workflows/build-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -1,4 +1,4 @@ -name: Build redis +name: Build (intel) redis on: push: @@ -13,7 +13,7 @@ on: workflow_dispatch: concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-buildx86 + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-linuxx64 cancel-in-progress: true permissions: @@ -23,29 +23,29 @@ permissions: jobs: ubuntu-bionic-x86-64: - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml + secrets: inherit with: docker_image: ubuntu:18.04 deps: apt-get update -qq && apt-get install -qqy build-essential libssl-dev python3 python3-pip jq wget osnick: ubuntu18.04 - secrets: inherit rhel7-x86-64: - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml + secrets: inherit with: docker_image: centos:7 deps: | yum install -y epel-release yum install -y gcc make jemalloc-devel openssl-devel python3 python3-pip jq wget osnick: rhel7 - secrets: inherit rhel8-x86-64: - uses: ./.github/workflows/BUILD-REUSABLE.yml + uses: ./.github/workflows/REUSABLE-linux.yml + secrets: inherit with: docker_image: oraclelinux:8 deps: | dnf install -y oracle-epel-release-el8 dnf install -y gcc make jemalloc-devel openssl-devel tar git python3 python3-pip jq wget - osnick: rhel8 - secrets: inherit \ No newline at end of file + osnick: rhel8 \ No newline at end of file diff --git a/.github/workflows/build-osx.yml b/.github/workflows/build-osx.yml new file mode 100644 index 0000000..d6269d0 --- /dev/null +++ b/.github/workflows/build-osx.yml @@ -0,0 +1,39 @@ +name: Build (mac) redis + +on: + push: + paths-ignore: + - 'docs/**' + - 'README.md' + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-osx + cancel-in-progress: true + + +permissions: + contents: read + packages: write + +jobs: + + # macos-arm64: + # uses: ./.github/workflows/REUSABLE-osx.yml + # secrets: inherit + # 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 + secrets: inherit + with: + macos_type: macos-latest + deps: brew install openssl@3 coreutils + build_script: scripts/build-osx.sh + osnick: monterey diff --git a/scripts/build-bsd.sh b/scripts/build-bsd.sh new file mode 100644 index 0000000..6f33844 --- /dev/null +++ b/scripts/build-bsd.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +gmake -C redis/src all BUILD_TLS=yes \ No newline at end of file diff --git a/scripts/build-osx-arm.sh b/scripts/build-osx-arm.sh new file mode 100644 index 0000000..2194277 --- /dev/null +++ b/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/scripts/build-osx.sh b/scripts/build-osx.sh new file mode 100644 index 0000000..2ff5dae --- /dev/null +++ b/scripts/build-osx.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +make -C redis/src 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/scripts/build.sh similarity index 100% rename from build.sh rename to scripts/build.sh