Build executables #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation | |
# | |
# This program and the accompanying materials are made available under the | |
# terms of the Apache License, Version 2.0 which is available at | |
# https://www.apache.org/licenses/LICENSE-2.0. | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
# License for the specific language governing permissions and limitations | |
# under the License. | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
name: Build executables | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_call: | |
inputs: | |
ref: | |
description: 'Commit ref to use' | |
required: false | |
type: string | |
cliVersion: | |
description: 'CLI package version to compile' | |
required: false | |
type: string | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'Commit ref to use' | |
required: false | |
type: string | |
cliVersion: | |
description: 'CLI package version to compile' | |
required: false | |
type: string | |
env: | |
NODE_VERSION: 20 | |
jobs: | |
compile: | |
strategy: | |
matrix: | |
arch: [arm64, x64] | |
os: [linux, alpine, macos] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Set version in package.json | |
run: | | |
if [ ${{ inputs.cliVersion }} != '' ]; then | |
echo "Set new release version in package.json" | |
VERSION=${{ inputs.cliVersion }} | |
else | |
echo "Set new release version in package.json" | |
VERSION=$GITHUB_SHA | |
fi | |
echo "$(jq --arg VERSION $VERSION '.version=$VERSION' package.json)" > package.json | |
# This step is needed to install needed dependencies (node-pty) for arm based architecture | |
- name: Install dependencies for ARM64 | |
if: ${{ matrix.arch == 'arm64' }} | |
uses: uraimo/run-on-arch-action@v2 | |
with: | |
distro: ubuntu22.04 | |
# Workaround since the genereal manifest was not found | |
base_image: arm64v8/node:${{ env.NODE_VERSION }}-bullseye@sha256:08bc7f3dee8fda489f0846b115dda34c867a16c1836844002eba071edfa810d6 | |
run: | | |
npm install . | |
- name: Install dependencies for AMD64 | |
if: ${{ matrix.arch == 'x64' }} | |
run: | | |
npm install . | |
- name: Compile EXE for ${{ matrix.arch }} | |
run: TARGET=node${{ env.NODE_VERSION }}-${{ matrix.os }}-${{ matrix.arch }} ARCH=${{ matrix.arch }} OS=${{ matrix.os }} npm run compile-exe | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-${{ matrix.arch }} | |
path: velocitas-${{ matrix.os }}-${{ matrix.arch }} |