Skip to content

Commit

Permalink
Replace release.mk by release scripts
Browse files Browse the repository at this point in the history
Since commit 2687d20, the Makefile
named release.mk stopped handling dependencies between recipes, because
they have to be executed separately (from different Github Actions
jobs).

There is no real benefit using a Makefile anymore. Replace them by
several individual release scripts for simplicity and readability.

Refs Genymobile#5306 <Genymobile#5306>
  • Loading branch information
rom1v committed Nov 22, 2024
1 parent 24588cb commit 45ad9a0
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 164 deletions.
46 changes: 25 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build-scrcpy-server:
runs-on: ubuntu-latest
env:
GRADLE: gradle # use native gradle instead of ./gradlew in release.mk
GRADLE: gradle # use native gradle instead of ./gradlew in scripts
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -22,16 +22,16 @@ jobs:
java-version: '17'

- name: Test scrcpy-server
run: make -f release.mk test-server
run: release/test_server.sh

- name: Build scrcpy-server
run: make -f release.mk build-server
run: release/build_server.sh

- name: Upload scrcpy-server artifact
uses: actions/upload-artifact@v4
with:
name: scrcpy-server
path: build-server/server/scrcpy-server
path: release/work/build-server/server/scrcpy-server

test-client:
runs-on: ubuntu-latest
Expand All @@ -46,13 +46,8 @@ jobs:
libsdl2-dev libavcodec-dev libavdevice-dev libavformat-dev \
libavutil-dev libswresample-dev libusb-1.0-0 libusb-1.0-0-dev
- name: Build
run: |
meson setup d -Db_sanitize=address,undefined
- name: Test
run: |
meson test -Cd
run: release/test_client.sh

build-win32:
runs-on: ubuntu-latest
Expand All @@ -72,13 +67,13 @@ jobs:
run: sed -i 's/^pkg-config/pkgconfig/' cross_win32.txt

- name: Build scrcpy win32
run: make -f release.mk build-win32
run: release/build_windows.sh 32

- name: Upload build-win32 artifact
uses: actions/upload-artifact@v4
with:
name: build-win32-intermediate
path: build-win32/dist/
path: release/work/build-win32/dist/

build-win64:
runs-on: ubuntu-latest
Expand All @@ -98,13 +93,13 @@ jobs:
run: sed -i 's/^pkg-config/pkgconfig/' cross_win64.txt

- name: Build scrcpy win64
run: make -f release.mk build-win64
run: release/build_windows.sh 64

- name: Upload build-win64 artifact
uses: actions/upload-artifact@v4
with:
name: build-win64-intermediate
path: build-win64/dist/
path: release/work/build-win64/dist/

package:
needs:
Expand All @@ -113,7 +108,7 @@ jobs:
- build-win64
runs-on: ubuntu-latest
env:
# $VERSION is used by release.mk
# $VERSION is used by release scripts
VERSION: ${{ github.event.inputs.name || github.ref_name }}
steps:
- name: Checkout code
Expand All @@ -123,25 +118,34 @@ jobs:
uses: actions/download-artifact@v4
with:
name: scrcpy-server
path: build-server/server/
path: release/work/build-server/server/

- name: Download build-win32
uses: actions/download-artifact@v4
with:
name: build-win32-intermediate
path: build-win32/dist/
path: release/work/build-win32/dist/

- name: Download build-win64
uses: actions/download-artifact@v4
with:
name: build-win64-intermediate
path: build-win64/dist/
path: release/work/build-win64/dist/

- name: Package server
run: release/package_server.sh

- name: Package win32
run: release/package_client.sh win32

- name: Package win64
run: release/package_client.sh win64

- name: Package
run: make -f release.mk package
- name: Generate checksums
run: release/generate_checksums.sh

- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: scrcpy-release-${{ env.VERSION }}
path: release-${{ env.VERSION }}
path: release/output
141 changes: 0 additions & 141 deletions release.mk

This file was deleted.

2 changes: 0 additions & 2 deletions release.sh

This file was deleted.

2 changes: 2 additions & 0 deletions release/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/work
/output
5 changes: 5 additions & 0 deletions release/build_common
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file must be sourced from the release scripts directory
WORK_DIR="$PWD/work"
OUTPUT_DIR="$PWD/output"

VERSION="${VERSION:-$(git describe --tags --always)}"
14 changes: 14 additions & 0 deletions release/build_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -ex
cd "$(dirname ${BASH_SOURCE[0]})"
. build_common
cd .. # root project dir

