Skip to content

Commit 18609d1

Browse files
authored
ci: introduce continuous release (#556)
1 parent f526ff7 commit 18609d1

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

.changeset/wise-vans-thank.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
pull_request:
78

89
name: Release
910

@@ -13,6 +14,8 @@ jobs:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1619

1720
- uses: actions/setup-node@v4
1821
with:
@@ -60,10 +63,15 @@ jobs:
6063
key: ${{ runner.os }}-ultra-v1-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
6164

6265
- name: Create PR or release packages
66+
if: github.event_name == 'push'
6367
uses: changesets/action@v1
6468
with:
6569
publish: yarn changeset publish
6670
version: yarn changeset:version
6771
env:
6872
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
6973
GITHUB_TOKEN: ${{ github.token }}
74+
75+
- name: Continuous release via pkg.pr.new
76+
if: github.event_name == 'pull_request'
77+
run: ./scripts/publish-preview-packages.sh ${{ github.event.pull_request.base.ref }}

demo/tsconfig.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
2-
"extends": "../tsconfig.json",
32
"compilerOptions": {
4-
"baseUrl": "./src",
5-
"outDir": "./dist",
3+
"target": "ESNext",
4+
"jsx": "react-jsx",
65
"module": "ESNext",
7-
"moduleResolution": "Bundler"
6+
"moduleResolution": "Bundler",
7+
"declaration": true,
8+
"declarationMap": true,
9+
"esModuleInterop": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"strict": true,
12+
"skipLibCheck": false,
13+
"baseUrl": "./src",
14+
"outDir": "./dist"
815
},
916
"exclude": ["./dist", "./build"]
1017
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
if [ -z "$1" ]; then
4+
echo "Error: Base branch not specified. Usage: publish-previews.sh <base-branch>"
5+
exit 1
6+
fi
7+
8+
BASE_BRANCH=$1
9+
10+
# ensure we have the latest changes from the remote
11+
git fetch origin
12+
13+
if ! git show-ref --verify --quiet refs/remotes/origin/"$BASE_BRANCH"; then
14+
echo "Error: Base branch '$BASE_BRANCH' not found in the remote repository."
15+
exit 1
16+
fi
17+
18+
echo "Detecting changed packages compared to $BASE_BRANCH..."
19+
20+
# Get changes from all relevant directories
21+
CHANGED_PATHS=$(git diff --name-only origin/"$BASE_BRANCH"...HEAD | grep -E '^(config|core|extensions/|integrations/|packages/)' | sort -u)
22+
23+
if [ -z "$CHANGED_PATHS" ]; then
24+
echo "No changed packages detected."
25+
exit 0
26+
fi
27+
28+
# Process each changed path and format it for publishing
29+
PUBLISH_PATHS=""
30+
while IFS= read -r path; do
31+
case "$path" in
32+
config/*|core/*)
33+
# For config and core, include the first directory
34+
dir=$(echo "$path" | cut -d '/' -f 1)
35+
if [[ ! "$PUBLISH_PATHS" =~ "./$dir " ]]; then
36+
PUBLISH_PATHS+="./$dir "
37+
fi
38+
;;
39+
extensions/*|integrations/*|packages/*)
40+
# For extensions, integrations, and packages, include the full path up to the second level
41+
dir=$(echo "$path" | cut -d '/' -f 1-2)
42+
if [[ ! "$PUBLISH_PATHS" =~ "./$dir " ]]; then
43+
PUBLISH_PATHS+="./$dir "
44+
fi
45+
;;
46+
esac
47+
done <<< "$CHANGED_PATHS"
48+
49+
# Remove trailing space
50+
PUBLISH_PATHS="${PUBLISH_PATHS% }"
51+
52+
if [ -n "$PUBLISH_PATHS" ]; then
53+
echo "Publishing changed packages: $PUBLISH_PATHS"
54+
yarn dlx pkg-pr-new publish --compact $PUBLISH_PATHS --packageManager yarn --template './demo'
55+
else
56+
echo "No publishable packages found."
57+
exit 0
58+
fi

0 commit comments

Comments
 (0)