forked from decentralized-identity/web5-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangesets-api-release-check.sh
executable file
·46 lines (38 loc) · 1.55 KB
/
changesets-api-release-check.sh
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
#!/bin/bash
CHANGESET_STATUS=$(pnpm changeset status)
ALL_RELEASES_COUNT=$(echo $CHANGESET_STATUS | grep -o "web5/" | wc -l)
API_RELEASES_COUNT=$(echo $CHANGESET_STATUS | grep -o "web5/api" | wc -l)
# check if it has changesets
if [[ $ALL_RELEASES_COUNT == 0 ]]; then
echo "No changesets detected, proceed as normal..."
exit 0
fi
# check if it has any api releases to be handled
if [[ $API_RELEASES_COUNT == 0 ]]; then
echo "No API releases detected, proceed as normal..."
exit 0
fi
# manual kick api release trigger input
echo "KICK_API_RELEASE: $KICK_API_RELEASE"
# check for api release labeled PRs
API_RELEASE_PR=$(gh pr list \
--base 'main' \
--head 'changeset-release/main' \
--json title,labels,number \
--jq '[.[] | select(.labels[]?.name == "api-release")] | first | .number')
echo "API_RELEASE_PR: $API_RELEASE_PR"
if [[ -n $API_RELEASE_PR || $KICK_API_RELEASE == "true" ]]; then
echo "@web5/api release DETECTED"
RELEASE_WEB5_API="true"
echo "release_web5_api=$RELEASE_WEB5_API" >> $GITHUB_OUTPUT
exit 0
fi
if [[ $API_RELEASES_COUNT == $ALL_RELEASES_COUNT ]]; then
echo "Only @web5/api release detected, checking for API Release labeled PR or Kick trigger..."
if [[ -z $RELEASE_WEB5_API ]]; then
echo "No API Release labeled PR found and KICK_API_RELEASE is false, skipping the PR creation..."
# removes all the api changesets files to ensure a Version Packages PR is not created
find .changeset -type f -name "*.md" ! -name "README.md" -exec rm {} +
exit 0
fi
fi