From fd5fb5fbacf6f562d88c75753b46b0bede1155a7 Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 25 Apr 2024 12:29:51 -0700 Subject: [PATCH 01/13] [feat] refactor the package publication workflow (#152) --- .github/workflows/publish-package.yaml | 71 +++++++++++++------------- packages/core-sdk/package.json | 2 +- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index a98aabf7..06fe8b01 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -1,25 +1,20 @@ -name: Publish to npm, Tag and GH Release +name: Publish to npm, Tag and create GH Release on: push: branches: - main + pull_request: + branches: + - main jobs: - # Add timestamp - print_timestamp: - runs-on: ubuntu-latest - steps: - - name: Generate timestamp - run: | - echo "TIMESTAMP=$(TZ='America/Los_Angeles' date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV - - name: Print timestamp - run: | - echo "Execution time (Pacific Time Zone) $TIMESTAMP" + Timestamp: + uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main print_version_to_publish: - needs: [print_timestamp] + needs: [ Timestamp ] runs-on: ubuntu-latest outputs: version_to_be_published: ${{ steps.get_version_to_publish.outputs.VERSION_TO_BE_PUBLISHED }} @@ -35,18 +30,35 @@ jobs: # Fetch the latest version from NPM fetch_latest_version: - needs: [print_timestamp] + 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/core-sdk version) echo "Latest version of @story-protocol/core-sdk on NPMJS is $LATEST_VERSION" + echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_OUTPUT - # TO-DO: check if pushed version is greater than the latest version on NPM + # 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] + 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: @@ -90,24 +102,11 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Tag and Push - run: | - VERSION=${{ needs.print_version_to_publish.outputs.version_to_be_published }} - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' - git tag -a v$VERSION -m "Release v$VERSION" - git push origin v$VERSION - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ needs.print_version_to_publish.outputs.version_to_be_published }} - release_name: Release v${{ needs.print_version_to_publish.outputs.version_to_be_published }} - body: Release of version v${{ needs.print_version_to_publish.outputs.version_to_be_published }} - draft: false - prerelease: false + 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 }} diff --git a/packages/core-sdk/package.json b/packages/core-sdk/package.json index 1798238a..3a3deb22 100644 --- a/packages/core-sdk/package.json +++ b/packages/core-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@story-protocol/core-sdk", - "version": "1.0.0-rc.6", + "version": "1.0.0-rc.7", "description": "Story Protocol Core SDK", "main": "dist/story-protocol-core-sdk.cjs.js", "module": "dist/story-protocol-core-sdk.esm.js", From 4320c22750cefc6047174f00ec7e70981b1888ea Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 25 Apr 2024 12:33:48 -0700 Subject: [PATCH 02/13] [test] create release (#153) --- .github/workflows/publish-package.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 06fe8b01..92100a27 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -110,3 +110,4 @@ jobs: 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 }} + From 3798d25e1288b0c6b4a759f7657fb19ab4074a6f Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 25 Apr 2024 20:06:12 -0700 Subject: [PATCH 03/13] [feature] remove legacy workflow to create gh release (#157) --- .github/workflows/create_release.yaml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/workflows/create_release.yaml diff --git a/.github/workflows/create_release.yaml b/.github/workflows/create_release.yaml deleted file mode 100644 index 2d08470d..00000000 --- a/.github/workflows/create_release.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: Create Release - -on: - push: - tags: - - '*' - -jobs: - - Timestamp: - uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main - - CreateRelease: - needs: [ Timestamp ] - uses: storyprotocol/gha-workflows/.github/workflows/reusable-create-release.yml@main From 7951c9ccf42aabccfe02c1b4855d03647566a6f8 Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 25 Apr 2024 20:07:52 -0700 Subject: [PATCH 04/13] Test/create release workflow (#155) * [test] create release * [test] create release - 2 --- .github/workflows/publish-package.yaml | 27 ++++++++++++++++++++------ packages/core-sdk/package.json | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 92100a27..8a912138 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -9,12 +9,11 @@ on: - main jobs: - Timestamp: uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main print_version_to_publish: - needs: [ Timestamp ] + needs: [Timestamp] runs-on: ubuntu-latest outputs: version_to_be_published: ${{ steps.get_version_to_publish.outputs.VERSION_TO_BE_PUBLISHED }} @@ -30,7 +29,7 @@ jobs: # Fetch the latest version from NPM fetch_latest_version: - needs: [ Timestamp ] + needs: [Timestamp] runs-on: ubuntu-latest outputs: LATEST_VERSION: ${{ steps.get_latest_version.outputs.LATEST_VERSION }} @@ -74,7 +73,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - + - uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 with: version: 8.8.0 @@ -102,12 +101,28 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + test_push_tag: + needs: [print_version_to_publish, fetch_latest_version, fail_if_version_is_same] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Push tag + run: | + VERSION=${{ needs.print_version_to_publish.outputs.version_to_be_published }} + git config --global user.name 'GitHub Actions' + git config --global user.email 'actions@github.com' + git tag -a v$VERSION -m "Release v$VERSION" + git push origin v$VERSION + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_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' + # 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 }} - diff --git a/packages/core-sdk/package.json b/packages/core-sdk/package.json index 3a3deb22..1798238a 100644 --- a/packages/core-sdk/package.json +++ b/packages/core-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@story-protocol/core-sdk", - "version": "1.0.0-rc.7", + "version": "1.0.0-rc.6", "description": "Story Protocol Core SDK", "main": "dist/story-protocol-core-sdk.cjs.js", "module": "dist/story-protocol-core-sdk.esm.js", From b96a5f79a4826abc15a93db5b45747f2a84ddd6d Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 25 Apr 2024 20:09:31 -0700 Subject: [PATCH 05/13] Update publish-package.yaml (#158) --- .github/workflows/publish-package.yaml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 8a912138..d502c946 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -101,23 +101,6 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - test_push_tag: - needs: [print_version_to_publish, fetch_latest_version, fail_if_version_is_same] - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - - name: Push tag - run: | - VERSION=${{ needs.print_version_to_publish.outputs.version_to_be_published }} - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' - git tag -a v$VERSION -m "Release v$VERSION" - git push origin v$VERSION - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_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 From e74cd70db30f2b4e614a9843004eeb0fc60f9d6d Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Tue, 7 May 2024 15:57:47 -0700 Subject: [PATCH 06/13] [fix] add condition check back --- .github/workflows/publish-package.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index d502c946..3aad4480 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -105,7 +105,7 @@ jobs: 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' + 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 }} From 36e3d06eb234eb67592c6ffb4e59dd1b82b71a06 Mon Sep 17 00:00:00 2001 From: Ze Huang Date: Tue, 7 May 2024 22:57:46 -0700 Subject: [PATCH 07/13] Fix CI syntax issue --- .github/workflows/publish-package.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 2c7ca394..94036e3f 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -108,7 +108,7 @@ jobs: - name: Test run: pnpm test - - name: Build + - name: Build run: pnpm build - name: Publish to npm From 85646dfc08fc3c0013b78233a078037aae18792b Mon Sep 17 00:00:00 2001 From: cenevan <92879012+cenevan@users.noreply.github.com> Date: Fri, 17 May 2024 14:07:14 -0700 Subject: [PATCH 08/13] Cenevan demo (#195) * Create test-slack-notifs.yml * Update test-slack-notifs.yml --- .github/workflows/test-slack-notifs.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/test-slack-notifs.yml diff --git a/.github/workflows/test-slack-notifs.yml b/.github/workflows/test-slack-notifs.yml new file mode 100644 index 00000000..0229a9eb --- /dev/null +++ b/.github/workflows/test-slack-notifs.yml @@ -0,0 +1,16 @@ +name: test slack notifications + +on: + workflow_dispatch: + +jobs: + call-slack-notif: + uses: cenevan/gha-workflows/.github/workflows/reusable-slack-notifs.yml@main + with: + short-desc: 'Test Description' + title: 'Test Title' + img-url: 'https://imgur.com/gallery/npm-install-OsbqxXW' + img-alt-text: 'Test alt text' + secrets: + channel-name: ${{ secrets.SLACK_CHANNEL_ID_STORY_57BLOCKS }} + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} From 41b1ade9d0ddd3da69eb15bd9cdd74e29359c4fc Mon Sep 17 00:00:00 2001 From: cenevan <92879012+cenevan@users.noreply.github.com> Date: Fri, 17 May 2024 14:43:55 -0700 Subject: [PATCH 09/13] Update test-slack-notifs.yml (#196) --- .github/workflows/test-slack-notifs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-slack-notifs.yml b/.github/workflows/test-slack-notifs.yml index 0229a9eb..375e309d 100644 --- a/.github/workflows/test-slack-notifs.yml +++ b/.github/workflows/test-slack-notifs.yml @@ -9,7 +9,7 @@ jobs: with: short-desc: 'Test Description' title: 'Test Title' - img-url: 'https://imgur.com/gallery/npm-install-OsbqxXW' + img-url: 'https://i.imgur.com/eqfFZRb.jpeg' img-alt-text: 'Test alt text' secrets: channel-name: ${{ secrets.SLACK_CHANNEL_ID_STORY_57BLOCKS }} From dc2d348eb33f42b3cfa580d49372a2a421e13339 Mon Sep 17 00:00:00 2001 From: cenevan <92879012+cenevan@users.noreply.github.com> Date: Fri, 17 May 2024 15:00:52 -0700 Subject: [PATCH 10/13] Changed description and title for demo (#197) * Update test-slack-notifs.yml * Update test-slack-notifs.yml --- .github/workflows/test-slack-notifs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-slack-notifs.yml b/.github/workflows/test-slack-notifs.yml index 375e309d..512d1c52 100644 --- a/.github/workflows/test-slack-notifs.yml +++ b/.github/workflows/test-slack-notifs.yml @@ -7,8 +7,8 @@ jobs: call-slack-notif: uses: cenevan/gha-workflows/.github/workflows/reusable-slack-notifs.yml@main with: - short-desc: 'Test Description' - title: 'Test Title' + short-desc: 'https://www.npmjs.com/package/@story-protocol/core-sdk/v/1.0.0-rc.11' + title: 'Core SDK Package Published' img-url: 'https://i.imgur.com/eqfFZRb.jpeg' img-alt-text: 'Test alt text' secrets: From ddfa155559564833487afda454c2fb0f432b0718 Mon Sep 17 00:00:00 2001 From: cenevan <92879012+cenevan@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:03:12 -0700 Subject: [PATCH 11/13] Update publish-package.yml (#193) * Update publish-package.yaml * Update publish-package.yaml * Update publish-package.yaml * reusable slack workflow implemented --- .github/workflows/publish-package.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 4e1f4afe..3e15d00f 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -126,3 +126,15 @@ jobs: 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://imgur.com/a/6P1xFvE' + img-alt-text: 'Published to Registry' + secrets: + channel-name: ${{ secrets.SLACK_CHANNEL_ID_STORY_57BLOCKS }} + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} \ No newline at end of file From d7367a0a1d764f253b3c516497456671c250e005 Mon Sep 17 00:00:00 2001 From: cenevan <92879012+cenevan@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:07:16 -0700 Subject: [PATCH 12/13] Update publish-package.yaml (#211) --- .github/workflows/publish-package.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 3e15d00f..664ebcd4 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -133,8 +133,8 @@ jobs: 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://imgur.com/a/6P1xFvE' + 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 }} \ No newline at end of file + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} From d1b468590749e5960ae4048e8609520cbfee8cbf Mon Sep 17 00:00:00 2001 From: cenevan <92879012+cenevan@users.noreply.github.com> Date: Wed, 3 Jul 2024 11:36:53 -0700 Subject: [PATCH 13/13] Update publish-package.yaml (#217) --- .github/workflows/publish-package.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index 664ebcd4..eade6468 100644 --- a/.github/workflows/publish-package.yaml +++ b/.github/workflows/publish-package.yaml @@ -128,7 +128,7 @@ jobs: version_to_publish: ${{ needs.print_version_to_publish.outputs.version_to_be_published }} send_slack_notif: - needs: [build-test-publish, create_release] + needs: [print_version_to_publish, 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 }}'