Node.js CI #35
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Node.js CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
inputs: | |
release: | |
description: "Build for release?" | |
required: true | |
default: false | |
type: boolean | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- run: npm ci | |
- run: npm test | |
- run: npm run lint | |
- name: Get version | |
id: fungus-version | |
uses: martinbeentjes/[email protected] | |
outputs: | |
version: ${{ steps.fungus-version.outputs.current-version }} | |
build_release: | |
if: ${{ inputs.release }} | |
needs: test | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { os: macos-12 , os-name: macos } | |
- { os: windows-2022, os-name: windows } | |
- { os: ubuntu-22.04, os-name: linux } | |
steps: | |
- name: Check out source code | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- run: npm ci | |
- name: Get artifact name | |
id: artifact-name | |
shell: bash | |
run: echo "NAME=fungus-gui-${{ needs.test.outputs.version }}-${{ matrix.job.os-name }}" >> "$GITHUB_OUTPUT" | |
- name: Install dependencies for building dmg | |
if: runner.os == 'macOS' | |
shell: bash | |
# https://github.com/actions/runner/issues/2958#issuecomment-1852627308 | |
run: sudo -H pip install setuptools && npm install appdmg | |
- run: npm run make | |
- name: Upload zip artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact-name.outputs.NAME }}.zip | |
path: out/make/zip/**/*.zip | |
if-no-files-found: error | |
- name: Upload squirrel artifact | |
if: runner.os == 'Windows' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact-name.outputs.NAME }}-squirrel.zip | |
path: out/make/squirrel.windows/ | |
if-no-files-found: error | |
- name: Upload deb artifact | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact-name.outputs.NAME }}.deb | |
path: out/make/deb/x64/fungus-gui_${{ needs.test.outputs.version }}_amd64.deb | |
if-no-files-found: error | |
- name: Upload rpm artifact | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact-name.outputs.NAME }}.rpm | |
path: out/make/rpm/x64/fungus-gui-${{ needs.test.outputs.version }}-1.x86_64.rpm | |
if-no-files-found: error | |
- name: Upload dmg artifact | |
if: runner.os == 'macOS' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact-name.outputs.NAME }}.dmg | |
path: out/make/fungus-gui-${{ needs.test.outputs.version }}-x64.dmg | |
if-no-files-found: error |