Files
MapLibreParticleLab/.github/workflows/node-release.yml
tdcosta100 f06f60803c Add windows support (#707)
Co-authored-by: acalcutt <acalcutt@techidiots.net>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
Co-authored-by: Ovidiu Voda <ovi.voda@gmail.com>
2023-02-25 16:12:06 -05:00

312 lines
9.3 KiB
YAML

name: node-release
on:
workflow_dispatch:
inputs:
version:
description: Choose a release type
required: true
type: choice
options:
- prerelease
- prepatch
- preminor
- premajor
- patch
- minor
- major
jobs:
bump_version:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.NODE_PRE_GYP_GITHUB_TOKEN }}
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: npm version
run: |
echo "NPM_VERSION=$(npm version ${{ github.event.inputs.version }} --preid pre --no-git-tag-version)" >> $GITHUB_ENV
- name: Push version to git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git commit -a -m "Update node version to ${{ env.NPM_VERSION }} (${{ github.event.inputs.version }})"
git push
publish_binaries:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-20.04
arch: x86_64
- runs-on: macos-12
arch: x86_64
- runs-on: macos-12-arm
arch: arm64
- runs-on: windows-2022
arch: x86_64
needs: bump_version
continue-on-error: true
env:
BUILDTYPE: ${{github.ref == 'refs/heads/main' && 'Release' || 'Debug'}}
defaults:
run:
working-directory: ./
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Latest Version
run: git pull
- name: Setup submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c core.longpaths=true -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 || true
- name: Get OS Architecture
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: uname -m
- name: Install dependencies (MacOS)
if: runner.os == 'MacOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew list cmake || brew install cmake
brew list ccache || brew install ccache
brew list ninja || brew install ninja
brew list pkg-config || brew install pkg-config
brew list glfw || brew install glfw
brew list libuv || brew install libuv
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y \
ccache \
cmake \
ninja-build \
pkg-config \
xvfb \
libcurl4-openssl-dev \
libglfw3-dev \
libuv1-dev \
g++-10 \
libc++-9-dev \
libc++abi-9-dev
/usr/sbin/update-ccache-symlinks
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: npm ci
run: npm ci --ignore-scripts
- name: Set up msvc dev cmd (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
- name: Update ccache (Windows)
if: runner.os == 'Windows'
run: |
choco.exe upgrade ccache
ccache.exe --version
echo "CCACHE_CONFIGPATH=C:/Users/runneradmin/AppData/Roaming/ccache/ccache.conf" >> $GITHUB_ENV
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}-${{ github.head_ref }}
restore-keys: |
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}-${{ github.sha }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}-${{ github.ref }}
${{ matrix.runs-on }}-${{ env.BUILDTYPE }}-${{ github.job }}
- name: Configure maplibre-gl-native (MacOS)
if: runner.os == 'MacOS'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
- name: Configure maplibre-gl-native (Linux)
if: runner.os == 'Linux'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=gcc-10 \
-DCMAKE_CXX_COMPILER=g++-10
- name: Configure maplibre-gl-native (Windows)
if: runner.os == 'Windows'
run: |
cmake . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache.exe
- name: Build maplibre-gl-native (MacOS/Linux)
if: runner.os == 'MacOS' || runner.os == 'Linux'
run: |
cmake --build build -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)
- name: Build maplibre-gl-native (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
cmake --build build
- name: Publish X64 Release to Github
if: github.ref == 'refs/heads/main' && matrix.arch == 'x86_64'
env:
PUBLISH: true
BUILDTYPE: RelWithDebInfo
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.NODE_PRE_GYP_GITHUB_TOKEN }}
run: |
./platform/node/scripts/publish.sh
- name: Publish ARM Release to Github
if: github.ref == 'refs/heads/main' && matrix.arch == 'arm64'
env:
PUBLISH: true
BUILDTYPE: RelWithDebInfo
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.NODE_PRE_GYP_GITHUB_TOKEN }}
run: |
./platform/node/scripts/publish.sh --target_arch=arm64
publish_npm:
runs-on: ubuntu-20.04
needs: publish_binaries
defaults:
run:
working-directory: ./
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Latest Version
run: git pull
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Publish to NPM (release)
if: github.ref == 'refs/heads/main' && (github.event.inputs.version == 'patch' || github.event.inputs.version == 'minor' || github.event.inputs.version == 'major')
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
- name: Publish to NPM (prerelease)
if: github.ref == 'refs/heads/main' && (github.event.inputs.version == 'prerelease' || github.event.inputs.version == 'prepatch' || github.event.inputs.version == 'preminor' || github.event.inputs.version == 'premajor')
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --tag next --access public
env:
NPM_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
publish_binary_linux_arm64:
runs-on: ubuntu-latest
needs: bump_version
name: publish_binary (ubuntu-20.04, arm64)
env:
DOCKERTAG: node-build-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Get Latest Version
run: git pull
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64'
- name: Install dependencies macOS
if: runner.os == 'macOS'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install docker docker-compose
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Create the docker build image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/arm64
file: platform/node/scripts/Dockerfile_Build
tags: ${{ env.DOCKERTAG }}
push: false
load: true
- name: Run the docker build image and create node libs
run: docker run --rm -v $(pwd):/data ${{ env.DOCKERTAG }}
- name: Clean up the docker build image
if: always()
run: docker rmi $(docker images | grep ${{ env.DOCKERTAG }} | tr -s ' ' | cut -d ' ' -f 3) --force
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: npm ci
run: npm ci --ignore-scripts
- name: Publish ARM Release to Github
env:
PUBLISH: true
BUILDTYPE: RelWithDebInfo
NODE_PRE_GYP_GITHUB_TOKEN: ${{ secrets.NODE_PRE_GYP_GITHUB_TOKEN }}
run: |
./platform/node/scripts/publish.sh --target_platform=linux --target_arch=arm64