From ef9ca7641a82202b2a6dee7e702ef226aecaa9cd Mon Sep 17 00:00:00 2001 From: t1amak Date: Tue, 9 Dec 2025 23:32:11 +0100 Subject: [PATCH] workflows changes 7 --- .github/workflows/build-releases.yml | 10 ++++++++++ scripts/release/images/ubuntu/build.sh | 10 +++++++++- scripts/release/linux_x64/build.sh | 11 +++++++++-- scripts/release/linux_x64/p2pool_linux_x64.sh | 13 ++++++++++--- scripts/release/macos_aarch64/build.sh | 11 +++++++++-- .../release/macos_aarch64/p2pool_macos_aarch64.sh | 13 ++++++++++--- scripts/release/windows_x64/build.sh | 11 +++++++++-- scripts/release/windows_x64/p2pool_windows_x64.sh | 13 ++++++++++--- 8 files changed, 76 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-releases.yml b/.github/workflows/build-releases.yml index bd58ff0..836d4f3 100644 --- a/.github/workflows/build-releases.yml +++ b/.github/workflows/build-releases.yml @@ -23,6 +23,8 @@ jobs: env: # This logic correctly gets the version from either the dispatch input or the tag name P2POOL_VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} + P2POOL_BUILD_CACHE: /tmp/p2pool-buildx-cache + DOCKER_BUILDKIT: 1 steps: - name: Checkout repository @@ -40,6 +42,14 @@ jobs: fi echo "Building release for ${P2POOL_VERSION}" + - name: Restore Docker build cache + uses: actions/cache@v3 + with: + path: /tmp/p2pool-buildx-cache + key: p2pool-buildx-${{ runner.os }}-${{ env.P2POOL_VERSION }} + restore-keys: | + p2pool-buildx-${{ runner.os }}- + # This new step sets the title and body for the release - name: Set Release Title and Body id: set_release_vars diff --git a/scripts/release/images/ubuntu/build.sh b/scripts/release/images/ubuntu/build.sh index f0b3576..a76bc61 100755 --- a/scripts/release/images/ubuntu/build.sh +++ b/scripts/release/images/ubuntu/build.sh @@ -1,3 +1,11 @@ #!/bin/sh cd "$(dirname "$0")" -docker build -t p2pool_build_ubuntu . +cache_args="" +if [ -n "${P2POOL_BUILD_CACHE:-}" ]; then + cache_dir="${P2POOL_BUILD_CACHE%/}/base" + mkdir -p "$cache_dir" + export DOCKER_BUILDKIT=1 + cache_args="--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from type=local,src=$cache_dir --cache-to type=local,dest=$cache_dir,mode=max" +fi + +docker build $cache_args -t p2pool_build_ubuntu . diff --git a/scripts/release/linux_x64/build.sh b/scripts/release/linux_x64/build.sh index f2cf63d..c400d89 100755 --- a/scripts/release/linux_x64/build.sh +++ b/scripts/release/linux_x64/build.sh @@ -6,7 +6,6 @@ set -eu cd "$(dirname "$0")" repo_root="$(cd ../../.. && pwd)" -checkout_ref="$(git -C "$repo_root" rev-parse HEAD)" if [ "${2:-}" ]; then cpu_set="--cpuset-cpus $2" @@ -14,9 +13,17 @@ else cpu_set="" fi +cache_args="" +if [ -n "${P2POOL_BUILD_CACHE:-}" ]; then + cache_dir="${P2POOL_BUILD_CACHE%/}/linux_x64" + mkdir -p "$cache_dir" + export DOCKER_BUILDKIT=1 + cache_args="--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from type=local,src=$cache_dir --cache-to type=local,dest=$cache_dir,mode=max" +fi + docker build $cpu_set \ --build-arg P2POOL_VERSION=$1 \ - --build-arg P2POOL_CHECKOUT=$checkout_ref \ + $cache_args \ -t p2pool_linux_x64_build_$1 \ -f Dockerfile "$repo_root" diff --git a/scripts/release/linux_x64/p2pool_linux_x64.sh b/scripts/release/linux_x64/p2pool_linux_x64.sh index 2bdba8a..44a2ab5 100755 --- a/scripts/release/linux_x64/p2pool_linux_x64.sh +++ b/scripts/release/linux_x64/p2pool_linux_x64.sh @@ -2,15 +2,22 @@ set -e cd /p2pool -git fetch --jobs=$(nproc) CHECKOUT_REF=${P2POOL_CHECKOUT:-$2} +if [ -z "$CHECKOUT_REF" ]; then + echo "No checkout ref provided. Pass a version/tag as argument 2 or set P2POOL_CHECKOUT." + exit 1 +fi +if ! git rev-parse --verify --quiet "$CHECKOUT_REF^{commit}" >/dev/null; then + echo "Requested ref '$CHECKOUT_REF' is not present in the build context." + exit 1 +fi echo "Checking out ${CHECKOUT_REF} (version label $2)" -git checkout "$CHECKOUT_REF" +git checkout --detach "$CHECKOUT_REF" git -c submodule.external/src/grpc.update=none submodule update --recursive --jobs $(nproc) export TZ=UTC0 -BUILD_TIMESTAMP=$(git show --no-patch --format=%ct $2) +BUILD_TIMESTAMP=$(git show --no-patch --format=%ct "$CHECKOUT_REF") CURRENT_DATE=$(date -u -d @$BUILD_TIMESTAMP +"%Y-%m-%d") CURRENT_TIME=$(date -u -d @$BUILD_TIMESTAMP +"%H:%M:%S") TOUCH_DATE=$(date -u -d @$BUILD_TIMESTAMP +"%Y%m%d%H%M.%S") diff --git a/scripts/release/macos_aarch64/build.sh b/scripts/release/macos_aarch64/build.sh index cfeaddd..e36bae2 100755 --- a/scripts/release/macos_aarch64/build.sh +++ b/scripts/release/macos_aarch64/build.sh @@ -6,7 +6,6 @@ set -eu cd "$(dirname "$0")" repo_root="$(cd ../../.. && pwd)" -checkout_ref="$(git -C "$repo_root" rev-parse HEAD)" if [ "${2:-}" ]; then cpu_set="--cpuset-cpus $2" @@ -14,9 +13,17 @@ else cpu_set="" fi +cache_args="" +if [ -n "${P2POOL_BUILD_CACHE:-}" ]; then + cache_dir="${P2POOL_BUILD_CACHE%/}/macos_aarch64" + mkdir -p "$cache_dir" + export DOCKER_BUILDKIT=1 + cache_args="--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from type=local,src=$cache_dir --cache-to type=local,dest=$cache_dir,mode=max" +fi + docker build $cpu_set \ --build-arg P2POOL_VERSION=$1 \ - --build-arg P2POOL_CHECKOUT=$checkout_ref \ + $cache_args \ -t p2pool_macos_aarch64_build_$1 \ -f Dockerfile "$repo_root" diff --git a/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh b/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh index 502767a..2f1169f 100755 --- a/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh +++ b/scripts/release/macos_aarch64/p2pool_macos_aarch64.sh @@ -2,15 +2,22 @@ set -e cd /p2pool -git fetch --jobs=$(nproc) CHECKOUT_REF=${P2POOL_CHECKOUT:-$2} +if [ -z "$CHECKOUT_REF" ]; then + echo "No checkout ref provided. Pass a version/tag as argument 2 or set P2POOL_CHECKOUT." + exit 1 +fi +if ! git rev-parse --verify --quiet "$CHECKOUT_REF^{commit}" >/dev/null; then + echo "Requested ref '$CHECKOUT_REF' is not present in the build context." + exit 1 +fi echo "Checking out ${CHECKOUT_REF} (version label $2)" -git checkout "$CHECKOUT_REF" +git checkout --detach "$CHECKOUT_REF" git -c submodule.external/src/grpc.update=none submodule update --recursive --jobs $(nproc) export TZ=UTC0 -BUILD_TIMESTAMP=$(git show --no-patch --format=%ct $2) +BUILD_TIMESTAMP=$(git show --no-patch --format=%ct "$CHECKOUT_REF") CURRENT_DATE=$(date -u -d @$BUILD_TIMESTAMP +"%Y-%m-%d") CURRENT_TIME=$(date -u -d @$BUILD_TIMESTAMP +"%H:%M:%S") TOUCH_DATE=$(date -u -d @$BUILD_TIMESTAMP +"%Y%m%d%H%M.%S") diff --git a/scripts/release/windows_x64/build.sh b/scripts/release/windows_x64/build.sh index fdccee5..ac2fe9a 100755 --- a/scripts/release/windows_x64/build.sh +++ b/scripts/release/windows_x64/build.sh @@ -6,7 +6,6 @@ set -eu cd "$(dirname "$0")" repo_root="$(cd ../../.. && pwd)" -checkout_ref="$(git -C "$repo_root" rev-parse HEAD)" if [ "${2:-}" ]; then cpu_set="--cpuset-cpus $2" @@ -14,9 +13,17 @@ else cpu_set="" fi +cache_args="" +if [ -n "${P2POOL_BUILD_CACHE:-}" ]; then + cache_dir="${P2POOL_BUILD_CACHE%/}/windows_x64" + mkdir -p "$cache_dir" + export DOCKER_BUILDKIT=1 + cache_args="--build-arg BUILDKIT_INLINE_CACHE=1 --cache-from type=local,src=$cache_dir --cache-to type=local,dest=$cache_dir,mode=max" +fi + docker build $cpu_set \ --build-arg P2POOL_VERSION=$1 \ - --build-arg P2POOL_CHECKOUT=$checkout_ref \ + $cache_args \ -t p2pool_windows_x64_build_$1 \ -f Dockerfile "$repo_root" diff --git a/scripts/release/windows_x64/p2pool_windows_x64.sh b/scripts/release/windows_x64/p2pool_windows_x64.sh index 22ee55b..138afee 100755 --- a/scripts/release/windows_x64/p2pool_windows_x64.sh +++ b/scripts/release/windows_x64/p2pool_windows_x64.sh @@ -9,15 +9,22 @@ trap 'rm -rf "$PATCH_TMP_ROOT"' EXIT cp -r patches "$PATCH_TMP_ROOT/" PATCH_DIR="$PATCH_TMP_ROOT/patches" -git fetch --jobs=$(nproc) CHECKOUT_REF=${P2POOL_CHECKOUT:-$2} +if [ -z "$CHECKOUT_REF" ]; then + echo "No checkout ref provided. Pass a version/tag as argument 2 or set P2POOL_CHECKOUT." + exit 1 +fi +if ! git rev-parse --verify --quiet "$CHECKOUT_REF^{commit}" >/dev/null; then + echo "Requested ref '$CHECKOUT_REF' is not present in the build context." + exit 1 +fi echo "Checking out ${CHECKOUT_REF} (version label $2)" -git checkout "$CHECKOUT_REF" +git checkout --detach "$CHECKOUT_REF" git -c submodule.external/src/grpc.update=none submodule update --recursive --jobs $(nproc) export TZ=UTC0 -BUILD_TIMESTAMP=$(git show --no-patch --format=%ct $2) +BUILD_TIMESTAMP=$(git show --no-patch --format=%ct "$CHECKOUT_REF") CURRENT_DATE=$(date -u -d @$BUILD_TIMESTAMP +"%Y-%m-%d") CURRENT_TIME=$(date -u -d @$BUILD_TIMESTAMP +"%H:%M:%S") TOUCH_DATE=$(date -u -d @$BUILD_TIMESTAMP +"%Y%m%d%H%M.%S")