setup-cpp/.github/workflows/CI.yml

159 lines
4.4 KiB
YAML

name: CI
on:
pull_request:
push:
branches:
- master
- main
- dev
tags:
- "*"
jobs:
Test:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-2022
- windows-2019
- ubuntu-22.04
- ubuntu-20.04
- ubuntu-18.04
- macos-12
- macos-11
cache_reset_counter:
- 0
node:
- 12
- 16
- 18
include:
- node: 12
pnpm: 6
skip_test: true
- node: 16
pnpm: 7
- node: 18
pnpm: 8
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: |
"setupcpp-cache-OS:${{ matrix.os }}-"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ matrix.pnpm }}
- name: Install and build
run: |
pnpm install
# - name: Setup SSH debugging session
# uses: mxschmitt/action-tmate@v3
- name: Test
if: "${{ !contains(github.event.head_commit.message, '[skip test]') && !matrix.skip_test }}"
run: |
pnpm run test
continue-on-error: ${{ contains(matrix.os, 'ubuntu-18.04') }}
# Create self-contained executable that bundles Nodejs
- name: Create Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12')"
run: |
pnpm run pack.exe
- name: Upload Artifacts
if: ${{ (startsWith(github.ref, 'refs/tags/')) && contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12') }}
uses: actions/upload-artifact@v3
with:
path: |
./exe
./dist
retention-days: 1
Release:
needs: Test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Place Artifacts
run: |
mv -v artifact/* ./
chmod +x -R ./exe/
- name: Draft the release
uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
gzip: folders
draft: true
files: >
./exe/setup-cpp-x64-windows.exe
./exe/setup-cpp-x64-linux
./exe/setup-cpp-x64-macos
./dist/node12/setup-cpp.js
./dist/node12/setup-cpp.js.map
./dist/node12/ # TODO: deprecate node12
./dist/node16/
./dist/node18/
Docker:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip test]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
container:
- "arch_node.dockerfile"
- "fedora_node.dockerfile"
- "ubuntu_20.04_node_legacy.dockerfile"
- "ubuntu_20.04_node.dockerfile"
- "ubuntu_node_legacy.dockerfile"
- "ubuntu_node.dockerfile"
cache_reset_counter:
- 0
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.pnpm-store
D:\.pnpm-store
key: "setupcpp-docker-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}-${{ matrix.cache_reset_counter }}"
restore-keys: |
"setupcpp-docker-cache-OS:${{ matrix.os }}"
- name: Build
id: docker_build
run: |
docker build -f ./dev/docker/${{ matrix.container }} -t setup-cpp .