-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (67 loc) · 2.03 KB
/
npm-publish.yml
File metadata and controls
91 lines (67 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Publish Packages
on:
release:
types: [created]
workflow_dispatch:
permissions:
id-token: write
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
registry-url: https://registry.npmjs.org
- name: Update npm
run: npm install -g npm@latest
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test --workspaces
- name: Run eslint
run: npm run lint --workspaces
- name: Parse release tag
id: tag
run: |
TAG="${{ github.event.release.tag_name }}"
NAME="${TAG%%_v*}"
VERSION="${TAG##*_v}"
echo "name=$NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Version packages
run: npx changeset version
- name: Publish packages
run: npx changeset publish
- name: Build package
run: |
PKG=${{ steps.tag.outputs.name }}
npm run build --workspace="$PKG"
- name: Archive package
run: |
mkdir artifacts
PKG_FULL=${{ steps.tag.outputs.name }}
VERSION=${{ steps.tag.outputs.version}}
PKG_NAME="${PKG_FULL#@*/}"
tar -czf "artifacts/${PKG_NAME}_v${VERSION}.tar.gz" \
-C "libraries/$PKG_NAME" .
- name: Collect release assets
run: |
PKG_FULL=${{ steps.tag.outputs.name }}
PKG_NAME="${PKG_FULL#@*/}"
mkdir -p release
# copy tarball
cp artifacts/*.tar.gz release/
# copy exact dist files
cp "libraries/$PKG_NAME/dist/$PKG_NAME.js" release/
cp "libraries/$PKG_NAME/dist/$PKG_NAME.min.js" release/
- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
files: release/**