Skip to content

Commit

Permalink
Static linkage of OpenVPN3 desktop binaries
Browse files Browse the repository at this point in the history
[openvpn]
  • Loading branch information
outspace committed Nov 15, 2023
1 parent 03cf14c commit f97eb02
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 5 deletions.
43 changes: 41 additions & 2 deletions .github/workflows/build_openvpn_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
Build-OpenVPN3-Linux:
name: 'Build-OpenVPN3-Ubuntu'
runs-on: ubuntu-20.04

if: |
contains(github.event.head_commit.message, '[all]') ||
contains(github.event.head_commit.message, '[linux]') ||
Expand All @@ -138,6 +139,9 @@ jobs:
O3: "${{ github.workspace }}/O3"
DEP_DIR: "${{ github.workspace }}/O3/deps"
DL: "${{ github.workspace }}/O3/dl"
CFLAGS: "-static-libgcc -g -O1 -ldl"
OPEN_SSL_VER: "1.1.1t"

steps:
- name: Set up build environment
uses: awalsh128/cache-apt-pkgs-action@latest
Expand Down Expand Up @@ -165,13 +169,28 @@ jobs:
cd core/scripts/linux/
./build-all
- name: Build OpenSSL
run: |
curl https://www.openssl.org/source/openssl-${OPEN_SSL_VER}.tar.gz | tar zx
cd openssl-${OPEN_SSL_VER}
./Configure no-shared no-tests linux-x86_64 enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp -static-libgcc --openssldir=/usr/local/lib
echo "************************************************"
echo "******** Compiling OpenSSL..."
echo "************************************************"
make
echo "************************************************"
echo "******** Copying OpenSSL include folder and static libraries..."
# if you want to use OS-default SHARED openssl libraries - not necessary to compile it.
# Just copy required headers of OpenSSL (include folder)
sudo make install
- name: 'Build the OpenVPN 3 client wrapper'
working-directory: ${{env.O3}}
run: |
cd ${{env.O3}}/core
cp -rf openvpn/plugin/linux/ck-ovpn-plugin.h openvpn/transport/client/pluggable/ck-ovpn-plugin.h
mkdir build && cd build
cmake ..
cmake -DOPENSSL_ROOT_DIR=${{ github.workspace }}/openssl-${OPEN_SSL_VER} -DCMAKE_EXE_LINKER_FLAGS="-ldl -static-libgcc -static " ..
cmake --build . --config Release --target ovpncli
- name: Archive artifacts
Expand Down Expand Up @@ -209,11 +228,31 @@ jobs:
overwrite: true
file_glob: true

ovpn3-release:
name: GitHub Release
needs: Build-OpenVPN3-Linux
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Setup | Checkout
uses: actions/checkout@v2

- name: Setup | Artifacts
uses: actions/download-artifact@v2

- name: Setup | Checksums
run: for file in $(find ./ -name 'o*' ); do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done

- name: Zip ALL
run: for file in *; do zip -r ${file%.*}.zip $file; done

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: openvpn3-linux.zip
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file_glob: true

37 changes: 34 additions & 3 deletions .github/workflows/build_openvpn_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,13 @@ jobs:
contains(github.event.head_commit.message, '[openvpn]')
name: "${{matrix.os}} - ${{matrix.arch}}"

env:
BUILD_DIR: ${{ github.workspace }}/build
OPEN_SSL_VER: "1.1.1t"

steps:
- name: Install dependencies
run: brew install asio cmake jsoncpp lz4 openssl pkg-config
run: brew install asio cmake jsoncpp pkg-config

- name: Creating work-folder
run: |
Expand All @@ -172,14 +175,42 @@ jobs:
repository: amnezia-vpn/openvpn3
ref: win-amezia
path: ${{ github.workspace }}/src/openvpn3

- name: Build OpenSSL
run: |
curl https://www.openssl.org/source/openssl-${OPEN_SSL_VER}.tar.gz | tar zx
cd openssl-${OPEN_SSL_VER}
if [ ${_ARCH} = "arm64" ]; then
./Configure darwin64-arm64-cc no-shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-arm64
else
./Configure darwin64-x86_64-cc no-shared enable-ec_nistp_64_gcc_128 no-ssl2 no-ssl3 no-comp --openssldir=/usr/local/ssl/macos-x86_64
fi
echo "************************************************"
echo "******** Compiling OpenSSL..."
echo "************************************************"
make
echo "************************************************"
echo "******** Copying OpenSSL include folder and static libraries..."
sudo make install
- name: Build LZ4
run: |
git clone https://github.com/lz4/lz4
cd lz4
git checkout release
CLFAGS="-mmacosx-version-min=10.6" make
CLFAGS="-mmacosx-version-min=10.6" sudo make install
sudo rm /usr/local/lib/liblz*.dylib
- name: Build MacOS OpenVPN3
run: |
cd ${{ github.workspace }}/src/
mkdir build-openvpn3
cd build-openvpn3
cp -rf ${{ github.workspace }}/src/openvpn3/openvpn/plugin/darwin/ck-ovpn-plugin.h ${{ github.workspace }}/src/openvpn3/openvpn/transport/client/pluggable/ck-ovpn-plugin.h
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DCMAKE_PREFIX_PATH=/usr/local/opt ${{ github.workspace }}/src/openvpn3
cmake -DOPENSSL_ROOT_DIR=${{ github.workspace }}/openssl-${OPEN_SSL_VER} -DCMAKE_PREFIX_PATH=/usr/local/opt ${{ github.workspace }}/src/openvpn3
cmake --build . --config Release --target ovpncli
- name: Archive artifacts
Expand Down

0 comments on commit f97eb02

Please sign in to comment.