Skip to content

Build Redis DIY

Build Redis DIY #3

Workflow file for this run

name: Build Redis DIY
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Version'
required: true
default: "6.2.13"
type: string
make_latest:
description: 'Latest'
default: false
type: boolean
prerelease:
description: 'Pre-release'
default: false
type: boolean
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Download source code
run: |
$tag_name="${{ inputs.tag_name }}"
(ConvertFrom-Json(Invoke-WebRequest -Headers @{'Authorization' = 'Bearer ${{ secrets.GITHUB_TOKEN }}'} -Uri "https://api.github.com/repos/redis/redis/releases/tags/$($tag_name.Trim())").Content).body -Replace '\#1', 'https://github.com/redis/redis/pull/1' | Set-Content .\redis_latest_body.txt
Invoke-WebRequest -Uri https://github.com/redis/redis/archive/refs/tags/$($tag_name.Trim()).tar.gz -OutFile redis-$($tag_name.Trim()).tar.gz
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_VERSION=$($tag_name.Trim())"
Add-Content -Path $env:GITHUB_ENV -Value "REDIS_DIST=Redis-$($tag_name.Trim())-Windows-x64"
- name: Setup dotnet
if: ${{ success() }}
uses: actions/setup-dotnet@v4
- run: |
dotnet publish -c Release -r win-x64 --sc
- uses: msys2/setup-msys2@v2
with:
update: true
install: gcc make pkg-config libopenssl openssl-devel zip
- name: msys2 Build Redis
if: ${{ success() }}
run: |
workspace=$(pwd)
mkdir ${{ env.REDIS_DIST }}-msys2
sed -i 's/__GNU_VISIBLE/1/' /usr/include/dlfcn.h
tar -xzf redis-${{ env.RELEASE_VERSION }}.tar.gz
cd redis-${{ env.RELEASE_VERSION }}/src && ./mkreleasehdr.sh
sed -i 's/\"\;/\"/' asciilogo.h
echo '" Redis for Windows Project Home \n"' >> asciilogo.h
echo '" yukuaixia \n\n";' >> asciilogo.h
cd ..
make BUILD_TLS=yes CFLAGS="-Wno-char-subscripts -O0"
find . -mindepth 1 -maxdepth 2 -type f -regex '.*\(\.exe\|\.conf\)' -exec cp -f "{}" "$workspace/${{ env.REDIS_DIST }}-msys2" \;
cd $workspace
cp README.md README.zh_CN.md start.bat /usr/bin/msys-2.0.dll /usr/bin/msys-crypto-3.dll /usr/bin/msys-ssl-3.dll ${{ env.REDIS_DIST }}-msys2
sed -i 's/pidfile \/var\/run/pidfile ./' ${{ env.REDIS_DIST }}-msys2/redis.conf
zip -q -r ${{ env.REDIS_DIST }}-msys2.zip ${{ env.REDIS_DIST }}-msys2
cp install_redis_service.bat uninstall_redis_service.bat publish/* ${{ env.REDIS_DIST }}-msys2/
mv ${{ env.REDIS_DIST }}-msys2 ${{ env.REDIS_DIST }}-msys2-with-Service
zip -q -r ${{ env.REDIS_DIST }}-msys2-with-Service.zip ${{ env.REDIS_DIST }}-msys2-with-Service
shell: msys2 {0}
- name: Verify msys2 version
if: ${{ success() }}
run: |
$REDIS_MSYS2_VERSION_INFO=(./${{ env.REDIS_DIST }}-msys2-with-Service/redis-server.exe --version )
echo $REDIS_MSYS2_VERSION_INFO
# If ( -not ( $REDIS_MSYS2_VERSION_INFO -match "${{ env.RELEASE_VERSION }}" ) ) {
# Write-Output "msys2 verification failed"
# exit 1
# }
- uses: cygwin/cygwin-install-action@master
with:
packages: make gcc-core pkg-config libssl-devel zip
- name: cygwin Build Redis
env:
CYGWIN_NOWINPATH: 1
if: ${{ success() }}
run: >-
workspace=$(pwd) ;
mkdir ${{ env.REDIS_DIST }}-cygwin ;
sed -i 's/__GNU_VISIBLE/1/' /usr/include/dlfcn.h ;
rm -rf redis-${{ env.RELEASE_VERSION }} && tar -xzf redis-${{ env.RELEASE_VERSION }}.tar.gz ;
cd redis-${{ env.RELEASE_VERSION }}/src && ./mkreleasehdr.sh ;
sed -i 's/\"\;/\"/' asciilogo.h ;
echo '" Redis for Windows Project Home \n"' >> asciilogo.h ;
echo '" https://github.com/redis-windows/redis-windows \n\n";' >> asciilogo.h ;
cd .. ;
make BUILD_TLS=yes CFLAGS="-Wno-char-subscripts -O0" ;
find . -mindepth 1 -maxdepth 2 -type f -regex '.*\(\.exe\|\.conf\)' -exec cp -f "{}" "$workspace/${{ env.REDIS_DIST }}-cygwin" \; ;
cd $workspace ;
cp README.md README.zh_CN.md start.bat /bin/cygcrypto-3.dll /bin/cygwin1.dll /bin/cygssl-3.dll /bin/cygz.dll ${{ env.REDIS_DIST }}-cygwin ;
sed -i 's/pidfile \/var\/run/pidfile ./' ${{ env.REDIS_DIST }}-cygwin/redis.conf ;
zip -q -r ${{ env.REDIS_DIST }}-cygwin.zip ${{ env.REDIS_DIST }}-cygwin ;
cp install_redis_service.bat uninstall_redis_service.bat publish/* ${{ env.REDIS_DIST }}-cygwin/ ;
mv ${{ env.REDIS_DIST }}-cygwin ${{ env.REDIS_DIST }}-cygwin-with-Service ;
zip -q -r ${{ env.REDIS_DIST }}-cygwin-with-Service.zip ${{ env.REDIS_DIST }}-cygwin-with-Service
shell: bash
- name: Verify cygwin version
if: ${{ success() }}
run: |
$REDIS_CYGWIN_VERSION_INFO=(./${{ env.REDIS_DIST }}-cygwin-with-Service/redis-server.exe --version )
echo $REDIS_CYGWIN_VERSION_INFO
# If ( -not ( $REDIS_CYGWIN_VERSION_INFO -match "${{ env.RELEASE_VERSION }}" ) ) {
# Write-Output "cygwin verification failed"
# exit 1
# }
- name: Calculate the hash value
if: ${{ success() }}
run: |
'Hashes' | Out-File -Append .\redis_latest_body.txt
'=========' | Out-File -Append .\redis_latest_body.txt
Get-FileHash .\${{ env.REDIS_DIST }}-msys2.zip | Format-List
Get-FileHash .\${{ env.REDIS_DIST }}-msys2.zip | Format-List | Out-File -Append .\redis_latest_body.txt
Get-FileHash .\${{ env.REDIS_DIST }}-msys2-with-Service.zip | Format-List
Get-FileHash .\${{ env.REDIS_DIST }}-msys2-with-Service.zip | Format-List | Out-File -Append .\redis_latest_body.txt
Get-FileHash .\${{ env.REDIS_DIST }}-cygwin.zip | Format-List
Get-FileHash .\${{ env.REDIS_DIST }}-cygwin.zip | Format-List | Out-File -Append .\redis_latest_body.txt
Get-FileHash .\${{ env.REDIS_DIST }}-cygwin-with-Service.zip | Format-List
Get-FileHash .\${{ env.REDIS_DIST }}-cygwin-with-Service.zip | Format-List | Out-File -Append .\redis_latest_body.txt
- name: Add from workflow
if: ${{ success() }}
run: |
"From workflow: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | Out-File -Append .\redis_latest_body.txt
- name: Release
if: ${{ success() }}
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Redis ${{ env.RELEASE_VERSION }} for Windows
tag_name: ${{ env.RELEASE_VERSION }}
body_path: redis_latest_body.txt
make_latest: ${{ inputs.make_latest }}
prerelease: ${{ inputs.prerelease }}
files: |
${{ env.REDIS_DIST }}-cygwin.zip
${{ env.REDIS_DIST }}-cygwin-with-Service.zip
${{ env.REDIS_DIST }}-msys2.zip
${{ env.REDIS_DIST }}-msys2-with-Service.zip