Skip to content

build: static link libstdc++ #69

build: static link libstdc++

build: static link libstdc++ #69

Workflow file for this run

name: Release
on:
push:
tags:
- v*.*.*
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [
{ node: 20.9.0, electron: 29.1.4, openssl: 1.1.1w }
]
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
with:
node-version: ${{ matrix.version.node }}
cache: 'npm'
- name: Setup (linux)
if: matrix.os == 'ubuntu-latest'
# git >= 2.18 required for actions/checkout git support
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install -y git build-essential clang python3 libssl-dev libkrb5-dev libc++-dev
echo "npm_config_openssl_dir=${{ github.workspace }}/openssl-${{ matrix.version.openssl }}/build" >> "$GITHUB_ENV"
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Cache Openssl (linux)
if: matrix.os == 'ubuntu-latest'
id: cache-openssl
uses: actions/cache@v4
with:
path: openssl-${{ matrix.version.openssl }}
key: ${{ runner.os }}-openssl-${{ matrix.version.openssl }}
- name: Build Openssl (linux)
if: matrix.os == 'ubuntu-latest' && steps.cache-openssl.outputs.cache-hit != 'true'
run: |
wget -qO- https://www.openssl.org/source/openssl-${{ matrix.version.openssl }}.tar.gz | tar -xz
cd openssl-${{ matrix.version.openssl }}
./config --prefix=${{ github.workspace }}/openssl-${{ matrix.version.openssl }}/build --openssldir=${{ github.workspace }}/openssl-${{ matrix.version.openssl }}/build
make
make install
- name: Setup (macos)
if: matrix.os == 'macos-latest'
run: |
echo "npm_config_openssl_dir=/usr/local/opt/[email protected]" >> "$GITHUB_ENV"
- name: Setup (windows)
if: matrix.os == 'windows-latest'
run: |
echo "npm_config_msvs_version=2022" >> $env:GITHUB_ENV
echo "npm_config_openssl_dir=C:\Program Files\OpenSSL" >> $env:GITHUB_ENV
- name: Install
env:
CC: clang
CXX: clang++ -static-libgcc -static-libstdc++
npm_config_clang: 1
GYP_DEFINES: use_obsolete_asm=true
NODEGIT_OPENSSL_STATIC_LINK: 1
run: npm ci --arch=x64 --runtime=electron --target=${{ matrix.version.electron }} --target_arch=x64 --disturl=https://electronjs.org/headers --build_from_source=true
- name: Deploy
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm install -g @mapbox/node-pre-gyp
node lifecycleScripts/clean
npx node-pre-gyp package --runtime=electron --target=${{ matrix.version.electron }}
npx node-pre-gyp-github publish
- name: Setup (macos M1)
if: matrix.os == 'macos-latest'
run: |
brew install grep
brew uninstall --ignore-dependencies [email protected]
FILE=$(brew fetch --force --bottle-tag=arm64_big_sur [email protected] | ggrep -oP '(?<=Downloaded to\: ).*')
echo "$FILE"
brew install "$FILE"
- name: Install (macos M1)
if: matrix.os == 'macos-latest'
env:
CC: clang
CXX: clang++
CFLAGS: -target arm64-apple-macos11
npm_config_clang: 1
GYP_DEFINES: use_obsolete_asm=true
NODEGIT_OPENSSL_STATIC_LINK: 1
run: npm ci --arch=arm64 --runtime=electron --target=${{ matrix.version.electron }} --target_arch=arm64 --disturl=https://electronjs.org/headers --build_from_source=true
- name: Deploy (macos M1)
if: matrix.os == 'macos-latest'
env:
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm install -g @mapbox/node-pre-gyp
node lifecycleScripts/clean
npx node-pre-gyp package --runtime=electron --target=${{ matrix.version.electron }} --arch=arm64 --target_arch=arm64
npx node-pre-gyp-github publish
- name: Prepare artifact for upload
if: matrix.os == 'ubuntu-latest'
run: |
touch artifact.tar.gz
tar -zcf artifact.tar.gz --exclude=artifact.tar.gz .
- name: Upload artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: build-ubuntu
path: artifact.tar.gz
if-no-files-found: error
retention-days: 5
publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: build-ubuntu
- name: Extract artifact
run: tar -xzf artifact.tar.gz
- name: Publish
env:
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_PUBLISH_TOKEN}
npm publish --access public