-
Notifications
You must be signed in to change notification settings - Fork 516
90 lines (68 loc) · 2.59 KB
/
npm-publish.yaml
File metadata and controls
90 lines (68 loc) · 2.59 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
name: Publish npm packages
on:
push:
branches:
- main
permissions:
id-token: write # Required for npm OIDC provenance
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false # Don't cancel publishing in progress
jobs:
publish:
runs-on: ubuntu-latest
environment: "hexclave/stack-auth — Publish npm packages"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
token: ${{ secrets.NPM_PUBLISH_VERSION_UPDATE_PR_PAT }}
- name: Setup Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 'latest'
registry-url: 'https://registry.npmjs.org'
- name: Setup pnpm
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Clean
run: pnpm run clean
- name: Install dependencies (after clean)
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm build:packages
- name: Publish packages
# pnpm publish skips versions that already exist on npm by default
run: pnpm publish -r --no-git-checks --access public
env:
NPM_CONFIG_PROVENANCE: true
- name: Update package versions on dev
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --exit-code HEAD
git fetch origin dev:dev
git checkout dev
git diff --exit-code dev origin/dev
pnpm install --frozen-lockfile
CHANGESET_FILE=".changeset/update-package-versions-${GITHUB_RUN_ID}.md"
cat > "$CHANGESET_FILE" <<'EOF'
---
"@stackframe/stack": patch
---
Update package versions.
EOF
pnpm changeset version
version=$(grep '"version":' packages/template/package.json)
sed "s/^[[:space:]]*\"version\":.*/$version/" packages/template/package-template.json > packages/template/package-template.json.untracked.tmp
mv packages/template/package-template.json.untracked.tmp packages/template/package-template.json
git add -A
if git diff --staged --quiet; then
echo "No package version changes to commit"
exit 0
fi
git commit -m "chore: update package versions"
git push origin dev