d5f55b5f9c
Coverage / build (push) Has been cancelled
Docker / Build (push) Has been cancelled
Docker / Publish (push) Has been cancelled
Node.js CI / build (16, macos-latest) (push) Has been cancelled
Node.js CI / build (16, ubuntu-latest) (push) Has been cancelled
Node.js CI / build (16, windows-latest) (push) Has been cancelled
NPM / Build (22) (push) Has been cancelled
NPM / Pack (push) Has been cancelled
NPM / Publish (push) Has been cancelled
89 lines
2.5 KiB
YAML
89 lines
2.5 KiB
YAML
name: NPM
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version:
|
|
- 22
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Use Node.js 22
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: npm
|
|
cache-dependency-path: package.json
|
|
|
|
- name: Install Dependencies
|
|
run: |
|
|
node --version
|
|
npm --version
|
|
npm install
|
|
|
|
- name: Test
|
|
run: npm test
|
|
|
|
pack:
|
|
name: Pack
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
cache-dependency-path: package.json
|
|
|
|
- run: npm install
|
|
- name: Generate Package JSON
|
|
run: ./scripts/generate-package-json.sh
|
|
- run: ./scripts/npm-pack-testing.sh
|
|
env:
|
|
WECHATY_PUPPET_PADPLUS_TOKEN: ${{ secrets.WECHATY_PUPPET_PADPLUS_TOKEN }}
|
|
|
|
publish:
|
|
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v'))
|
|
name: Publish
|
|
needs: [build, pack]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
registry-url: https://registry.npmjs.org/
|
|
cache: npm
|
|
cache-dependency-path: package.json
|
|
- run: npm install
|
|
- name: Generate Package JSON
|
|
run: ./scripts/generate-package-json.sh
|
|
- run: ./scripts/package-publish-config-tag.sh
|
|
- run: npm run dist
|
|
|
|
- name: Check Branch
|
|
id: check-branch
|
|
run: |
|
|
if [[ ${{ github.ref }} =~ ^refs/heads/(main|v[0-9]+\.[0-9]+.*)$ ]]; then
|
|
echo ::set-output name=match::true
|
|
fi # See: https://stackoverflow.com/a/58869470/1123955
|
|
- name: Is A Publish Branch
|
|
if: steps.check-branch.outputs.match == 'true'
|
|
run: |
|
|
NAME=$(npx pkg-jq -r .name)
|
|
VERSION=$(npx pkg-jq -r .version)
|
|
if npx version-exists "$NAME" "$VERSION"
|
|
then echo "$NAME@$VERSION exists on NPM, skipped."
|
|
else echo "Publishing..." && npm publish
|
|
fi
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
- name: Is Not A Publish Branch
|
|
if: steps.check-branch.outputs.match != 'true'
|
|
run: echo 'Not A Publish Branch'
|