Skip to content

Commit 2aa9ffb

Browse files
committed
chore: add publish workflow
1 parent b56f6fe commit 2aa9ffb

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/publish.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Publish
2+
run-name: Publish ${{ github.ref_name }}
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*.*.*'
8+
9+
concurrency:
10+
group: publish
11+
cancel-in-progress: false
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4.2.2
22+
23+
- name: Install Bun
24+
uses: oven-sh/setup-bun@v2.0.2
25+
with:
26+
bun-version: latest
27+
28+
- name: Install Dependencies
29+
run: bun install --frozen-lockfile
30+
31+
- name: Build
32+
run: bun run build
33+
34+
- name: Run tests
35+
run: bun run test
36+
37+
- name: Pack
38+
run: bun pm pack
39+
40+
- name: Upload build archive
41+
uses: actions/upload-artifact@v4.6.2
42+
with:
43+
name: build
44+
path: pdown-*.tgz
45+
npm:
46+
needs: [build]
47+
runs-on: ubuntu-latest
48+
permissions:
49+
id-token: write
50+
steps:
51+
- name: Download build artifact
52+
uses: actions/download-artifact@v5.0.0
53+
with:
54+
name: build
55+
path: build
56+
57+
- uses: actions/setup-node@v6.0.0
58+
with:
59+
node-version: '*'
60+
registry-url: https://registry.npmjs.org
61+
62+
# Ensure npm 11.5.1 or later is installed to enable trusted publishing
63+
# https://docs.npmjs.com/trusted-publishers
64+
- name: Update npm
65+
run: npm install -g npm@latest
66+
67+
- name: Publish
68+
run: npm publish ./build/pdown-*.tgz
69+
github-packages:
70+
needs: [build]
71+
runs-on: ubuntu-latest
72+
permissions:
73+
id-token: write
74+
packages: write
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4.2.2
78+
79+
- name: Download build artifact
80+
uses: actions/download-artifact@v5.0.0
81+
with:
82+
name: build
83+
path: build
84+
85+
- uses: actions/setup-node@v6.0.0
86+
with:
87+
node-version: '*'
88+
registry-url: https://npm.pkg.github.com
89+
90+
- name: Publish
91+
run: npm publish ./build/pdown-*.tgz
92+
env:
93+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
github-release:
95+
needs: [build]
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: write
99+
steps:
100+
- name: Download build artifact
101+
uses: actions/download-artifact@v5.0.0
102+
with:
103+
name: build
104+
path: build
105+
106+
- name: Release
107+
uses: softprops/action-gh-release@v2.4.1
108+
with:
109+
name: '${{ github.ref_name }}'
110+
prerelease: ${{ startsWith(github.ref_name, 'v0.') }}
111+
files: build/pdown-*.tgz
112+
fail_on_unmatched_files: true
113+
make_latest: true

0 commit comments

Comments
 (0)