Skip to content

Cron Build Redis

Cron Build Redis #384

Workflow file for this run

name: Cron Build Redis
on:
schedule:
- cron: '0 1 * * *'
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Download source code
run: |
If ( -not ( Test-Path -Path .github\redis_latest_version.txt )) {
Add-Content -Path .github\redis_latest_version.txt -Value "" -NoNewline
}
$res = ConvertFrom-Json(Invoke-WebRequest -Headers @{'Authorization' = 'token ${{ secrets.GITHUB_TOKEN }}'} -Uri "https://api.github.com/repos/redis/redis/releases/latest").Content
If ( $res.tag_name -eq ( Get-Content .github\redis_latest_version.txt )) {
Write-Output "No new version"
exit 1
}
$res.tag_name | Out-File -FilePath .github\redis_latest_version.txt -NoNewline -Encoding ascii
$res.body -Replace '\(\#', '(https://github.com/redis/redis/pull/' | Set-Content .\redis_latest_body.txt
Add-Content -Path $env:GITHUB_ENV -Value "RELEASE_VERSION=$($res.tag_name)"
Add-Content -Path $env:GITHUB_ENV -Value "REDIS_DIST=Redis-$($res.tag_name)-Windows-x64"
Invoke-WebRequest -Uri https://github.com/redis/redis/archive/refs/tags/$($res.tag_name).tar.gz -OutFile redis-$($res.tag_name).tar.gz
- 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 '" 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 }}-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: |
If ( -not ( (./${{ env.REDIS_DIST }}-msys2-with-Service/redis-server.exe --version ) -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: |
If ( -not ( (./${{ env.REDIS_DIST }}-cygwin-with-Service/redis-server.exe --version ) -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: Update redis_latest_version.txt
if: ${{ success() }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .github\redis_latest_version.txt
git commit -m "update redis latest version"
git push
- 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: true
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