Skip to content

Commit

Permalink
ci: upload built binaries as artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Feb 15, 2025
1 parent 21eaef5 commit e168da0
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ jobs:
OUTPUT_KEY="build-$(echo -n "${{ inputs.depends-key }}" | sha256sum | head -c 64)-${{ github.sha }}"
echo "OUTPUT_KEY=${OUTPUT_KEY}" >> "${GITHUB_OUTPUT}"
echo "Cache key for build outputs set to \"${OUTPUT_KEY}\""
echo "short-sha=$(git rev-parse --short=8 HEAD)" >> "${GITHUB_OUTPUT}"
CCACHE_SIZE="400M"
CACHE_DIR="/cache"
export BUILD_TARGET="${{ inputs.build-target }}"
source ./ci/dash/matrix.sh
./ci/dash/build_src.sh
./ci/dash/test_unittests.sh
./ci/dash/bundle-output.sh create
ARTIFACT_PATH="/output" ./ci/dash/bundle-build.sh
shell: bash

- name: Save compile cache
Expand All @@ -100,3 +102,13 @@ jobs:
path: |
output-${{ inputs.build-target }}.tar.zst
key: ${{ steps.build.outputs.OUTPUT_KEY }}

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{ inputs.build-target }}-${{ steps.build.outputs.short-sha }}
path: |
/output/artifacts-${{ matrix.build_target }}.tar.zst
/output/artifacts-${{ matrix.build_target }}.tar.zst.sha256
compression-level: 0
retention-days: 3
93 changes: 93 additions & 0 deletions ci/dash/bundle-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# Copyright (c) 2024-2025 The Dash Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

export LC_ALL=C.UTF-8

set -eo pipefail

SH_NAME="$(basename "${0}")"

if [ -z "${BUILD_TARGET}" ]; then
echo "${SH_NAME}: BUILD_TARGET not defined, cannot continue!";
exit 1;
elif [ -z "${ARTIFACT_PATH}" ]; then
echo "${SH_NAME}: ARTIFACT_PATH not defined, cannot continue!";
exit 1;
elif [ ! "$(command -v zstd)" ]; then
echo "${SH_NAME}: zstd not found, cannot continue!";
exit 1;
fi

ARTIFACT_ARCHIVE="artifacts-${BUILD_TARGET}.tar.zst"
if [ -f "${ARTIFACT_ARCHIVE}" ]; then
echo "${SH_NAME}: ${ARTIFACT_ARCHIVE} already exists, cannot continue!";
exit 1;
fi

FILE_EXTENSION=""
if [[ "${BUILD_TARGET}" == "win"* ]]; then
FILE_EXTENSION=".exe"
fi

# The extra comma is so that brace expansion works as expected, otherwise
# it's just interpreted as literal braces
ARTIFACT_DIRS=",bin"
if [[ "${BUILD_TARGET}" == "mac"* ]]; then
ARTIFACT_DIRS="${ARTIFACT_DIRS},dist"
fi

# If there are new binaries, these need to be updated
BIN_NAMES="d,-cli,-tx"
if [[ ${BUILD_TARGET} != *"nowallet" ]]; then
BIN_NAMES="${BIN_NAMES},-wallet"
fi
if [[ ${BUILD_TARGET} == *"multiprocess" ]]; then
BIN_NAMES="${BIN_NAMES},-node"
fi

# Since brace expansion happens _before_ variable substitution, we need to
# do the variable substitution in this bash instance, then use a fresh bash
# instance to do the brace expansion, then take the word split output.
#
# This needs us to suppress SC2046.

ARTIFACT_BASE_PATH="${ARTIFACT_PATH}/${BUILD_TARGET}"
# shellcheck disable=SC2046
mkdir -p $(echo -n $(bash -c "echo ${ARTIFACT_BASE_PATH}/{${ARTIFACT_DIRS}}"))

# We aren't taking binaries from "release" as they're stripped and therefore,
# impede debugging.
BUILD_BASE_PATH="build-ci/dashcore-${BUILD_TARGET}/src"

if [ -f "${BUILD_BASE_PATH}/dashd${FILE_EXTENSION}" ]; then
# shellcheck disable=SC2046
cp $(echo -n $(bash -c "echo ${BUILD_BASE_PATH}/dash{${BIN_NAMES}}${FILE_EXTENSION}")) \
"${BUILD_BASE_PATH}/bench/bench_dash${FILE_EXTENSION}" \
"${BUILD_BASE_PATH}/test/test_dash${FILE_EXTENSION}" \
"${ARTIFACT_BASE_PATH}/bin";
fi

if [ -f "${BUILD_BASE_PATH}/qt/dash-qt${FILE_EXTENSION}" ]; then
cp "${BUILD_BASE_PATH}/qt/dash-qt${FILE_EXTENSION}" \
"${BUILD_BASE_PATH}/qt/test/test_dash-qt${FILE_EXTENSION}" \
"${ARTIFACT_BASE_PATH}/bin";
fi

if [ -f "${BUILD_BASE_PATH}/test/fuzz/fuzz${FILE_EXTENSION}" ]; then
cp "${BUILD_BASE_PATH}/test/fuzz/fuzz${FILE_EXTENSION}" \
"${ARTIFACT_BASE_PATH}/bin";
fi

if [[ "${ARTIFACT_DIRS}" == *"dist"* ]] && [[ "${BUILD_TARGET}" == "mac"* ]]; then
cp "${BUILD_BASE_PATH}/../Dash-Core.zip" \
"${ARTIFACT_BASE_PATH}/dist"
fi

# We have to cd into ARTIFACT_PATH so that the archive doesn't have the
# directory structure ARTIFACT_PATH/BUILD_TARGET when we want BUILD_TARGET
# as the root directory. `tar` offers no easy way to do this.
cd "${ARTIFACT_PATH}"
tar -cvf - "${BUILD_TARGET}" | zstd -T"$(nproc)" -5 > "${ARTIFACT_ARCHIVE}"
sha256sum "${ARTIFACT_ARCHIVE}" > "${ARTIFACT_ARCHIVE}.sha256"

0 comments on commit e168da0

Please sign in to comment.