diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..da72ca8 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +name: build + +on: + push: + branches: + - safe.fiery.me + paths: + - 'src/**/*.css' + - 'src/**/*.js' + - 'src/**/*.scss' + +jobs: + build: + name: Build client assets and bump v1 version string + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: '10.x' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install + + - name: yarn build + run: yarn build + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Rebuilt client assets and bumped v1 version string + env: + CI: true diff --git a/scripts/bump-versions.js b/scripts/bump-versions.js index 7fdd99c..ed5b348 100644 --- a/scripts/bump-versions.js +++ b/scripts/bump-versions.js @@ -1,9 +1,21 @@ const { promisify } = require('util') const fs = require('fs') const path = require('path') -const utils = require('../controllers/utilsController') const self = { + // This is a parallel of utilsController.js->stripIndents(). + // Added here so that this script won't have to import the said controller. + stripIndents: string => { + if (!string) return + const result = string.replace(/^[^\S\n]+/gm, '') + const match = result.match(/^[^\S\n]*(?=\S)/gm) + const indent = match && Math.min(...match.map(el => el.length)) + if (indent) { + const regexp = new RegExp(`^.{${indent}}`, 'gm') + return result.replace(regexp, '') + } + return result + }, access: promisify(fs.access), readFile: promisify(fs.readFile), writeFile: promisify(fs.writeFile), @@ -33,7 +45,7 @@ const self = { } if (args.includes('--help') || args.includes('-h') || !Object.keys(self.types).length) - return console.log(utils.stripIndents(` + return console.log(self.stripIndents(` Bump version strings for client-side assets. Usage: