Skip to content

Commit

Permalink
ci: add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Feb 26, 2025
1 parent 76a5913 commit 40adce2
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 61 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish Package

on:
push:
tags:
- v*

jobs:
publish:
if: github.repository == 'qmhc/vite-plugin-dts'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Install deps
run: pnpm install

- name: Build
run: pnpm run build

- name: Publish package
run: pnpm run publish:ci ${{ github.ref_name }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_OPTIONS: --max-old-space-size=4096
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ on:
- v*

jobs:
build:
name: Create Release
release:
if: github.repository == 'qmhc/vite-plugin-dts'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Create Release for Tag
id: release_tag
uses: yyx990803/release-tag@master
- run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
body: |
Please refer to [CHANGELOG.md](/~https://github.com/qmhc/vite-plugin-dts/blob/main/CHANGELOG.md) for details.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"prepublishOnly": "pinst --disable",
"prettier": "pretty-quick --staged && pnpm run lint",
"postpublish": "pinst --enable",
"publish:ci": "tsx scripts/publish.ts",
"release": "tsx scripts/release.ts",
"test": "vitest run",
"test:dev": "vitest",
Expand Down
4 changes: 4 additions & 0 deletions scripts/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { resolve } from "node:path";
import { fileURLToPath } from "node:url";

export const rootDir = resolve(fileURLToPath(import.meta.url), '../..')
44 changes: 0 additions & 44 deletions scripts/logger.ts

This file was deleted.

22 changes: 22 additions & 0 deletions scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import minimist from 'minimist'
import { logger, publish } from '@vexip-ui/scripts'
import { rootDir } from './constant'

const args = minimist<{
d?: boolean,
dry?: boolean,
t?: string,
tag?: string
}>(process.argv.slice(2))

const isDryRun = args.dry || args.d
const releaseTag = args.tag || args.t

publish({
pkgDir: rootDir,
isDryRun,
releaseTag
}).catch(error => {
logger.error(error)
process.exit(1)
})
8 changes: 2 additions & 6 deletions scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import minimist from 'minimist'
import { logger } from './logger'
import { release, run } from '@vexip-ui/scripts'
import { logger, release, run } from '@vexip-ui/scripts'
import { rootDir } from './constant'

const args = minimist<{
d?: boolean,
Expand All @@ -16,8 +14,6 @@ const args = minimist<{
const isDryRun = args.dry || args.d
const preId = args.preid || args.p

const rootDir = path.resolve(fileURLToPath(import.meta.url), '../..')

release({
pkgDir: rootDir,
isDryRun,
Expand Down

0 comments on commit 40adce2

Please sign in to comment.