diff --git a/.github/workflows/publish-package.yaml b/.github/workflows/publish-package.yaml index a98aabf7..ff5a7752 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,7 +30,7 @@ jobs: # Fetch the latest version from NPM fetch_latest_version: - needs: [print_timestamp] + needs: [ Timestamp ] runs-on: ubuntu-latest steps: - name: Get latest package version @@ -46,6 +41,8 @@ jobs: # TO-DO: check if pushed version is greater than the latest version on NPM build-test-publish: + # skip this job for testing + if: github.event_name == 'pull_request' needs: [print_version_to_publish, fetch_latest_version] runs-on: ubuntu-latest environment: 'beta-sepolia' @@ -90,24 +87,8 @@ 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] + uses: storyprotocol/gha-workflows/.github/workflows/reusable-create-release.yml@feat/refactor_reusable_create_release + with: + version_to_publish: ${{ needs.print_version_to_publish.outputs.version_to_be_published }}