-
Notifications
You must be signed in to change notification settings - Fork 333
106 lines (88 loc) · 3 KB
/
Copy pathpublish.yml
File metadata and controls
106 lines (88 loc) · 3 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Publish
on:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22.18.0
cache: pnpm
- run: npm install -g npm@11
- run: pnpm install --frozen-lockfile
- name: Create release PR or publish
id: changesets
uses: changesets/action@v1
with:
publish: pnpm release
version: pnpm run version
title: "chore: version packages"
commit: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
publish-dev:
name: Publish @dev snapshot
needs: publish
if: ${{ !cancelled() && needs.publish.result != 'failure' }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22.18.0
cache: pnpm
registry-url: https://registry.npmjs.org
- run: npm install -g npm@11
- run: pnpm install --frozen-lockfile
- name: Compute dev version
id: dev-version
run: |
base_version="$(node -p "require('./packages/react-grab/package.json').version")"
dev_version="${base_version}-dev.$(git rev-parse --short HEAD)"
echo "version=${dev_version}" >> "$GITHUB_OUTPUT"
echo "Publishing dev snapshot ${dev_version}"
- name: Apply dev version to published packages
env:
DEV_VERSION: ${{ steps.dev-version.outputs.version }}
run: |
for package_dir in react-grab cli grab; do
node -e "const fs = require('node:fs'); const path = 'packages/${package_dir}/package.json'; const manifest = JSON.parse(fs.readFileSync(path, 'utf8')); manifest.version = process.env.DEV_VERSION; fs.writeFileSync(path, JSON.stringify(manifest, null, 2) + '\n');"
done
- name: Build
env:
VERSION: ${{ steps.dev-version.outputs.version }}
run: pnpm build
- name: Publish to npm under the dev tag
env:
NPM_CONFIG_PROVENANCE: true
run: |
for attempt in 1 2 3; do
if pnpm publish --recursive --tag dev --no-git-checks --access public; then
exit 0
fi
backoff_seconds=$((attempt * 15))
echo "Dev publish attempt ${attempt} failed; retrying in ${backoff_seconds}s (already-published versions are skipped by pnpm)"
sleep "${backoff_seconds}"
done
echo "Dev publish failed after 3 attempts"
exit 1