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/"
0 commit comments