Skip to content

Commit d5410e9

Browse files
committed
chore: update build process and documentation for browser and npm usage
1 parent bdd9f0d commit d5410e9

File tree

1 file changed

+16
-118
lines changed

1 file changed

+16
-118
lines changed

.github/workflows/deploy-npm.yml

Lines changed: 16 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -9,150 +9,57 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
checkout:
12+
publish-npm:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16+
# Checkout the repository
1617
- name: Checkout repository
1718
uses: actions/checkout@v3
1819
with:
1920
token: ${{ secrets.HUB_TOKEN }}
2021

21-
- name: Upload repository files
22-
uses: actions/upload-artifact@v3
23-
with:
24-
name: repo-files
25-
path: .
26-
27-
setup-node:
28-
runs-on: ubuntu-latest
29-
needs: checkout
30-
31-
steps:
32-
- name: Download repository files
33-
uses: actions/download-artifact@v3
34-
with:
35-
name: repo-files
36-
22+
# Set up Node.js environment
3723
- name: Set up Node.js
3824
uses: actions/setup-node@v3
3925
with:
4026
node-version: '18'
4127
registry-url: 'https://registry.npmjs.org/'
4228

43-
install:
44-
runs-on: ubuntu-latest
45-
needs: setup-node
46-
47-
steps:
48-
- name: Download repository files
49-
uses: actions/download-artifact@v3
50-
with:
51-
name: repo-files
52-
29+
# Install dependencies
5330
- name: Install dependencies
5431
run: npm install
5532

56-
get-hash:
57-
runs-on: ubuntu-latest
58-
needs: install
59-
60-
steps:
61-
- name: Download repository files
62-
uses: actions/download-artifact@v3
63-
with:
64-
name: repo-files
65-
33+
# Get the short hash of the last commit
6634
- name: Get short commit hash
35+
id: get_hash
6736
run: echo "HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
6837

69-
update-version:
70-
runs-on: ubuntu-latest
71-
needs: get-hash
72-
73-
steps:
74-
- name: Download repository files
75-
uses: actions/download-artifact@v3
76-
with:
77-
name: repo-files
78-
38+
# Update the version in package.json
7939
- name: Update version
40+
id: update_version
8041
run: |
81-
VERSION="0.0.1-alpha.${{ env.HASH }}"
42+
VERSION="0.0.1-alpha.$HASH"
8243
jq --arg ver "$VERSION" '.version = $ver' package.json > tmp.json && mv tmp.json package.json
8344
echo "VERSION=$VERSION" >> $GITHUB_ENV
84-
- name: Upload updated package.json
85-
uses: actions/upload-artifact@v3
86-
with:
87-
name: updated-files
88-
path: package.json
89-
90-
build:
91-
runs-on: ubuntu-latest
92-
needs: update-version
93-
94-
steps:
95-
- name: Download updated files
96-
uses: actions/download-artifact@v3
97-
with:
98-
name: updated-files
9945
46+
# Build the package
10047
- name: Build package
101-
run: npm run make
102-
103-
test:
104-
runs-on: ubuntu-latest
105-
needs: build
106-
107-
steps:
108-
- name: Download updated files
109-
uses: actions/download-artifact@v3
110-
with:
111-
name: updated-files
48+
run: npm run build
11249

50+
# Run tests
11351
- name: Run tests
11452
run: npm test
11553

116-
coverage:
117-
runs-on: ubuntu-latest
118-
needs: test
119-
120-
steps:
121-
- name: Download updated files
122-
uses: actions/download-artifact@v3
123-
with:
124-
name: updated-files
125-
126-
- name: Run coverage
127-
run: npm run coverage
128-
129-
tag:
130-
runs-on: ubuntu-latest
131-
needs: coverage
132-
133-
steps:
134-
- name: Download updated files
135-
uses: actions/download-artifact@v3
136-
with:
137-
name: updated-files
138-
54+
# Create Git tag
13955
- name: Create Git tag
14056
run: |
14157
git config --local user.name "github-actions[bot]"
14258
git config --local user.email "github-actions[bot]@users.noreply.github.com"
14359
git tag ${{ env.VERSION }}
14460
git push origin ${{ env.VERSION }}
14561
146-
release:
147-
runs-on: ubuntu-latest
148-
needs: tag
149-
150-
steps:
151-
- name: Download updated files
152-
uses: actions/download-artifact@v3
153-
with:
154-
name: updated-files
155-
62+
# Create GitHub Release
15663
- name: Create GitHub Release
15764
uses: actions/create-release@v1
15865
env:
@@ -163,17 +70,8 @@ jobs:
16370
draft: false
16471
prerelease: true
16572

166-
publish:
167-
runs-on: ubuntu-latest
168-
needs: release
169-
170-
steps:
171-
- name: Download updated files
172-
uses: actions/download-artifact@v3
173-
with:
174-
name: updated-files
175-
73+
# Publish to npm
17674
- name: Publish to npm
17775
env:
17876
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
179-
run: npm publish
77+
run: npm publish

0 commit comments

Comments
 (0)