Skip to content

Commit

Permalink
Update publish-package.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnie57 committed Jul 3, 2024
1 parent 437919d commit dce8bbe
Showing 1 changed file with 26 additions and 43 deletions.
69 changes: 26 additions & 43 deletions .github/workflows/publish-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ jobs:
echo "The core-sdk and react-sdk versions to be published are the same as the latest versions on NPM. "
exit 1
fi
echo "$(needs.fetch_latest_version.outputs.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_version_to_be_published || needs.fetch_latest_version.outputs.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_version_to_be_published) && github.event_name == 'push'""
build-test:
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.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_version_to_be_published || needs.fetch_latest_version.outputs.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_version_to_be_published) && github.event_name == 'push'}}
if: ${{ ((needs.fetch_latest_version.outputs.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_version_to_be_published) || (needs.fetch_latest_version.outputs.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_version_to_be_published)) && github.event_name == 'push'}}
runs-on: ubuntu-latest
environment: "beta-sepolia"
env:
Expand Down Expand Up @@ -130,70 +129,54 @@ jobs:
- name: Build
run: pnpm build

publish-core-sdk:
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.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_version_to_be_published && github.event_name == 'push'}}
runs-on: ubuntu-latest
steps:
- name: Publish to npm
- name: Publish core-sdk package to npm
if: ${{ needs.fetch_latest_version.outputs.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_version_to_be_published && github.event_name == 'push'}}
run: |
cd packages/core-sdk
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

create_release-core-sdk:
needs:
[print_version_to_publish, fetch_latest_version, fail_if_version_is_same]
- name: Publish react-sdk package to npm
if: ${{ needs.fetch_latest_version.outputs.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_version_to_be_published && github.event_name == 'push'}}
run: |
cd packages/react-sdk
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

create-release-core-sdk:
needs: [build-test-publish, print_version_to_publish, fetch_latest_version]
# 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.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_version_to_be_published && github.event_name == 'push'
if: ${{ needs.fetch_latest_version.outputs.core_sdk_latest_version != needs.print_version_to_publish.outputs.core_sdk_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.core_sdk_version_to_be_published }}

send_slack_notif-core-sdk:
needs: [build-test, create_release-core-sdk]
needs: [build-test-publish, create-release-core-sdk]
uses: storyprotocol/gha-workflows/.github/workflows/reusable-slack-notifs.yml@main
with:
short-desc: "${{ github.repository }}: Core-sdk package has been published to NPM Registry, version: ${{ needs.print_version_to_publish.outputs.core_sdk_version_to_be_published }}"
short-desc: "${{ github.repository }}: Core-sdk package has been published to NPM Registry, version: ${{ needs.print_version_to_publish.outputs.core_sdk_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 }}

publish-react-sdk:
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.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_version_to_be_published && github.event_name == 'push'}}
runs-on: ubuntu-latest
steps:
- name: Publish to npm
run: |
cd packages/react-sdk
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

create_release-react-sdk:
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.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_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.react_sdk_version_to_be_published }}
# create-release-react-sdk:
# needs: [build-test-publish, print_version_to_publish, fetch_latest_version]
# # 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.react_sdk_latest_version != needs.print_version_to_publish.outputs.react_sdk_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.react_sdk_version_to_be_published }}

send_slack_notif-react-sdk:
needs: [build-test, create_release-react-sdk]
needs: [build-test-publish]
uses: storyprotocol/gha-workflows/.github/workflows/reusable-slack-notifs.yml@main
with:
short-desc: "${{ github.repository }}: React-sdk package has been published to NPM Registry, version: ${{ needs.print_version_to_publish.outputs.react_sdk_version_to_be_published }}"
Expand Down

0 comments on commit dce8bbe

Please sign in to comment.