Skip to content

Commit

Permalink
ci: some improve on workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Jul 9, 2024
1 parent be0157c commit 6ac7d28
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 39 deletions.
12 changes: 3 additions & 9 deletions .github/actions/verdaccio-actions/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ inputs:
description: "the authtoken of your verdaccio registry"
required: false
token-config-location:
description: "Define the location of token config. passed to `npm set ... --location <token-config-location>`"
description: "Define the location of token config. passed to `npm config set ... --location <token-config-location>`"
required: false
default: "project"
registry-config:
description: "whether to setup registry setting in npm configuration"
required: false
default: "false"
registry-config-location:
description: "Define the location of register config. passed to `npm set ... --location <registry-config-location>`"
description: "Define the location of register config. passed to `npm config set ... --location <registry-config-location>`"
required: false
default: "project"

Expand All @@ -58,13 +58,7 @@ outputs:
runs:
using: "composite"
steps:
- name: Install pnpm
uses: pnpm/action-setup@v3
if: ${{ inputs.package-manager == 'pnpm' }}
with:
version: "8"

- name: Install verdaccio global
- name: Install verdaccio global via ${{ inputs.package-manager }}
shell: bash
if: ${{ inputs.install-global == 'true' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
labels:
- "dependencies"
- "submodules"
Expand Down
28 changes: 21 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_call:
inputs:
cache:
description: "(boolean) use actions/cache"
description: "(boolean) enable actions/cache for pnpm"
required: false
default: true
type: boolean
Expand All @@ -17,10 +17,16 @@ on:
required: false
default: "ubuntu-latest"
type: string
pnpm_version:
description: "(string) "
required: false
default: "latest"
type: string

env:
default_node_version: "lts/*"
default_pnpm_version: 8
default_pnpm_version: "latest"
artifact_name: build_${{ github.sha }}

jobs:
build:
Expand All @@ -34,12 +40,20 @@ jobs:
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: ${{env.default_pnpm_version}}
version: ${{ inputs.pnpm_version }}

- uses: actions/setup-node@v4
name: Setup Node without cache
if: ${{ !inputs.cache }}
with:
node-version: ${{ inputs.node_version }}

- uses: actions/setup-node@v4
name: Setup Node with cache
if: ${{ inputs.cache }}
with:
node-version: ${{ inputs.node_version }}
cache: pnpm
cache: "pnpm"

- name: Install Dependencies
run: pnpm i
Expand All @@ -48,16 +62,16 @@ jobs:
run: |
pnpm run build
- name: get hexo-starter hash
- name: get hash of `hexo-starter`
shell: bash
run: |
echo -n $(cat .git/modules/hexo-starter/refs/heads/master) > hash
pnpm run hash
- uses: actions/upload-artifact@v4
with:
retention-days: 1
compression-level: 1
name: artifact
name: ${{ env.artifact_name }}
path: |
bin
hash
27 changes: 16 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@ on:
- "main"
paths:
- "src/**.tsx?"
- "hexo-starter"
- ".gitmodules"
- "package.json"
- "tsconfig.json"
- ".github/workflows/ci.yml"
pull_request:
paths:
- "src/**.tsx?"
- "scripts/**"
- "hexo-starter"
- ".gitmodules"
- "package.json"
- "tsconfig.json"
- ".github/workflows/ci.yml"

env:
default_node_version: "lts/*"
default_pnpm_version: 8
default_pnpm_version: "latest"
artifact_name: build_${{ github.sha }}

jobs:
lint:
name: Lint
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -43,11 +48,11 @@ jobs:
- name: Install Dependencies
run: pnpm i

- name: Lint
- name: ESLint
run: |
pnpm run lint
type:
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
Expand All @@ -66,9 +71,9 @@ jobs:
- name: Install Dependencies
run: pnpm i

- name: Lint
- name: Type Check
run: |
pnpm run lint:type
pnpm run type-check
build:
name: Build
Expand All @@ -91,7 +96,7 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: artifact
name: ${{ env.artifact_name }}

- uses: pnpm/action-setup@v4
name: Install pnpm
Expand All @@ -103,23 +108,23 @@ jobs:
with:
node-version: ${{env.default_node_version}}

- name: setup 'verdaccio'
- name: setup local registry via 'verdaccio'
id: verdaccio
uses: ./.github/actions/verdaccio-actions
with:
verdaccio-config: .verdaccio/.verdaccio.yaml
token-config: true
token-content: gHz2lB9wOy+kDV4Cyy+v0w==

- name: version for test
- name: bump a version for testing
run: |
npm version major --commit-hooks false --git-tag-version false
- name: publish to 'verdaccio'
- name: publish to local registry
run: |
npm publish --registry http://${{ steps.verdaccio.outputs.listen }}
- name: config for test
- name: setup config for testing
run: |
mkdir ../.temp
${{ matrix.pm }} config set registry http://${{ steps.verdaccio.outputs.listen }}
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:

env:
default_node_version: "lts/*"
artifact_name: build_${{ github.sha }}

jobs:
build:
Expand All @@ -38,11 +39,11 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: artifact
name: ${{ env.artifact_name }}

- uses: actions/setup-node@v4
with:
# node-version: "lts/*"
# node-version: ${{ env.default_node_version }}
registry-url: https://registry.npmjs.org/

- run: npm publish --provenance --access public --registry=https://registry.npmjs.org/
Expand All @@ -65,7 +66,7 @@ jobs:

- uses: actions/setup-node@v4
with:
# node-version: "lts/*"
# node-version: ${{ env.default_node_version }}
registry-url: "https://npm.pkg.github.com/"
# Defaults to the user or organization that owns the workflow file
scope: ${{env.SCOPE}}
Expand All @@ -74,11 +75,11 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: artifact
name: ${{ env.artifact_name }}

- name: rename package name
run: |
node scripts/renamePackage.mjs
node ./scripts/renamePackage.mjs
- run: npm publish --access public --registry=https://npm.pkg.github.com
env:
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"scripts": {
"build": "pnpm run esb",
"esb": "rm -rf bin && node ./scripts/esb.mjs ",
"hash": "bash ./scripts/gethash.sh",
"hash": "bash ./scripts/getHash.sh",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint:type": "tsc --noEmit",
"sort": "pnpm dlx sort-package-json",
"test": "jest",
"test:cov": "jest --coverage --coverageReporters html --coverageReporters text",
"test:lcov": "jest --coverage --coverageReporters lcovonly --coverageReporters text-summary",
"tsb": "tsc -b -v",
"tsbf": "tsc -b -v -f",
"tsbw": "tsc -b -v -w"
"tsbw": "tsc -b -v -w",
"type-check": "tsc --noEmit"
},
"dependencies": {
"commander": "^12.0.0",
Expand All @@ -67,6 +67,5 @@
},
"engines": {
"node": ">=20"
},
"#packageManager": "[email protected]+sha256.245fe901f8e7fa8782d7f17d32b6a83995e2ae03984cb5b62b8949bfdc27c7b5"
}
}
}

0 comments on commit 6ac7d28

Please sign in to comment.