Skip to content

ESLint: Cache results #235

ESLint: Cache results

ESLint: Cache results #235

Workflow file for this run

# 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://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: main
workflow_dispatch:
jobs:
check:
name: Test
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
node-version: [18.x]
runs-on: ${{ matrix.platform }}
outputs:
source_any_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check changed files
id: changed-files
uses: tj-actions/changed-files@v35.6.3
with:
files: |
src/**
types/**
package.json
package-lock.json
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build files
run: npm run prepublishOnly
- name: Run CI
run: npm run ci
- name: Test
run: npm run tsc:test && npm test
env:
TEST_BOT_NAME: ${{ secrets.TEST_BOT_NAME }}
TEST_BOT_PASS: ${{ secrets.TEST_BOT_PASS }}
publish:
name: Publish
needs: check
if: (success() && github.repository_owner == 'dirain1700' &&
needs.check.outputs.source_any_changed == 'true') ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
scope: "@dirain"
always-auth: true
- name: Install dependencies
run: npm ci
- name: Check previous dev package
id: check-prev
uses: actions/github-script@v6
with:
script: |
const { execSync } = require("child_process");
const { name } = require("./package.json");
core.setOutput("PACK_NAME", name);
try {
const version = execSync("npm info " + name + "@dev version");
if (!version) return;
core.setOutput("PRE_VERSION", version.toString().replaceAll("\n", ""));
} catch(e) {}
- name: Deprecate Previous version of the package
if: steps.check-prev.outputs.PRE_VERSION
run: npm deprecate ${{ steps.check-prev.outputs.PACK_NAME }}@${{ steps.check-prev.outputs.PRE_VERSION }} "This dev version has been deprecated automatically. Please use newest one."
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Update package version
run: npm version prerelease --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)" --no-git-tag-version
# Running build is not needed because this package has prepublishOnly
- name: Publish a package
run: npm publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}