Skip to content

Commit

Permalink
Merge branch 'static-dev' into static
Browse files Browse the repository at this point in the history
# Conflicts:
#	configure.ac
#	src/test-komodo/test_parse_args.cpp
  • Loading branch information
DeckerSU committed Jan 30, 2024
2 parents 61447b5 + 88f8e8c commit 281f59e
Show file tree
Hide file tree
Showing 26 changed files with 733 additions and 165 deletions.
17 changes: 17 additions & 0 deletions .github/actions/build-project-docker/Dockerfile.focal.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Amsterdam

RUN \
apt-get update && apt-get install --no-install-recommends -y ca-certificates curl &&\
apt-get install --no-install-recommends -y build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python bison zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake &&\
apt-get install --no-install-recommends -y mingw-w64 &&\
echo 1 | update-alternatives --config x86_64-w64-mingw32-gcc &&\
echo 1 | update-alternatives --config x86_64-w64-mingw32-g++ &&\
apt-get install --no-install-recommends -y librsvg2-bin libtiff-tools cmake imagemagick libcap-dev libz-dev libbz2-dev python3-setuptools libtinfo5 xorriso sudo
RUN \
apt-get clean && rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
20 changes: 20 additions & 0 deletions .github/actions/build-project-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Build project in docker'
description: 'Create docker image with build environment and build the project'
inputs:
builder-name:
required: true
default: 'builder'
builder-uid:
required: true
default: 1000
builder-gid:
required: true
default: 1000
runs:
using: 'docker'
image: 'Dockerfile.focal.ci'
env:
BUILDER_NAME: ${{ inputs.builder-name }}
BUILDER_UID: ${{ inputs.builder-uid }}
BUILDER_GID: ${{ inputs.builder-gid }}
210 changes: 210 additions & 0 deletions .github/actions/build-project-docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#!/usr/bin/env bash

groupadd --gid ${BUILDER_GID} --force ${BUILDER_NAME}
adduser --disabled-password --gecos '' --no-create-home $BUILDER_NAME --uid ${BUILDER_UID} --gid ${BUILDER_GID}
adduser $BUILDER_NAME sudo
echo "$BUILDER_NAME ALL=(ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/$BUILDER_NAME

# there may be a better way to continue building as a user builder with the same UID and GID as the host runner
su -m $BUILDER_NAME << 'EOF'
echo "User: $(whoami)"
WORKSPACE=$(pwd)
echo "Workspace directory: ${WORKSPACE}"
delete_linux_depends=false
build_focal=true
build_windows=true
build_macos=true
download_and_check_macos_sdk() {
url="https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz"
output_file="Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz"
expected_checksum="be17f48fd0b08fb4dcd229f55a6ae48d9f781d210839b4ea313ef17dd12d6ea5"
# Check if file exists
if [[ -f "$output_file" ]]; then
# Calculate checksum of the file
actual_checksum=$(sha256sum "$output_file" 2>/dev/null | awk '{print $1}')
if [[ -n $actual_checksum ]]; then
# Compare checksums
if [[ "$actual_checksum" == "$expected_checksum" ]]; then
echo "MacOS SDK already exists and has the correct checksum. Skipping download."
return
fi
fi
fi
echo "Downloading MacOS SDK ..."
# Download the file
curl -L -o "$output_file" "$url"
# Calculate checksum of the downloaded file
actual_checksum=$(sha256sum "$output_file" | awk '{print $1}')
# Compare checksums
if [[ "$actual_checksum" != "$expected_checksum" ]]; then
echo "ERROR: Downloaded MacOS SDK has an invalid checksum."
exit 1
fi
echo "MacOS SDK downloaded successfully and has a valid checksum."
}
delete_artefacts() {
local release_name=$1
if [[ "$release_name" = "windows" ]]; then
ext=".exe"
else
ext=""
fi
mkdir -p ${WORKSPACE}/releases/${release_name}
binaries=(
"src/komodod"
"src/wallet-utility"
"src/komodo-tx"
"src/komodo-cli"
"src/komodo-test"
"src/qt/komodo-qt"
)
for binary in "${binaries[@]}"
do
rm -f "${WORKSPACE}/${binary}${ext}" || false
done
echo "Deleting artefacts from ${WORKSPACE} ..."
# delete possible artefacts from previous build(s)
find ${WORKSPACE}/src \( -name "*.a" -o -name "*.la" -o -name "*.o" -o -name "*.lo" -o -name "*.Plo" -o -name "*.Po" -o -name "*.lai" -o -name "*.dirstamp" \) -delete
find ${WORKSPACE}/src \( -name "*.a" -o -name "*.la" -o -name "*.o" -o -name "*.lo" -o -name "*.Plo" -o -name "*.Po" -o -name "*.lai" -o -name "*.dirstamp" \) -path "*/.*" -delete
rm -f ${WORKSPACE}/src/qt/moc_*.cpp # delete meta object code files, otherwise we will have MacOS after Linux/Windows build error
}
copy_release() {
local release_name=$1
if [[ "$release_name" = "windows" ]]; then
ext=".exe"
else
ext=""
fi
mkdir -p ${WORKSPACE}/releases/${release_name}
binaries=(
"src/komodod"
"src/wallet-utility"
"src/komodo-tx"
"src/komodo-cli"
"src/qt/komodo-qt"
)
for binary in "${binaries[@]}"
do
case $release_name in
windows)
bash -c "/usr/bin/x86_64-w64-mingw32-strip ${WORKSPACE}/${binary}${ext}" || false
;;
macos)
bash -c "${WORKSPACE}/depends/x86_64-apple-darwin/native/bin/x86_64-apple-darwin-strip ${WORKSPACE}/${binary}${ext}" || false
;;
*)
strip "${WORKSPACE}/${binary}${ext}" || false
;;
esac
cp -f "${WORKSPACE}/${binary}${ext}" "${WORKSPACE}/releases/${release_name}/"
done
case $release_name in
xenial)
echo "Performing actions for Xenial..."
mv "${WORKSPACE}/releases/${release_name}/komodo-qt" "${WORKSPACE}/releases/${release_name}/komodo-qt-linux"
;;
focal)
echo "Performing actions for Focal..."
mv "${WORKSPACE}/releases/${release_name}/komodo-qt" "${WORKSPACE}/releases/${release_name}/komodo-qt-linux"
;;
windows)
echo "Performing actions for Windows..."
mv "${WORKSPACE}/releases/${release_name}/komodo-qt${ext}" "${WORKSPACE}/releases/${release_name}/komodo-qt-windows${ext}"
;;
macos)
echo "Performing actions for MacOS..."
bash -c "make deploy" || false
cp -f ${WORKSPACE}/*.dmg "${WORKSPACE}/releases/${release_name}/"
mv "${WORKSPACE}/releases/${release_name}/komodo-qt${ext}" "${WORKSPACE}/releases/${release_name}/komodo-qt-mac${ext}"
;;
*)
echo "Unknown release name: $release_name"
;;
esac
}
emulate_build() {
for folder in macos windows focal; do
mkdir -p ${WORKSPACE}/releases/${folder}
for file in komodo-qt komodo-cli komodo-tx wallet-utility komodod; do
extension=""
case ${folder} in
focal)
[[ "$file" == "komodo-qt" ]] && file=${file}-linux
;;
macos)
[[ "$file" == "komodo-qt" ]] && file=${file}-mac
;;
windows)
extension=".exe"
[[ "$file" == "komodo-qt" ]] && file=${file}-windows
;;
esac
echo test > ${WORKSPACE}/releases/${folder}/${file}${extension}
done
done
echo test > ${WORKSPACE}/releases/macos/KomodoOcean-0.8.1-beta1.dmg
}
if true; then
# Check if awk command exists
command -v awk >/dev/null 2>&1 || { echo >&2 "ERROR: awk command not found."; exit 1; }
# Check if sha256sum command exists
command -v sha256sum >/dev/null 2>&1 || { echo >&2 "ERROR: sha256sum command not found."; exit 1; }
### focal
if [[ "${build_focal}" = "true" ]]; then
# delete old depends binaries (from previous linux version, bcz it's x86_64-unknown-linux-gnu also)
if [[ "${delete_linux_depends}" = true ]]; then
rm -rf ${WORKSPACE}/depends/built/x86_64-unknown-linux-gnu
rm -rf ${WORKSPACE}/depends/x86_64-unknown-linux-gnu
fi
# delete possible artefacts from previous build(s)
delete_artefacts focal
bash -c 'zcutil/build.sh -j'$(expr $(nproc) - 1)
copy_release focal
fi
### windows
if [[ "${build_windows}" = "true" ]]; then
delete_artefacts windows
bash -c 'zcutil/build-win.sh -j'$(expr $(nproc) - 1)
copy_release windows
fi
### macos
if [[ "${build_macos}" = "true" ]]; then
download_and_check_macos_sdk
delete_artefacts macos
bash -c 'zcutil/build-mac-cross.sh -j'$(expr $(nproc) - 1)
copy_release macos
fi
else
emulate_build
# all environment variables of docker container are accessible here,
# you can use BUILDER_NAME or GITHUB_SHA, or GITHUB_ACTOR, etc.
fi
EOF


79 changes: 79 additions & 0 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
on:
pull_request:
types:
- opened
- synchronize
- reopened
branches:
- static-experimental
- static
workflow_dispatch:

jobs:
build-project-job:
# Execute on pull requests within the same repository (and not forks) or on manual dispatch
if: ${{ github.actor == 'DeckerSU' && (github.event_name == 'workflow_dispatch' || (github.event.pull_request.head.repo.full_name == github.repository)) }}
runs-on: [self-hosted, Linux, X64]
name: Build project job

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set variables
run: |
echo "branch=$(echo ${{ github.ref }} | sed 's/refs\/heads\///g')" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
echo "builder_name=$(echo $USER)" >> $GITHUB_OUTPUT
echo "builder_uid=$(id -u)" >> $GITHUB_OUTPUT
echo "builder_gid=$(id -g)" >> $GITHUB_OUTPUT
echo "is_fork=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_OUTPUT
id: set_variables_step

- name: Print variables
run: |
echo "Event Type: ${{ github.event_name }}"
echo "Repository name: ${{ github.event.repository.name }}"
echo "Branch: ${{ steps.set_variables_step.outputs.branch }}"
echo "Commit: ${{ steps.set_variables_step.outputs.sha_short }}"
echo "builder_name: ${{ steps.set_variables_step.outputs.builder_name }}"
echo "builder_uid: ${{ steps.set_variables_step.outputs.builder_uid }}"
echo "builder_gid: ${{ steps.set_variables_step.outputs.builder_gid }}"
echo "is_fork: ${{ steps.set_variables_step.outputs.is_fork }}"
- name: Build app in docker container
uses: ./.github/actions/build-project-docker
id: build-in-docker
with:
builder-name: '${{ steps.set_variables_step.outputs.builder_name }}'
builder-uid: '${{ steps.set_variables_step.outputs.builder_uid }}'
builder-gid: '${{ steps.set_variables_step.outputs.builder_gid }}'

# we don't want use strategy / matrix here, bcz in this case matrix will be used
# for entire job and docker containet will be rebuild several times
- name: Archive artifacts (Linux)
uses: actions/upload-artifact@v3
with:
name: komodoocean-linux-${{ steps.set_variables_step.outputs.sha_short }}
path: |
./releases/focal
- name: Archive artifacts (Windows)
uses: actions/upload-artifact@v3
with:
name: komodoocean-windows-${{ steps.set_variables_step.outputs.sha_short }}
path: |
./releases/windows
- name: Archive artifacts (MacOS)
uses: actions/upload-artifact@v3
with:
name: komodoocean-macos-${{ steps.set_variables_step.outputs.sha_short }}
path: |
./releases/macos
- name: Cleanup workspace after build
if: always()
shell: bash
run: |
rm -rf ${{ github.workspace }}/*
1 change: 1 addition & 0 deletions Dockerfile.focal.ci
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ENV TZ=Europe/Amsterdam
RUN \
apt-get update && apt-get install --no-install-recommends -y apt-transport-https ca-certificates curl &&\
sed -i 's/archive\.ubuntu\.com/mirror\.nl\.leaseweb\.net/g' /etc/apt/sources.list &&\
sed -i 's/security\.ubuntu\.com/mirror\.nl\.leaseweb\.net/g' /etc/apt/sources.list &&\
sed -i 's/http:/https:/g' /etc/apt/sources.list &&\
apt-get update && apt-get install -y sudo &&\
groupadd --gid ${BUILDER_GID} --force ${BUILDER_NAME} &&\
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.xenial.ci
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ENV TZ=Europe/Amsterdam
RUN \
apt-get update && apt-get install --no-install-recommends -y apt-transport-https ca-certificates curl &&\
sed -i 's/archive\.ubuntu\.com/mirror\.nl\.leaseweb\.net/g' /etc/apt/sources.list &&\
sed -i 's/security\.ubuntu\.com/mirror\.nl\.leaseweb\.net/g' /etc/apt/sources.list &&\
sed -i 's/http:/https:/g' /etc/apt/sources.list &&\
apt-get update && apt-get install -y sudo &&\
groupadd --gid ${BUILDER_GID} --force ${BUILDER_NAME} &&\
Expand Down
4 changes: 2 additions & 2 deletions build_releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ copy_release() {
check_image_focal() {
if [[ "${force_rebuild_containers}" == "true" || "$(docker images --format '{{.Repository}}' | grep -c ocean_focal_builder)" -eq 0 ]]; then
echo "Container 'ocean_focal_builder' rebuilding ..."
docker build -f Dockerfile.focal.ci --build-arg BUILDER_NAME=$USER --build-arg BUILDER_UID=$(id -u) --build-arg BUILDER_GID=$(id -g) -t ocean_focal_builder .
docker build --no-cache -f Dockerfile.focal.ci --build-arg BUILDER_NAME=$USER --build-arg BUILDER_UID=$(id -u) --build-arg BUILDER_GID=$(id -g) -t ocean_focal_builder .
fi
}

check_image_xenial() {
if [[ "${force_rebuild_containers}" == "true" || "$(docker images --format '{{.Repository}}' | grep -c ocean_xenial_builder)" -eq 0 ]]; then
echo "Container 'ocean_xenial_builder' rebuilding ..."
docker build -f Dockerfile.xenial.ci --build-arg BUILDER_NAME=$USER --build-arg BUILDER_UID=$(id -u) --build-arg BUILDER_GID=$(id -g) -t ocean_xenial_builder .
docker build --no-cache -f Dockerfile.xenial.ci --build-arg BUILDER_NAME=$USER --build-arg BUILDER_UID=$(id -u) --build-arg BUILDER_GID=$(id -g) -t ocean_xenial_builder .
fi
}

Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 8)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_YEAR, 2024)
define(_COPYRIGHT_HOLDERS, "The %s developers")
define(_COPYRIGHT_HOLDERS_SUBSTITUTION, "Ocean and Decker")

Expand Down
2 changes: 1 addition & 1 deletion depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SDK_PATH ?= $(BASEDIR)/SDKs
NO_QT ?=
NO_WALLET ?=
NO_UPNP ?=
FALLBACK_DOWNLOAD_PATH ?= https://supernet/depends-sources
FALLBACK_DOWNLOAD_PATH ?= https://download.kmd.sh/depends-sources

BUILD ?= $(shell ./config.guess)
HOST ?= $(BUILD)
Expand Down
4 changes: 2 additions & 2 deletions depends/funcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ endef
define fetch_file
(test -f $$($(1)_source_dir)/$(4) || \
( mkdir -p $$($(1)_download_dir) && echo Fetching $(1)... && \
( $(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(PRIORITY_DOWNLOAD_PATH)/$(4)" || \
$(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(2)/$(3)" ) && \
( $(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(2)/$(3)" || \
$(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(FALLBACK_DOWNLOAD_PATH)/$(4)" ) && \
echo "$(5) $$($(1)_download_dir)/$(4).temp" > $$($(1)_download_dir)/.$(4).hash && \
$(build_SHA256SUM) -c $$($(1)_download_dir)/.$(4).hash && \
mv $$($(1)_download_dir)/$(4).temp $$($(1)_source_dir)/$(4) && \
Expand Down
Loading

0 comments on commit 281f59e

Please sign in to comment.