GRADLE="${GRADLE:-./gradlew}"
SERVER_BUILD_DIR="$WORK_DIR/build-server"

rm -rf "$SERVER_BUILD_DIR"
"$GRADLE" -p server assembleRelease
mkdir -p "$SERVER_BUILD_DIR/server"
cp server/build/outputs/apk/release/server-release-unsigned.apk \
"$SERVER_BUILD_DIR/server/scrcpy-server"
51 changes: 51 additions & 0 deletions release/build_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -ex

case "$1" in
32)
WINXX=win32
;;
64)
WINXX=win64
;;
*)
echo "ERROR: $0 must be called with one argument: 32 or 64" >&2
exit 1
;;
esac

cd "$(dirname ${BASH_SOURCE[0]})"
. build_common
cd .. # root project dir

WINXX_BUILD_DIR="$WORK_DIR/build-$WINXX"

app/deps/adb.sh $WINXX
app/deps/sdl.sh $WINXX
app/deps/ffmpeg.sh $WINXX
app/deps/libusb.sh $WINXX

DEPS_INSTALL_DIR="$PWD/app/deps/work/install/$WINXX"

rm -rf "$WINXX_BUILD_DIR"
meson setup "$WINXX_BUILD_DIR" \
--pkg-config-path="$DEPS_INSTALL_DIR/lib/pkgconfig" \
-Dc_args="-I$DEPS_INSTALL_DIR/include" \
-Dc_link_args="-L$DEPS_INSTALL_DIR/lib" \
--cross-file=cross_$WINXX.txt \
--buildtype=release \
--strip \
-Db_lto=true \
-Dcompile_server=false \
-Dportable=true
ninja -C "$WINXX_BUILD_DIR"

# Group intermediate outputs into a 'dist' directory
mkdir -p "$WINXX_BUILD_DIR/dist"
cp "$WINXX_BUILD_DIR"/app/scrcpy.exe "$WINXX_BUILD_DIR/dist/"
cp app/data/scrcpy-console.bat "$WINXX_BUILD_DIR/dist/"
cp app/data/scrcpy-noconsole.vbs "$WINXX_BUILD_DIR/dist/"
cp app/data/icon.png "$WINXX_BUILD_DIR/dist/"
cp app/data/open_a_terminal_here.bat "$WINXX_BUILD_DIR/dist/"
cp "$DEPS_INSTALL_DIR"/bin/*.dll "$WINXX_BUILD_DIR/dist/"
cp "$DEPS_INSTALL_DIR"/bin/adb.exe "$WINXX_BUILD_DIR/dist/"
10 changes: 10 additions & 0 deletions release/generate_checksums.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -ex
cd "$(dirname ${BASH_SOURCE[0]})"
. build_common

cd "$OUTPUT_DIR"
sha256sum "scrcpy-server-$VERSION" \
"scrcpy-win32-$VERSION.zip" \
"scrcpy-win64-$VERSION.zip" | tee SHA256SUMS.txt
echo "Release checksums generated in $PWD/SHA256SUMS.txt"
33 changes: 33 additions & 0 deletions release/package_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -ex
cd "$(dirname ${BASH_SOURCE[0]})"
. build_common
cd .. # root project dir

if [[ $# != 1 ]]
then
# <target_name>: for example win64
echo "Syntax: $0 <target>" >&2
exit 1

fi

BUILD_DIR="$WORK_DIR/build-$1"
ZIP_DIR="$BUILD_DIR/zip"
TARGET="scrcpy-$1-$VERSION"

rm -rf "$ZIP_DIR/$TARGET"
mkdir -p "$ZIP_DIR/$TARGET"

cp -r "$BUILD_DIR/dist/." "$ZIP_DIR/$TARGET/"
cp "$WORK_DIR/build-server/server/scrcpy-server" "$ZIP_DIR/$TARGET/"

mkdir -p "$OUTPUT_DIR"
rm -f "$OUTPUT_DIR/$TARGET.zip"

cd "$ZIP_DIR"
rm -f "$OUTPUT_DIR/$TARGET.zip"
zip -r "$OUTPUT_DIR/$TARGET.zip" "$TARGET"
rm -rf "$TARGET"
cd -
echo "Generated '$OUTPUT_DIR/$TARGET.zip'"
Loading

0 comments on commit 45ad9a0

Please sign in to comment.