Update react-sdk version #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish react-sdk to npm, Tag and create GH Release | |
on: | |
workflow_run: | |
workflows: ["Publish core-sdk to npm, Tag and create GH Release"] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
Timestamp: | |
uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main | |
print_version_to_publish: | |
needs: [Timestamp] | |
runs-on: ubuntu-latest | |
outputs: | |
version_to_be_published: ${{ steps.get_version_to_publish.outputs.VERSION_TO_BE_PUBLISHED }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Get version to publish | |
id: get_version_to_publish | |
run: | | |
content=$(cat packages/react-sdk/package.json) | |
echo "VERSION_TO_BE_PUBLISHED=$(echo $content | jq -r '.version')" >> $GITHUB_OUTPUT | |
# Fetch the latest version from NPM | |
fetch_latest_version: | |
needs: [Timestamp] | |
runs-on: ubuntu-latest | |
outputs: | |
LATEST_VERSION: ${{ steps.get_latest_version.outputs.LATEST_VERSION }} | |
steps: | |
- name: Get latest package version | |
id: get_latest_version | |
run: | | |
LATEST_VERSION=$(npm view @story-protocol/react-sdk version) | |
if [ -z "$LATEST_VERSION" ]; then | |
echo "Latest version of @story-protocol/react-sdk is not available on NPMJS" | |
fi | |
echo "Latest version of @story-protocol/react-sdk on NPMJS is $LATEST_VERSION" | |
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
# Fail the PR if the version to be published is the same as the latest version on NPM | |
fail_if_version_is_same: | |
needs: [print_version_to_publish, fetch_latest_version] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fail if version is the same | |
run: | | |
if [ "${{ needs.fetch_latest_version.outputs.LATEST_VERSION }}" == "${{ needs.print_version_to_publish.outputs.version_to_be_published }}" ]; then | |
echo "The version to be published is the same as the latest version on NPM. Exiting..." | |
exit 1 | |
fi | |
build-test-publish: | |
needs: | |
[print_version_to_publish, fetch_latest_version, fail_if_version_is_same] | |
# Skip this job if the version to be published is the same as the latest version on NPM | |
# and the event triggering the workflow is a push | |
if: needs.fetch_latest_version.outputs.LATEST_VERSION != needs.print_version_to_publish.outputs.version_to_be_published && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
environment: "beta-sepolia" | |
env: | |
RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} | |
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} | |
TEST_WALLET_ADDRESS: ${{ secrets.TEST_WALLET_ADDRESS }} | |
SEPOLIA_RPC_PROVIDER_URL: ${{ secrets.SEPOLIA_RPC_PROVIDER_URL }} | |
TEST_SEPOLIA_RPC_PROVIDER_URL: ${{ secrets.TEST_SEPOLIA_RPC_PROVIDER_URL }} | |
SEPOLIA_WALLET_PRIVATE_KEY: ${{ secrets.SEPOLIA_WALLET_PRIVATE_KEY }} | |
SEPOLIA_TEST_WALLET_ADDRESS: ${{ secrets.SEPOLIA_TEST_WALLET_ADDRESS }} | |
STORY_TEST_NET_RPC_PROVIDER_URL: ${{ secrets.STORY_TEST_NET_RPC_PROVIDER_URL }} | |
STORY_TEST_NET_WALLET_PRIVATE_KEY: ${{ secrets.STORY_TEST_NET_WALLET_PRIVATE_KEY }} | |
STORY_TEST_NET_TEST_WALLET_ADDRESS: ${{ secrets.STORY_TEST_NET_TEST_WALLET_ADDRESS }} | |
steps: | |
- name: Publish to npm | |
run: | | |
cd packages/react-sdk | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
create_release: | |
needs: | |
[print_version_to_publish, fetch_latest_version, fail_if_version_is_same] | |
# Skip this job if the version to be published is the same as the latest version on NPM | |
# and the event triggering the workflow is a push | |
if: needs.fetch_latest_version.outputs.LATEST_VERSION != needs.print_version_to_publish.outputs.version_to_be_published && github.event_name == 'push' | |
uses: storyprotocol/gha-workflows/.github/workflows/reusable-create-release.yml@main | |
with: | |
version_to_publish: ${{ needs.print_version_to_publish.outputs.version_to_be_published }} | |
send_slack_notif: | |
needs: [build-test-publish, create_release] | |
uses: storyprotocol/gha-workflows/.github/workflows/reusable-slack-notifs.yml@main | |
with: | |
short-desc: "${{ github.repository }}: Package has been published to NPM Registry, version: ${{ needs.print_version_to_publish.outputs.version_to_be_published }}" | |
title: "Published to Registry" | |
img-url: "https://i.imgur.com/JHmKB0s.png" | |
img-alt-text: "Published to Registry" | |
secrets: | |
channel-name: ${{ secrets.SLACK_CHANNEL_ID_STORY_57BLOCKS }} | |
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} |