Skip to content

Commit 3599418

Browse files
committed
chore: 🤖 Add provenance build
1 parent 02a697c commit 3599418

7 files changed

Lines changed: 684 additions & 1246 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
name: Deploy
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
contents: write
15+
16+
steps:
17+
- name: Clone repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Install Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: lts/*
27+
28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v4
30+
with:
31+
version: 10.28.1
32+
33+
- name: Install dependencies
34+
run: pnpm install
35+
36+
- name: Build and test
37+
run: |
38+
pnpm run build
39+
pnpm run coverage
40+
41+
- name: Upload coverage reports to Codecov
42+
uses: codecov/codecov-action@v4
43+
with:
44+
token: ${{ secrets.CODECOV_TOKEN }}
45+
fail_ci_if_error: false
46+
47+
- name: Prepublish
48+
run: pnpm run prepublishOnly
49+
50+
- name: Verify NPM token
51+
run: |
52+
npm config set //registry.npmjs.org/:_authToken=${NPM_TOKEN}
53+
echo "Verifying npm auth..."
54+
npm whoami --registry=https://registry.npmjs.org/
55+
env:
56+
NPM_TOKEN: ${{ secrets.JSON_WEB3_NPM_TOKEN }}
57+
58+
- name: NPM Publish
59+
uses: JS-DevTools/npm-publish@v3
60+
with:
61+
token: ${{ secrets.JSON_WEB3_NPM_TOKEN }}
62+
provenance: true
63+
access: public
64+
65+
- name: Configure Git user identity
66+
run: |
67+
git config --global user.name "github-actions[bot]"
68+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
69+
git config --global commit.gpgSign false
70+
git config --global tag.gpgSign false
71+
72+
- name: Create Git Tag (with overwrite)
73+
run: |
74+
git reset --hard HEAD
75+
VERSION=$(node -p "require('./package.json').version")
76+
TAG_NAME="v$VERSION"
77+
echo "VERSION=$VERSION" >> $GITHUB_ENV
78+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
79+
80+
if git ls-remote --tags origin | grep -q "refs/tags/$TAG_NAME$"; then
81+
git push --delete origin "$TAG_NAME" || echo "Failed to delete remote tag"
82+
git tag -d "$TAG_NAME" 2>/dev/null || echo "Local tag does not exist"
83+
fi
84+
85+
git tag "$TAG_NAME" -m "Release version $VERSION"
86+
git push origin "$TAG_NAME"
87+
echo "NEED_RELEASE=true" >> $GITHUB_ENV
88+
89+
- name: Get Previous Git Tag
90+
run: |
91+
PREV_TAG=$(git tag --sort=-creatordate | grep -v "$TAG_NAME" | head -n 1)
92+
echo "Previous tag: $PREV_TAG"
93+
echo "PREV_TAG=$PREV_TAG" >> $GITHUB_ENV
94+
95+
- name: Generate Changelog and Compare Link
96+
run: |
97+
echo "Generating changelog from commits between $PREV_TAG and $TAG_NAME"
98+
echo "### Changes Since $PREV_TAG" > CHANGELOG.md
99+
git log "$PREV_TAG..HEAD" --pretty=format:"%s" --no-merges | sort | uniq | sed 's/^/- /' >> CHANGELOG.md
100+
101+
COMPARE_URL="https://github.com/${{ github.repository }}/compare/$PREV_TAG...$TAG_NAME"
102+
echo "" >> CHANGELOG.md
103+
echo "**Full Changelog**: $COMPARE_URL" >> CHANGELOG.md
104+
105+
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
106+
cat CHANGELOG.md >> $GITHUB_ENV
107+
echo "EOF" >> $GITHUB_ENV
108+
109+
- name: Delete existing GitHub Release (if exists)
110+
run: |
111+
RELEASE_ID=$(gh release view "${{ env.TAG_NAME }}" --json id --jq '.id' 2>/dev/null || echo "")
112+
if [ -n "$RELEASE_ID" ]; then
113+
gh release delete "${{ env.TAG_NAME }}" --yes || echo "Failed to delete release"
114+
fi
115+
env:
116+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
118+
- name: Create GitHub Release
119+
if: env.NEED_RELEASE == 'true'
120+
uses: softprops/action-gh-release@v2
121+
with:
122+
tag_name: ${{ env.TAG_NAME }}
123+
name: Release ${{ env.TAG_NAME }}
124+
body: |
125+
## Release ${{ env.VERSION }}
126+
${{ env.CHANGELOG }}
127+
files: |
128+
dist/*
129+
draft: false
130+
prerelease: false
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# json-web3
22

3+
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/haozi/json-web3/deploy.yml)](https://github.com/haozi/json-web3/actions)
4+
[![npm](https://img.shields.io/npm/v/json-web3.svg)](https://www.npmjs.com/package/json-web3)
5+
[![codecov](https://codecov.io/gh/haozi/json-web3/branch/main/graph/badge.svg)](https://app.codecov.io/gh/haozi/json-web3)
6+
[![contributors](https://img.shields.io/github/contributors/haozi/json-web3)](https://github.com/haozi/json-web3/graphs/contributors)
7+
[![LICENSE](https://img.shields.io/npm/l/json-web3)](https://github.com/haozi/json-web3/blob/main/LICENSE)
8+
[![Size](https://img.shields.io/bundlejs/size/json-web3.svg)](https://cdn.jsdelivr.net/npm/json-web3/+esm)
9+
310
BigInt-safe JSON serialization and deserialization for Web3 data.
411

512
## Install

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-web3",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "BigInt-safe JSON serialization and deserialization for Web3 use cases.",
55
"keywords": [
66
"json",
@@ -36,16 +36,21 @@
3636
],
3737
"scripts": {
3838
"build": "tsup",
39+
"coverage": "vitest run --coverage",
40+
"postinstall": "pnpm run ncu",
3941
"lint": "prettier . --write",
40-
"prepublishOnly": "pnpm run build",
42+
"ncu": "pnpm npm-check-updates -u --deep",
43+
"prepublishOnly": "pnpm run build && vite-node scripts/clean.ts",
4144
"publishOnly": "pnpm run build",
4245
"test": "vitest run --coverage",
4346
"test:watch": "vitest"
4447
},
4548
"devDependencies": {
46-
"@types/node": "^25.0.9",
49+
"@types/node": "^25.0.10",
4750
"@vitest/coverage-v8": "^4.0.17",
48-
"prettier": "^3.8.0",
51+
"fs-extra": "^11.3.3",
52+
"npm-check-updates": "^19.3.1",
53+
"prettier": "^3.8.1",
4954
"prettier-plugin-lint-md": "^1.0.1",
5055
"prettier-plugin-organize-imports": "^4.3.0",
5156
"prettier-plugin-sort-json": "^4.2.0",
@@ -58,5 +63,10 @@
5863
"packageManager": "pnpm@10.28.1",
5964
"engines": {
6065
"node": ">=18"
66+
},
67+
"publishConfig": {
68+
"access": "public",
69+
"provenance": true,
70+
"registry": "https://registry.npmjs.org/"
6171
}
6272
}

0 commit comments

Comments
 (0)