diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..18f0530 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,73 @@ +on: + workflow_call: + inputs: + cache: + description: "(boolean) use actions/cache" + required: false + default: true + type: boolean + node_version: + description: "(string) " + required: false + default: "lts/*" + type: string + runs_on: + description: "(string) " + required: false + default: "ubuntu-latest" + type: string + +env: + CI: true + +jobs: + 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 + + - uses: actions/cache@v3 + name: Setup pnpm cache + if: ${{ inputs.cache }} + with: + path: | + ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install Dependencies + run: pnpm i + + - name: Build + run: | + pnpm esb + + - name: pack + run: | + npm pack + + - uses: actions/upload-artifact@v4 + with: + retention-days: 1 + compression-level: 1 + name: artifact + path: | + bin + *.tgz diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 863dc58..947afea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: "recursive" - uses: actions/setup-node@v4 with: @@ -56,9 +58,12 @@ jobs: run: | pnpm run lint + build: + uses: ./.github/workflows/build.yml + test-ve: + needs: build runs-on: ${{ matrix.os }} - name: test (${{ matrix.pm }}, ${{ matrix.os }}) services: verdaccio: image: verdaccio/verdaccio:5 @@ -75,40 +80,28 @@ jobs: with: submodules: "recursive" + - uses: actions/download-artifact@v4 + 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 - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: | - ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install Dependencies - run: pnpm i + - name: login to 'verdaccio' + run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873 - - name: build + - name: version for 'verdaccio' run: | - pnpm esb + npm version patch --commit-hooks false --git-tag-version false - - name: login to verdaccio - run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873 - - - name: publish to verdaccio + - name: publish to 'verdaccio' run: | npm publish --registry http://localhost:4873 @@ -124,8 +117,8 @@ jobs: ${{ matrix.pm }} create hexo test-ln: + needs: build runs-on: ${{ matrix.os }} - name: test (${{ matrix.pm }}, ${{ matrix.os }}) strategy: matrix: os: [windows-latest, macos-latest] @@ -134,8 +127,12 @@ jobs: steps: - uses: actions/checkout@v4 + # with: + # submodules: "recursive" + + - uses: actions/download-artifact@v4 with: - submodules: "recursive" + name: artifact - uses: actions/setup-node@v4 with: @@ -145,31 +142,21 @@ jobs: name: Install pnpm with: version: 8 - - name: Get pnpm store directory shell: bash run: | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - uses: actions/cache@v3 name: Setup pnpm cache + if: ${{ inputs.cache }} with: path: | ${{ env.STORE_PATH }} key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - - name: Install Dependencies - run: pnpm i - - - name: build - run: | - pnpm esb - - - name: pack - run: | - npm pack + run: pnpm add @actions/core -D - name: config for test run: | diff --git a/scripts/getversion.mjs b/scripts/getversion.mjs index efc782d..8816fb0 100644 --- a/scripts/getversion.mjs +++ b/scripts/getversion.mjs @@ -1,5 +1,6 @@ import { readFileSync } from "node:fs"; -import * as core from "@actions/core"; +import { exportVariable } from "@actions/core"; const { version } = JSON.parse(readFileSync("package.json")); console.info(version); -core.exportVariable("version", version); +// process.stdout.write(`::set-env name=version::${version}`); +exportVariable("version", version);