-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (76 loc) · 2.99 KB
/
changesets-dev.yml
File metadata and controls
88 lines (76 loc) · 2.99 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
name: Changesets (Dev)
on:
push:
branches:
- dev
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release-dev:
name: Release Dev
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js (for npm publish)
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Check for changesets
id: check
run: |
if ls .changeset/*.md 1>/dev/null 2>&1; then
COUNT=$(ls .changeset/*.md | grep -v README.md | wc -l)
if [ "$COUNT" -gt 0 ]; then
echo "has_changesets=true" >> $GITHUB_OUTPUT
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
fi
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
fi
- name: Snapshot Version
if: steps.check.outputs.has_changesets == 'true'
run: bunx changeset version --snapshot dev
- name: Replace workspace protocol
if: steps.check.outputs.has_changesets == 'true'
run: |
for pkg in packages/*/package.json; do
if grep -q '"workspace:\*"' "$pkg" 2>/dev/null; then
for dep in $(jq -r '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key' "$pkg"); do
DEP_VERSION=$(find packages -name "package.json" -path "*/package.json" -exec jq -r --arg name "$dep" 'select(.name == $name) | .version' {} \; 2>/dev/null | head -1)
if [ -n "$DEP_VERSION" ]; then
jq --arg dep "$dep" --arg ver "${DEP_VERSION}" '
if .dependencies[$dep] == "workspace:*" then .dependencies[$dep] = $ver else . end |
if .devDependencies[$dep] == "workspace:*" then .devDependencies[$dep] = $ver else . end
' "$pkg" > tmp && mv tmp "$pkg"
fi
done
fi
done
- name: Build Packages
if: steps.check.outputs.has_changesets == 'true'
run: bun run build
- name: Publish Dev
if: steps.check.outputs.has_changesets == 'true'
run: bunx changeset publish --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.ORG_NPM_TOKEN }}
- name: Summary
if: steps.check.outputs.has_changesets == 'true'
run: |
VERSION=$(jq -r '.version' packages/core/package.json)
echo "## Dev Snapshot Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${VERSION}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Install: \`bun add routerxjs@dev\`" >> $GITHUB_STEP_SUMMARY