Skip to content

Commit

Permalink
ci: add typecheck && improve workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Feb 10, 2024
1 parent f7bfba2 commit bff108c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 47 deletions.
29 changes: 9 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: build
on:
workflow_call:
inputs:
Expand All @@ -18,46 +19,34 @@ on:
type: string

env:
CI: true
default_node_version: "lts/*"
default_pnpm_version: 8

jobs:
build:
name: build
runs-on: ${{ inputs.runs_on }}
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
version: ${{env.default_pnpm_version}}

- uses: actions/cache@v4
name: Setup pnpm cache
if: ${{ inputs.cache }}
- uses: actions/setup-node@v4
with:
path: |
${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: ${{ inputs.node_version }}
cache: pnpm

- name: Install Dependencies
run: pnpm i

- name: Build
run: |
pnpm esb
pnpm run build
- name: get hexo-starter hash
shell: bash
Expand Down
66 changes: 40 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,63 @@ on:
- ".github/workflows/ci.yml"

env:
CI: true
default_node_version: "lts/*"
default_pnpm_version: 8

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: ${{env.default_pnpm_version}}

- uses: actions/setup-node@v4
with:
node-version: "lts/*"
node-version: ${{env.default_node_version}}
cache: pnpm

- name: Install Dependencies
run: pnpm i

- name: Lint
run: |
pnpm run lint
type:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
version: ${{env.default_pnpm_version}}

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
- uses: actions/setup-node@v4
with:
path: |
${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: ${{env.default_node_version}}
cache: pnpm

- name: Install Dependencies
run: pnpm i

- name: Lint
run: |
pnpm run lint
pnpm run lint:type
build:
uses: ./.github/workflows/build.yml

test-ve:
name: test-ve
needs: build
runs-on: ${{ matrix.os }}
services:
Expand All @@ -84,15 +97,15 @@ jobs:
with:
name: artifact

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

- uses: pnpm/action-setup@v2
name: Install pnpm
if: ${{ matrix.pm == 'pnpm' }}
with:
version: 8
version: ${{env.default_pnpm_version}}

- uses: actions/setup-node@v4
with:
node-version: ${{env.default_node_version}}

- name: login to 'verdaccio'
run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873
Expand All @@ -117,6 +130,7 @@ jobs:
${{ matrix.pm }} create hexo
test-ln:
name: test-ln
needs: build
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -134,15 +148,15 @@ jobs:
with:
name: artifact

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

- uses: pnpm/action-setup@v2
name: Install pnpm
if: ${{ matrix.pm == 'pnpm' }}
with:
version: 8
version: ${{env.default_pnpm_version}}

- uses: actions/setup-node@v4
with:
node-version: ${{env.default_node_version}}

- name: config for test
run: |
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "the package version you want to bump"
description: ""
required: true
default: "keep current"
type: choice
Expand All @@ -18,8 +18,12 @@ on:
tags:
- "v*.*.*"

env:
default_node_version: "lts/*"

jobs:
build:
name: build
uses: ./.github/workflows/build.yml

publish-npm:
Expand Down Expand Up @@ -79,3 +83,18 @@ jobs:
- run: npm publish --access public --registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

release:
name: Release
needs: publish-npm
runs-on: ubuntu-latest
permissions:
contents: write
discussions: write
steps:
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
discussion_category_name: "Announcements"

0 comments on commit bff108c

Please sign in to comment.