Skip to content

chore: update build from https://github.com/dimaslanjaka/hexo-post-pa… #245

chore: update build from https://github.com/dimaslanjaka/hexo-post-pa…

chore: update build from https://github.com/dimaslanjaka/hexo-post-pa… #245

Workflow file for this run

name: Build Release
# automated build dist and tarball
# repo : https://github.com/dimaslanjaka/nodejs-package-types/blob/main/.github/workflows/build-release.yml
# raw : https://raw.githubusercontent.com/dimaslanjaka/nodejs-package-types/main/.github/workflows/build-release.yml
# update : curl -L https://github.com/dimaslanjaka/nodejs-package-types/raw/main/.github/workflows/build-release.yml > .github/workflows/build-release.yml
on:
push:
branches: ['master', 'main', 'private']
paths-ignore:
- '**/*.tgz'
- '**/*.gz'
- '**/release/**'
- '**garbage-collector**'
- '**codeql**'
- '**/.github/workflows/tester.yml'
pull_request:
types:
- closed
paths-ignore:
- '**/release/**'
- '**/*.tgz'
- '**/*.gz'
- '**/test*/**'
workflow_dispatch:
# run single job
concurrency:
group: build-release
cancel-in-progress: true
jobs:
build-release:
name: build release
env:
NODE_OPTIONS: '--max_old_space_size=8192' #8192 4096 --expose-gc
YARN_ENABLE_IMMUTABLE_INSTALLS: false
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
node-version: 14.x
YARN_CHECKSUM_BEHAVIOR: update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
- name: Set EOL git configs
continue-on-error: true
run: |
git config core.eol lf
git config core.autocrlf input
git checkout-index --force --all
- name: Pull & update submodules recursively
continue-on-error: true
run: |
git submodule update --init --recursive
git submodule update --recursive --remote
git pull -X theirs
echo "init submodules"
git submodule init
git submodule foreach "git submodule init"
echo "sync submodules"
git submodule sync
git submodule foreach "git submodule sync"
echo "update submodules"
mkdir -p bin >/dev/null 2>&1
curl -L https://github.com/dimaslanjaka/bin/raw/master/bin/submodule-install > bin/submodule-install
rm -rf .git/modules
bash ./bin/submodule-install
- name: initialize nodejs
uses: actions/setup-node@v4
with:
node-version: ${{ env.node-version }}
- name: Set env
id: set-env
shell: bash
run: |
echo "${HOME}/.local/bin" >> $GITHUB_PATH
echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
echo "${GITHUB_WORKSPACE}/node_modules/.bin" >> $GITHUB_PATH
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_OUTPUT
echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "GITHUB_COMMIT_URL=https://github.com/${{github.repository}}/commit/$(echo $GITHUB_SHA)" >> $GITHUB_ENV
echo "GITHUB_COMMIT_URL=https://github.com/${{github.repository}}/commit/$(echo $GITHUB_SHA)" >> $GITHUB_OUTPUT
echo "GITHUB_RUNNER_URL=https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}" >> $GITHUB_ENV
echo "GITHUB_RUNNER_URL=https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}" >> $GITHUB_OUTPUT
echo "CACHE_NPM=$(npm config get cache)" >> $GITHUB_ENV
echo "CACHE_NPM=$(npm config get cache)" >> $GITHUB_OUTPUT
YARN_CURRENT=$(yarn -v)
YARN_BERRY=3.2.1
if [[ "ok" == "$(echo | awk "(${YARN_CURRENT} > ${YARN_BERRY}) { print \"ok\"; }")" ]]; then
echo "CACHE_YARN=$(yarn config get cacheFolder)" >> $GITHUB_ENV
echo "CACHE_YARN=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
else
echo "CACHE_YARN=$(yarn cache dir)" >> $GITHUB_ENV
echo "CACHE_YARN=$(yarn cache dir)" >> $GITHUB_OUTPUT
fi
echo "architecture=$(getconf LONG_BIT)" >> $GITHUB_ENV
if [ -f "package-lock.json" ]; then
echo "PACKAGE-MANAGER=npm" >> $GITHUB_OUTPUT
echo "PACKAGE-MANAGER=npm" >> $GITHUB_ENV
else
echo "PACKAGE-MANAGER=yarn" >> $GITHUB_OUTPUT
echo "PACKAGE-MANAGER=yarn" >> $GITHUB_ENV
fi
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=linux;;
Darwin*) machine=mac;;
CYGWIN*) machine=cygwin;;
MINGW*) machine=mingw;;
*) machine="unknown:${unameOut}"
esac
echo "machine=$machine" >> $GITHUB_OUTPUT
echo "machine=$machine" >> $GITHUB_ENV
- name: Enable corepack
run: corepack enable
- uses: actions/cache@v4
id: cache
with:
path: |
**/.yarn
**/release*
**/yarn.lock
**/node_modules
**/tmp
**/dist
key: ${{ runner.os }}-${{ env.node-version }}
restore-keys: |
${{ runner.os }}-${{ env.node-version }}
${{ runner.os }}-
- name: Check Updates
shell: bash
continue-on-error: true
if: ${{ false }}
run: |
curl -L https://github.com/dimaslanjaka/nodejs-package-types/raw/main/postinstall.js > postinstall.js
if [ -f "postinstall.js" ]; then
if [ "${{ steps.set-env.outputs.PACKAGE-MANAGER }}" ]; then
node postinstall.js
else
node postinstall.js --yarn
fi
fi
- name: Install Global Packages
run: npm i -g typescript ts-node gulp-cli hexo-cli webpack-cli
if: steps.cache.outputs.cache-hit != 'true'
- name: Install Legacy Peer Dependencies
run: |
if [ -f "package-lock.json" ]; then
npm install --legacy-peer-deps
else
yarn install
fi
id: install-legacy
shell: bash
continue-on-error: true
- name: Install Verbose
if: steps.install-legacy.outcome == 'failure'
id: install-verbose
continue-on-error: true
shell: bash
run: |
rm -rf node_modules
FILE=package-lock.json
if [ -f "$FILE" ]; then
npm install --verbose
else
yarn install --verbose
fi
- name: Install Update Binary
id: install-update
if: steps.install-verbose.outcome == 'failure'
shell: bash
run: |
rm -rf node_modules
FILE=package-lock.json
if [ -f "$FILE" ]; then
npm install --no-shrinkwrap --update-binary
else
yarn install
fi
continue-on-error: true
- name: Clean Install
id: install-clean
shell: bash
if: steps.install-update.outcome == 'failure'
run: |
find . -name "yarn.lock" -type d -prune -exec rm -rf '{}' +
find . -name "package-lock.json" -type d -prune -exec rm -rf '{}' +
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
if [ "${{ steps.set-env.outputs.PACKAGE-MANAGER }}" == "npm" ]; then
npm install
else
touch yarn.lock
yarn install
fi
- name: Dump
shell: bash
run: |
echo "install-legacy.outcome ${{ steps.install-legacy.outcome }}"
echo "install-legacy.conclusion ${{ steps.install-legacy.conclusion }}"
echo "install-verbose.outcome ${{ steps.install-verbose.outcome }}"
echo "install-verbose.conclusion ${{ steps.install-verbose.conclusion }}"
echo "install-update.outcome ${{ steps.install-update.outcome }}"
echo "install-update.conclusion ${{ steps.install-update.conclusion }}"
echo "install-clean.outcome ${{ steps.install-clean.outcome }}"
echo "install-clean.conclusion ${{ steps.install-clean.conclusion }}"
echo "branch : ${{ steps.set-env.outputs.GITHUB_BRANCH }}"
echo "commit msg : ${{ github.event.head_commit.message }}"
echo "commit hash : ${{ steps.set-env.outputs.GITHUB_SHA_SHORT }}"
echo "commit url : ${{ steps.set-env.outputs.GITHUB_COMMIT_URL }}"
echo "runner url : ${{ steps.set-env.outputs.GITHUB_RUNNER_URL }}"
echo "cache npm : ${{ steps.set-env.outputs.CACHE_NPM }}"
echo "cache yarn : ${{ steps.set-env.outputs.CACHE_YARN }}"
echo "package mgr : "${{ steps.set-env.outputs.PACKAGE-MANAGER }}""
- if: ${{ steps.cache.outputs.cache-hit != 'true' }}
name: List the state of node modules
shell: bash
continue-on-error: true
run: npm list
- name: Build
run: npm run build
- name: Pack
run: npm run pack --if-present
# https://github.com/marketplace/actions/verify-changed-files
- name: Check if there are changes
id: changes
uses: tj-actions/verify-changed-files@v17
with:
files: |
release*
dist
lib
!node_modules
!tmp
- shell: bash
name: "What's changed?"
run: |
echo "Changed files: ${{ steps.changes.outputs.changed_files }}"
- name: Git setup user email
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
run: |
git config --global user.name 'dimaslanjaka'
git config --global user.email 'dimaslanjaka@gmail.com'
- run: git add release
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
- run: git add dist
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
- run: git add lib
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
- run: git add postinstall.js packer.js .github
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
- run: git pull -X theirs
name: Pull before push
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
- name: Git push
if: steps.changes.outputs.files_changed == 'true'
continue-on-error: true
run: |
git commit -m "chore: update build from ${{ env.GITHUB_COMMIT_URL }}" -m "commit hash: ${{ env.GITHUB_SHA_SHORT }}" -m "commit url: ${{ env.GITHUB_COMMIT_URL }}" -m "runner: ${{ env.GITHUB_RUNNER_URL }}"
git push