Skip to content

Commit 322935a

Browse files
ci: add docker, native binaries build (#2)
* ci: add docker build * ci: add build + release workflow * build: avoid LIBCURL_CHECK_CONFIG Does not work on neither CI nor my local machine. * build: allow setting LIBCURL
1 parent b283f15 commit 322935a

3 files changed

Lines changed: 336 additions & 2 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
pull_request:
9+
10+
jobs:
11+
# Build and push ALL events. We'll make sure to give the images
12+
# sensible tags, so there's no confusion around what's 'dev' builds
13+
# through PRs, and what's proper 'master' builds.
14+
#
15+
# Official GitHub docs on this: https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images
16+
build-push-docker:
17+
runs-on: ubuntu-latest-large
18+
# needed to push to GHCR
19+
permissions:
20+
contents: read
21+
packages: write
22+
attestations: write
23+
id-token: write
24+
steps:
25+
- name: Docker meta
26+
id: meta
27+
# https://github.com/docker/metadata-action
28+
uses: docker/metadata-action@v5
29+
with:
30+
images: |
31+
ghcr.io/${{ github.repository_owner }}/cpuminer
32+
# generate Docker tags based on the following events/attributes
33+
tags: |
34+
# creates a tag for each push
35+
type=sha,event=push
36+
37+
# creates a tag for each pr
38+
type=ref,event=pr
39+
40+
# set latest tag for default branch
41+
type=raw,value=latest,enable={{is_default_branch}}
42+
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
46+
- name: Login to GHCR
47+
uses: docker/login-action@v3
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.repository_owner }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- uses: actions/checkout@v4
54+
with:
55+
submodules: "recursive"
56+
57+
- name: Build (and maybe push) Docker image
58+
uses: docker/build-push-action@v6
59+
with:
60+
# Only push if this is not a PR from a fork
61+
# prettier-ignore
62+
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
63+
tags: ${{ steps.meta.outputs.tags }}
64+
# Caching Docker builds on CI is an eternally
65+
# difficult task. From the official docs:
66+
# "In most cases you want to use the inline cache exporter"
67+
#
68+
# https://docs.docker.com/build/ci/github-actions/cache/#inline-cache
69+
# prettier-ignore
70+
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cpuminer:latest
71+
cache-to: type=inline
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
name: Build, release and upload to releases.drivechain.info
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-release:
12+
# No windows build for now. Built-in Windows anti virus really
13+
# doesn't like the binary!
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
name: x86_64-unknown-linux-gnu
20+
21+
- os: macos-latest-large
22+
name: x86_64-apple-darwin
23+
24+
name: Build and release (${{ matrix.name }})
25+
runs-on: ${{ matrix.os }}
26+
permissions:
27+
contents: write
28+
timeout-minutes: 20
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
submodules: "recursive"
33+
34+
- name: Build static OpenSSL
35+
run: |
36+
# Download and build OpenSSL statically
37+
OPENSSL_VERSION="3.3.3"
38+
curl -L https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -o openssl.tar.gz
39+
tar xzf openssl.tar.gz
40+
cd openssl-${OPENSSL_VERSION}
41+
42+
if [ "${{ matrix.os }}" = "macos-latest-large" ]; then
43+
brew install automake
44+
./Configure darwin64-x86_64-cc \
45+
--prefix=$HOME/openssl-static \
46+
--openssldir=$HOME/openssl-static/ssl \
47+
no-shared \
48+
no-zlib \
49+
no-weak-ssl-ciphers
50+
else
51+
# Linux
52+
sudo apt-get update
53+
sudo apt-get install -y zlib1g-dev
54+
./Configure linux-x86_64 \
55+
--prefix=$HOME/openssl-static \
56+
--openssldir=$HOME/openssl-static/ssl \
57+
no-shared \
58+
no-zlib \
59+
no-weak-ssl-ciphers
60+
fi
61+
62+
make -j
63+
make install_sw
64+
cd ..
65+
66+
- name: Build static curl
67+
run: |
68+
# Download and build curl statically for portability
69+
curl -L https://curl.se/download/curl-8.11.0.tar.gz -o curl.tar.gz
70+
tar xzf curl.tar.gz
71+
cd curl-8.11.0
72+
73+
# Common configure flags - minimal build with just what we need
74+
CURL_CONFIG_FLAGS="--disable-shared --enable-static"
75+
CURL_CONFIG_FLAGS="$CURL_CONFIG_FLAGS --prefix=$HOME/curl-static"
76+
CURL_CONFIG_FLAGS="$CURL_CONFIG_FLAGS --disable-ldap --disable-ldaps"
77+
CURL_CONFIG_FLAGS="$CURL_CONFIG_FLAGS --without-librtmp"
78+
CURL_CONFIG_FLAGS="$CURL_CONFIG_FLAGS --without-libpsl --without-brotli --without-zstd"
79+
CURL_CONFIG_FLAGS="$CURL_CONFIG_FLAGS --without-libidn2 --without-nghttp2 --without-nghttp3"
80+
81+
# Use our statically built OpenSSL
82+
CURL_CONFIG_FLAGS="$CURL_CONFIG_FLAGS --with-openssl=$HOME/openssl-static"
83+
# Force static linking of OpenSSL
84+
export LDFLAGS="-L$HOME/openssl-static/lib"
85+
export CPPFLAGS="-I$HOME/openssl-static/include"
86+
export PKG_CONFIG_PATH="$HOME/openssl-static/lib/pkgconfig"
87+
88+
./configure $CURL_CONFIG_FLAGS
89+
90+
make -j
91+
make install
92+
93+
# Verify curl was built without rtmp
94+
if $HOME/curl-static/bin/curl-config --static-libs | grep -q rtmp; then
95+
echo "ERROR: curl-config includes rtmp in static libs!"
96+
exit 1
97+
fi
98+
99+
# Verify curl links OpenSSL statically (no dylib references for macOS)
100+
if [ "${{ matrix.os }}" = "macos-latest-large" ]; then
101+
if otool -L $HOME/curl-static/lib/libcurl.a 2>/dev/null | grep -q "libssl\|libcrypto"; then
102+
echo "WARNING: curl static library may have dynamic OpenSSL dependencies"
103+
fi
104+
fi
105+
106+
cd ..
107+
108+
- name: Build
109+
run: |
110+
./autogen.sh
111+
112+
# Set common flags
113+
export CFLAGS="-O3"
114+
CONFIGURE_OPTS=""
115+
116+
# Use our statically built curl and OpenSSL
117+
export PKG_CONFIG_PATH="$HOME/curl-static/lib/pkgconfig:$HOME/openssl-static/lib/pkgconfig"
118+
export CURL_CONFIG="$HOME/curl-static/bin/curl-config"
119+
120+
# Get static libs from curl-config (should not include rtmp since we built without it)
121+
export LIBCURL="$($CURL_CONFIG --static-libs)"
122+
export LIBCURL_CPPFLAGS="$($CURL_CONFIG --cflags)"
123+
124+
# macOS doesn't support -static flag (Linux-only)
125+
if [ "${{ matrix.os }}" = "macos-latest-large" ]; then
126+
# macOS needs CoreFoundation frameworks for curl's macOS-specific features
127+
# Link OpenSSL statically by using full paths to .a files
128+
export LDFLAGS="-L$HOME/curl-static/lib -L$HOME/openssl-static/lib -framework CoreFoundation -framework CoreServices -framework SystemConfiguration"
129+
# Override any dynamic OpenSSL libs from curl-config with static ones
130+
OPENSSL_LIB_DIR="$HOME/openssl-static/lib"
131+
export LIBCURL="$(echo $LIBCURL | sed "s|-lssl|-L${OPENSSL_LIB_DIR} ${OPENSSL_LIB_DIR}/libssl.a|g" | sed "s|-lcrypto|-L${OPENSSL_LIB_DIR} ${OPENSSL_LIB_DIR}/libcrypto.a|g")"
132+
CONFIGURE_OPTS="--disable-assembly"
133+
else
134+
# Linux - use full static linking
135+
# OpenSSL on 64-bit Linux installs to lib64, check both lib and lib64
136+
export LDFLAGS="-L$HOME/curl-static/lib -L$HOME/openssl-static/lib -L$HOME/openssl-static/lib64 -static"
137+
# Filter out rtmp, ssl, and crypto from LIBCURL
138+
export LIBCURL="$(echo $LIBCURL | sed 's/-lrtmp//g' | sed 's/-lssl//g' | sed 's/-lcrypto//g' | sed 's/ */ /g' | sed 's/^ *//;s/ *$//')"
139+
# Add OpenSSL static libraries explicitly - check lib64 first (64-bit Linux default), then lib
140+
if [ -f "$HOME/openssl-static/lib64/libssl.a" ]; then
141+
OPENSSL_LIB_DIR="$HOME/openssl-static/lib64"
142+
else
143+
OPENSSL_LIB_DIR="$HOME/openssl-static/lib"
144+
fi
145+
export LIBCURL="$LIBCURL ${OPENSSL_LIB_DIR}/libssl.a ${OPENSSL_LIB_DIR}/libcrypto.a"
146+
fi
147+
148+
./configure $CONFIGURE_OPTS
149+
150+
make -j
151+
152+
# Verify dependencies
153+
if [ "${{ matrix.os }}" = "macos-latest-large" ]; then
154+
echo "macOS dependencies:"
155+
otool -L minerd
156+
# Fail if rtmp is still linked
157+
if otool -L minerd | grep -q rtmp; then
158+
echo "ERROR: Binary still links to librtmp!"
159+
exit 1
160+
fi
161+
# Fail if OpenSSL is dynamically linked
162+
if otool -L minerd | grep -q "libssl\|libcrypto"; then
163+
echo "ERROR: Binary dynamically links to OpenSSL!"
164+
exit 1
165+
fi
166+
167+
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
168+
echo "Linux dependencies:"
169+
# With -static flag, binary should be statically linked
170+
# Check ldd output for verification
171+
if ldd minerd 2>&1 | grep -qi "not a dynamic executable\|statically linked"; then
172+
echo "SUCCESS: Binary is statically linked"
173+
elif ! ldd minerd >/dev/null 2>&1; then
174+
# ldd failed, which means static binary (expected behavior)
175+
echo "SUCCESS: Binary is statically linked (ldd cannot read it, which is expected)"
176+
else
177+
# ldd succeeded, check for problematic libraries
178+
LDD_OUTPUT=$(ldd minerd 2>&1)
179+
echo "ldd output:"
180+
echo "$LDD_OUTPUT"
181+
# Only fail if we see actual .so library files for rtmp/ssl/crypto
182+
if echo "$LDD_OUTPUT" | grep -qiE "(librtmp|libssl|libcrypto)\.so"; then
183+
echo "ERROR: Binary dynamically links to rtmp/ssl/crypto!"
184+
exit 1
185+
else
186+
echo "Note: Binary may have some system library dependencies, but not rtmp/ssl/crypto"
187+
fi
188+
fi
189+
# Show file type
190+
echo ""
191+
file minerd || true
192+
fi
193+
194+
# verify we can boot the binary
195+
./minerd --version
196+
197+
- name: "Set environment variables: version number and output filenames"
198+
run: |
199+
APP_DIRNAME="minerd-latest-${{ matrix.name }}"
200+
APP_FILENAME="${APP_DIRNAME}"
201+
echo "APP_FILENAME=$APP_FILENAME" >> "$GITHUB_ENV"
202+
echo "APP_DIRNAME=$APP_DIRNAME" >> "$GITHUB_ENV"
203+
204+
- run: |
205+
mkdir release
206+
cp minerd release/${{ env.APP_FILENAME }}
207+
208+
- name: "Upload artifacts"
209+
uses: actions/upload-artifact@v4
210+
with:
211+
name: ${{ env.APP_DIRNAME }}
212+
if-no-files-found: error
213+
path: |
214+
release/${{ env.APP_FILENAME }}
215+
216+
- name: Release
217+
uses: softprops/action-gh-release@v2.0.2
218+
if: startsWith(github.ref, 'refs/tags/')
219+
with:
220+
files: |
221+
release/${{ env.APP_FILENAME }}
222+
fail_on_unmatched_files: true
223+
224+
upload-releases-to-releases-drivechain-info:
225+
name: Upload releases to releases.drivechain.info
226+
runs-on: ubuntu-latest
227+
needs: [build-release]
228+
if: github.ref == 'refs/heads/master'
229+
steps:
230+
- name: Download artifacts
231+
uses: actions/download-artifact@v4
232+
233+
- name: Create zip files for releases.drivechain.info
234+
run: |
235+
shopt -s extglob
236+
zip -r minerd-latest-x86_64-apple-darwin.zip minerd-latest-x86_64-apple-darwin
237+
zip -r minerd-latest-x86_64-unknown-linux-gnu.zip minerd-latest-x86_64-unknown-linux-gnu
238+
239+
- name: Upload release assets to releases.drivechain.info
240+
uses: appleboy/scp-action@v1
241+
with:
242+
host: 45.33.96.47
243+
username: root
244+
password: ${{ secrets.RELEASES_SERVER_PW }}
245+
port: 22
246+
source: "minerd-latest-*.zip"
247+
target: "/var/www/html/"

