All credit for the original work goes to (KnicKnic). This is a detached-fork of https://github.com/KnicKnic/os-specific-run. This version (2.0.0 and beyond) will attempt to stay upto date on the lastest version of NPM and other dependecies.
A github action for running a separate command based on the os
- uses: carlkidcrypto/os-specific-runner@v2.0.0
with:
macos: echo "Hi from macos"
linux: |
echo "Hi from linux"
echo "Hi from linux second line"
windows: echo "Hi from windows"
Enable dependabot to get notifications for updated actions by creating .github/dependabot.yml in your repository with the actions configurations
os | command value |
---|---|
macos | echo "No command specified for macos" |
linux | echo "No command specified for linux" |
windows | echo "No command specified for windows" |
os | command value |
---|---|
macosShell | bash |
linuxShell | bash |
windowsShell | pwsh |
See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell for more details
name: test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
steps:
- uses: actions/checkout@v4
- uses: carlkidcrypto/os-specific-runner@v2.0.0
with:
macos: echo "Hi from macos"
linux: |
echo "Hi from linux"
echo "Hi from linux second line"
windows: echo "Hi from windows"
You can do what this project accomplishes with simple if
statements in github actions.
The problem is you have to figure them out, and they end up creating multiple steps one per each OS. I think a single step (rather than multiple steps in each OS that are not run) looks cleaner and is more obvious what failed. More details on if statements - https://github.community/t/what-is-the-correct-if-condition-syntax-for-checking-matrix-os-version/16221/4
npm install -g npm@10.8.3
npm i -g @vercel/ncc@0.38.2
npm install
npm update
ncc build index.js -m