Skip to content

Commit 3f39561

Browse files
Merge pull request #531 from reown-com/fix-prerelease-pr-comment
Fix prerelease PR comment and add Slack notifications
2 parents c032ff9 + 92fdf6e commit 3f39561

File tree

2 files changed

+88
-13
lines changed

2 files changed

+88
-13
lines changed

.github/workflows/changesets.yml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
# gh release create "v$VERSION" --generate-notes --target main
6262

6363
- name: Publish NPM pre-release
64+
id: publish_prerelease
6465
if: steps.changesets.outputs.published != 'true'
6566
continue-on-error: true
6667
env:
@@ -74,24 +75,54 @@ jobs:
7475
yarn run changeset publish --no-git-tag --snapshot canary --tag canary
7576
7677
- name: Get NPM Version
77-
if: steps.changesets.outputs.published != 'true'
78+
if: steps.publish_prerelease.outcome == 'success'
7879
id: get_version
7980
run: |
8081
VERSION=$(node -pe "require('./package.json').version")
81-
echo "VERSION=$VERSION" >> $GITHUB_ENV
82+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
8283
8384
- name: Comment Version on Pull Request
84-
if: steps.changesets.outputs.published != 'true'
85+
if: steps.publish_prerelease.outcome == 'success' && steps.changesets.outputs.pullRequestNumber
8586
env:
8687
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8788
run: |
88-
# Find PR associated with the current commit
89-
PR_NUMBER=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls \
90-
--jq '.[0].number' 2>/dev/null || echo "")
91-
92-
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
93-
gh pr comment $PR_NUMBER --body "Published pre-release version: ${{ env.VERSION }}"
94-
echo "Commented on PR #$PR_NUMBER"
95-
else
96-
echo "No associated PR found. This might be a direct push to main."
97-
fi
89+
gh pr comment ${{ steps.changesets.outputs.pullRequestNumber }} \
90+
--body "Published pre-release version: ${{ steps.get_version.outputs.VERSION }}"
91+
echo "Commented on PR #${{ steps.changesets.outputs.pullRequestNumber }}"
92+
93+
- name: Send Slack notification
94+
if: steps.publish_prerelease.outcome == 'success'
95+
continue-on-error: true
96+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
97+
with:
98+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
99+
webhook-type: incoming-webhook
100+
payload: |
101+
{
102+
"text": "📦 AppKit RN Canary Published",
103+
"blocks": [
104+
{
105+
"type": "header",
106+
"text": { "type": "plain_text", "text": "📦 AppKit RN Canary Published" }
107+
},
108+
{
109+
"type": "section",
110+
"fields": [
111+
{ "type": "mrkdwn", "text": "*Version:*\n`${{ steps.get_version.outputs.VERSION }}`" },
112+
{ "type": "mrkdwn", "text": "*Tag:*\n`canary`" },
113+
{ "type": "mrkdwn", "text": "*Branch:*\n`${{ github.ref_name }}`" },
114+
{ "type": "mrkdwn", "text": "*Triggered by:*\n`${{ github.actor }}`" }
115+
]
116+
},
117+
{
118+
"type": "section",
119+
"text": { "type": "mrkdwn", "text": "*NPM:* <https://www.npmjs.com/package/@reown/appkit-react-native/v/${{ steps.get_version.outputs.VERSION }}|@reown/appkit-react-native>" }
120+
},
121+
{
122+
"type": "context",
123+
"elements": [
124+
{ "type": "mrkdwn", "text": "Install: `yarn add @reown/appkit-react-native@canary`" }
125+
]
126+
}
127+
]
128+
}

.github/workflows/snapshot.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,50 @@ jobs:
9292
yarn run changeset:prepublish:ci
9393
yarn run changeset publish --no-git-tag --snapshot $snapshot --tag $snapshot
9494
95+
- name: Get NPM Version
96+
if: steps.check-changesets.outputs.has_changesets == 'true'
97+
id: get_version
98+
run: |
99+
VERSION=$(node -pe "require('./package.json').version")
100+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
101+
102+
- name: Send Slack notification
103+
if: steps.check-changesets.outputs.has_changesets == 'true'
104+
continue-on-error: true
105+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
106+
with:
107+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
108+
webhook-type: incoming-webhook
109+
payload: |
110+
{
111+
"text": "📦 AppKit RN Snapshot Published",
112+
"blocks": [
113+
{
114+
"type": "header",
115+
"text": { "type": "plain_text", "text": "📦 AppKit RN Snapshot Published" }
116+
},
117+
{
118+
"type": "section",
119+
"fields": [
120+
{ "type": "mrkdwn", "text": "*Version:*\n`${{ steps.get_version.outputs.VERSION }}`" },
121+
{ "type": "mrkdwn", "text": "*Tag:*\n`${{ steps.determine-tag.outputs.tag }}`" },
122+
{ "type": "mrkdwn", "text": "*Branch:*\n`${{ github.ref_name }}`" },
123+
{ "type": "mrkdwn", "text": "*Triggered by:*\n`${{ github.actor }}`" }
124+
]
125+
},
126+
{
127+
"type": "section",
128+
"text": { "type": "mrkdwn", "text": "*NPM:* <https://www.npmjs.com/package/@reown/appkit-react-native/v/${{ steps.get_version.outputs.VERSION }}|@reown/appkit-react-native>" }
129+
},
130+
{
131+
"type": "context",
132+
"elements": [
133+
{ "type": "mrkdwn", "text": "Install: `yarn add @reown/appkit-react-native@${{ steps.determine-tag.outputs.tag }}`" }
134+
]
135+
}
136+
]
137+
}
138+
95139
- name: Get Snapshot Tag
96140
id: get-snapshot-tag
97141
run: |

0 commit comments

Comments
 (0)