configure.ac

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,24 @@ else
120120
JANSSON_LIBS=-ljansson
121121
fi
122122

123-
LIBCURL_CHECK_CONFIG([curl], 7.15.2, ,
124-
[AC_MSG_ERROR([Missing required libcurl >= 7.15.2])])
123+
dnl Check for libcurl
124+
AC_PATH_PROG([CURL_CONFIG], [curl-config], [no])
125+
if test "$CURL_CONFIG" = "no"; then
126+
AC_MSG_ERROR([curl-config not found. Please install libcurl development files.])
127+
fi
128+
129+
LIBCURL_CPPFLAGS=`$CURL_CONFIG --cflags`
130+
if test -z "$LIBCURL"; then
131+
LIBCURL=`$CURL_CONFIG --libs`
132+
fi
133+
134+
dnl Check libcurl version
135+
LIBCURL_VERSION=`$CURL_CONFIG --version | sed 's/libcurl *//'`
136+
AC_MSG_CHECKING([for libcurl >= 7.15.2])
137+
AC_MSG_RESULT([$LIBCURL_VERSION])
138+
139+
AC_SUBST(LIBCURL_CPPFLAGS)
140+
AC_SUBST(LIBCURL)
125141

126142
AC_SUBST(JANSSON_LIBS)
127143
AC_SUBST(PTHREAD_FLAGS)

0 commit comments

Comments
 (0)