hyper/.github/workflows/nodejs.yml
Labhansh Agrawal 5ec276ea1f use actions/cache for yarn cache
fixes yarn cache on windows ci job
cleanup build step
2023-06-14 23:37:32 +05:30

99 lines
3.5 KiB
YAML

name: Node CI
on:
push:
branches:
- master
- canary
pull_request:
defaults:
run:
shell: bash
env:
NODE_VERSION: 18.x
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
runs-on: ${{matrix.os}}
strategy:
matrix:
os:
- macos-12
- ubuntu-20.04
- windows-latest
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache/restore@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install
run: yarn install
- name: Lint and Run Unit Tests
run: yarn run test
- name: Getting Build Icon
if: github.ref == 'refs/heads/canary' || github.base_ref == 'canary'
run: |
cp build/canary.ico build/icon.ico
cp build/canary.icns build/icon.icns
- name: Set Environment variables
run: |
if [ ! -z "$CSC_LINK" ] ; then echo "CSC_LINK=$CSC_LINK" >> $GITHUB_ENV ; fi
if [ ! -z "$CSC_KEY_PASSWORD" ] ; then echo "CSC_KEY_PASSWORD=$CSC_KEY_PASSWORD" >> $GITHUB_ENV ; fi
if [ ! -z "$WIN_CSC_LINK" ] ; then echo "WIN_CSC_LINK=$WIN_CSC_LINK" >> $GITHUB_ENV ; fi
if [ ! -z "$WIN_CSC_KEY_PASSWORD" ] ; then echo "WIN_CSC_KEY_PASSWORD=$WIN_CSC_KEY_PASSWORD" >> $GITHUB_ENV ; fi
if [ ! -z "$APPLE_ID" ] ; then echo "APPLE_ID=$APPLE_ID" >> $GITHUB_ENV ; fi
if [ ! -z "$APPLE_APP_SPECIFIC_PASSWORD" ] ; then echo "APPLE_APP_SPECIFIC_PASSWORD=$APPLE_APP_SPECIFIC_PASSWORD" >> $GITHUB_ENV ; fi
env:
CSC_LINK: ${{ secrets.MAC_CERT_P12_BASE64 }}
CSC_KEY_PASSWORD: ${{ secrets.MAC_CERT_P12_PASSWORD }}
WIN_CSC_LINK: ${{ secrets.WIN_CERT_P12_BASE64 }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CERT_P12_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
- name: Build
run: yarn run dist
- name: Archive Build Artifacts
uses: LabhanshAgrawal/upload-artifact@v3
with:
path: |
dist/*.dmg
dist/*.snap
dist/*.AppImage
dist/*.deb
dist/*.rpm
dist/*.exe
- name: Run E2E Tests
if: runner.os != 'Linux'
run: yarn run test:e2e
- name: Archive E2E test screenshot
if: runner.os != 'Linux'
uses: actions/upload-artifact@v3
with:
name: e2e
path: dist/tmp/*.png
- name: Save the pr number in an artifact
if: github.event_name == 'pull_request'
env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
- name: Upload the pr num
uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request'
with:
name: pr_num
path: ./pr_num.txt
- uses: actions/cache/save@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock', 'app/yarn.lock') }}