Skip to content

[feat] refactor workflow to publish package #1

[feat] refactor workflow to publish package

[feat] refactor workflow to publish package #1

Workflow file for this run

name: Publish to npm and Tag Release
on:
push:
branches:
- master
- main
# TO-DELETE: created for testing only
pull_request:
branches:
- master
- main
jobs:
# Add timestamp
print_timestamp:
runs-on: ubuntu-latest
outputs:
PR_BRANCH_NAME: ${{ steps.get_pr_branch_name.outputs.PR_BRANCH_NAME }}
steps:
- name: Generate timestamp
run: |
echo "TIMESTAMP=$(TZ='America/Los_Angeles' date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
echo ${{ github.head_ref }}
- name: Print timestamp
run: |
echo "Execution time (Pacific Time Zone): $TIMESTAMP"
- name: Get PR branch name
id: get_pr_branch_name
run: |
echo "PR_BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_OUTPUT
# Fetch the latest version from NPM
fetch_latest_version:
needs: [print_timestamp]
runs-on: ubuntu-latest
steps:
- name: Get latest package version
run: |
LATEST_VERSION=$(npm view story-protocol/core-sdk version)
echo "Latest version is $LATEST_VERSION"
# TO-DO: check if pushed version is greater than the latest version on NPM
build-test-publish:
needs: [fetch_latest_version]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0
with:
version: 8.8.0
- name: Setup Node.js environment
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version: 20.0.0
cache: pnpm
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
# Disabled test for now for later validation
- name: Test
run: pnpm test
# - name: Publish to npm
# run: |
# cd packages/core-sdk
# npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}