Skip to content

Commit

Permalink
zip (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
DvirDukhan authored Sep 27, 2023
1 parent b5b6d5f commit 9597897
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 22 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/common-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@ jobs:
run: make
- name: test
run: RLTest --module bin/rediscompat.so
- name: Rename
if: ${{ inputs.deploy }}
run: mv ./bin/rediscompat.so
${{ format('{0}.{1}-{2}.{3}.so',
'./bin/rediscompat',
inputs.os-nickname || format('{0}-{1}', steps.system-info.outputs.name, steps.system-info.outputs.release),
runner.arch,
'1.0.0') }}
- name: Zip
# if: ${{ inputs.deploy }}
run: ./zip.sh
- name: Upload artifact
if: ${{ inputs.deploy }}
uses: actions/upload-artifact@v3
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/common-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
container: ${{ matrix.os }}
deploy: ${{ inputs.deploy }}
dependencies_command: 'apt update && apt install make gcc build-essential python3 python3-pip curl -y'
dependencies_command: 'apt update && apt install make gcc build-essential python3 python3-pip curl zip -y'

ubuntu-build-arm:
strategy:
Expand All @@ -34,7 +34,7 @@ jobs:
with:
container: ${{ matrix.os }}
deploy: ${{ inputs.deploy }}
dependencies_command: 'apt update && apt install make gcc build-essential python3 python3-pip curl -y'
dependencies_command: 'apt update && apt install make gcc build-essential python3 python3-pip curl zip -y'

yum-flavors:
strategy:
Expand All @@ -53,7 +53,7 @@ jobs:
container: ${{ matrix.os }}
os-nickname: ${{ matrix.osnick }}
deploy: ${{ inputs.deploy }}
dependencies_command: 'yum install make gcc tar gzip curl python3 python3-devel -y'
dependencies_command: 'yum install make gcc tar gzip curl python3 python3-devel zip -y'

yum-flavors-arm:
strategy:
Expand All @@ -72,7 +72,7 @@ jobs:
container: ${{ matrix.os }}
os-nickname: ${{ matrix.osnick }}
deploy: ${{ inputs.deploy }}
dependencies_command: 'yum install make gcc tar gzip curl python3 python3-devel -y'
dependencies_command: 'yum install make gcc tar gzip curl python3 python3-devel zip -y'

mac-build:
strategy:
Expand All @@ -83,5 +83,18 @@ jobs:
uses: ./.github/workflows/common-runner.yml
with:
runner: ${{ matrix.runners }}
python-setup: '3.10'
# python-setup: '3.10'
deploy: ${{ inputs.deploy }}

apple-silicon-build:
strategy:
fail-fast: ${{ inputs.fast-fail }}
matrix:
runners: [monterey]
secrets: inherit
uses: ./.github/workflows/common-runner.yml
with:
runner: ${{ matrix.runners }}
# python-setup: '3.10'
deploy: ${{ inputs.deploy }}
sudo: 'sudo'
16 changes: 7 additions & 9 deletions .github/workflows/common-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
type: string
python-setup:
type: string
sudo:
type: string
default: ''


jobs:
Expand Down Expand Up @@ -46,19 +49,14 @@ jobs:
run: pip3 install -r requirments.txt
- name: Install Redis Server
working-directory: redis
run: make -j `nproc` install
run: ${{ inputs.sudo }} make -j `nproc` install
- name: Make
run: make
- name: test
run: RLTest --module bin/rediscompat.so
- name: Rename
if: ${{ inputs.deploy }}
run: mv ./bin/rediscompat.so
${{ format('{0}.{1}-{2}.{3}.so',
'./bin/rediscompat',
inputs.os-nickname || format('{0}-{1}', steps.system-info.outputs.name, steps.system-info.outputs.release),
runner.arch,
'1.0.0') }}
- name: Zip
# if: ${{ inputs.deploy }}
run: ./zip.sh
- name: Upload artifact
if: ${{ inputs.deploy }}
uses: actions/upload-artifact@v3
Expand Down
77 changes: 77 additions & 0 deletions zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash

# This script adds the file ./bin/rediscompat.so to the zip file with the pattern rediscompt-<Linux|macos>-<osnick>-<arch>.version.zip
version=1.0.0
# Get OS name and architecture
os=$(uname -s)
arch=$(uname -m)
echo $os
echo $arch


# Get OS nick name
if [[ $os = 'Darwin' ]]
then
os='macos'
OS_NICK=$(sw_vers -productVersion)
# get major version
OS_NICK=${OS_NICK%%.*}
else
VERSION=$(grep '^VERSION_ID' /etc/os-release | sed 's/"//g')
VERSION=${VERSION#"VERSION_ID="}
OS_NAME=$(grep '^NAME' /etc/os-release | sed 's/"//g')
OS_NAME=${OS_NAME#"NAME="}
OS_NICK=${OS_NAME,,}${VERSION}
OS_NICK=${OS_NICK// /'_'}
fi
echo $OS_NICK

# Get OS nick name
if [[ $os = 'macos' ]]
then
# Since macos uses bash v3, we cannot use associative arrays
case $OS_NICK in
12)
OS_NICK="monterey"
;;
13)
OS_NICK="ventura"
;;
*)
echo "Unknown MacOS version $OS_NICK"
exit 1
;;
esac
case $arch in
x86_64)
arch="x86_64"
;;
aarch64)
arch="arm64v8"
;;
arm64)
arch="arm64v8"
;;
*)
echo "Unknown MacOS architecture $arch"
exit 1
;;
esac
else
declare -A LINUX_OSNICKS=(
["rocky_linux8.8"]="rhel8"
["centos_linux7"]="rhel7"
["ubuntu18.04"]="ubuntu18.04"
["ubuntu20.04"]="ubuntu20.04"
["ubuntu22.04"]="ubuntu22.04"
["amazon_linux2"]="amzn2"
["debian_gnu/linux11"]="bullseye"
)
OS_NICK=${LINUX_OSNICKS[$OS_NICK]}
fi
echo $OS_NICK
echo $arch

# Call zip and create the zip file
echo "Creating zip file ./bin/rediscompat-${os}-${OS_NICK}-${arch}.${version}.zip"
zip -j ./bin/rediscompat-${os}-${OS_NICK}-${arch}.${version}.zip ./bin/rediscompat.so

0 comments on commit 9597897

Please sign in to comment.