-
Notifications
You must be signed in to change notification settings - Fork 4
84 lines (74 loc) · 2.9 KB
/
publish.yml
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
name: Publish to NPM
on:
push:
branches:
- main
jobs:
increment-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Update versions
run: |
node=$(which node)
mv $node $node.exe
node=$(echo $node.exe)
git fetch origin --prune
changed_packages=$(git diff --name-only origin/version...origin/main --diff-filter=ACM | grep -E "(packages|plugins|utils)/" | sort -u)
if [ -z "$changed_packages" ]; then
echo "No changes found in packages, skipping update"
exit 0
fi
changed_packages=$(echo "$changed_packages" | xargs dirname | sed 's|/src$||' | sort -u)
if [ -z "$changed_packages" ]; then
echo "No changes found in packages, skipping update"
exit 0
else
updated_packages=""
pnpm i -w semver
for pkg in $changed_packages
do
cd $pkg && current_version=$(pnpm pkg get version | sed 's/"//g') && new_version=$($node -pe "require('semver').inc('$current_version', 'patch')") && cd - > /dev/null
echo -e "Bumping version for $pkg from $current_version to $new_version"
cd $pkg && pnpm pkg set version=$new_version && cd - > /dev/null
updated_packages="$updated_packages\n- $pkg: $new_version"
done
pnpm uninstall -w semver
echo -e "Package updates:$updated_packages"
echo "::set-output name=updated_packages::$updated_packages"
fi
id: update-versions
- name: Build packages
run: pnpm build
- name: Publish packages
if: steps.update-versions.outputs.updated_packages != '' && github.event_name == 'push'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm publish -r --access public
- name: Push changes to version branch
if: steps.update-versions.outputs.updated_packages != '' && github.event_name == 'push'
run: |
git checkout version
git merge main
git push origin version
- name: Create pull request
if: steps.update-versions.outputs.updated_packages != '' && github.event_name == 'push'
uses: peter-evans/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "(chore): updated package versions"
title: "(chore): Update package versions"
body: |
The following packages have been updated:
${{ steps.update-versions.outputs.updated_packages }}
branch: main
base: version