-
Notifications
You must be signed in to change notification settings - Fork 14
138 lines (118 loc) Β· 4.42 KB
/
snapshot.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Create SDK Snapshot
on:
pull_request:
branches: ['master']
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: π€ Checkout
uses: actions/checkout@v4
- name: βοΈ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- name: π Authenticate with NPM
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: 𧩠Install dependencies
run: npm ci --ignore-scripts
- name: ποΈ Bump version
run: npm run changeset:snapshot -- --pr $PR --sha $COMMIT_SHA --output release-plan.json
env:
PR: ${{ github.event.pull_request.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
- name: π οΈ Build SDK
run: npm run build
- name: π Publish snapshot
run: npm run changeset -- publish --no-git-tag --snapshot --tag beta
- name: β
Verify release plan
id: verify
run: |
cat release-plan.json
if [ $(jq '.releases | length' release-plan.json) -eq 0 ]; then
printf "\nNo new releases available :("
else
echo "upgrade_ui_deps=yes" >> $GITHUB_OUTPUT
fi
- name: β¬οΈ Upload release plan
uses: actions/upload-artifact@v4
with:
name: release-plan
path: release-plan.json
outputs:
upgrade_ui_deps: ${{ steps.verify.outputs.upgrade_ui_deps }}
upgrade-ui-deps:
needs:
- release
if: needs.release.outputs.upgrade_ui_deps == 'yes'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: β¬οΈ Download release plan
uses: actions/download-artifact@v4
with:
name: release-plan
- name: π€ Checkout hydration-ui repository
uses: actions/checkout@v4
with:
repository: 'galacticcouncil/hydration-ui'
token: ${{ secrets.TARGET_REPO_PAT }}
path: 'hydration-ui'
- name: βοΈ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: π§ Upgrade hydration-ui sdk packages
run: |
cd hydration-ui
jq -c '.releases[]' ../release-plan.json | while read i; do
package_name=$(jq --raw-output '.name' <<< "$i")
package_version=$(jq --raw-output '.newVersion' <<< "$i")
echo Installing $package_name@$package_version
yarn add $package_name@$package_version
done
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add package.json yarn.lock
git commit -m "$(jq '.releaseMessage' ../release-plan.json)"
- name: π§ Open hydration-ui PR with sdk upgrade
id: cpr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.TARGET_REPO_PAT }}
title: 'π§ SDK Preview: [${{ env.PR_TITLE }}]'
body: |
This PR was triggered by SDK upgrade no. ${{ env.PR }}
For details visit: https://github.com/galacticcouncil/sdk/pull/${{ env.PR }}
![Alt Text](https://media.tenor.com/DNCBqbguizsAAAAM/magic.gif)
branch: upgrade-sdk-pr${{ env.PR }}
base: master
path: 'hydration-ui'
draft: true
env:
PR: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
- name: π§ Print hydration-ui PR details
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
echo "Pull Request Action - ${{ steps.cpr.outputs.pull-request-operation }}"
- name: π§ Update sdk PR with live preview link
if: ${{ steps.cpr.outputs.pull-request-operation == 'created' }}
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'π§ Live preview: ${{ steps.cpr.outputs.pull-request-url }}'
})