diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f690e13..d4ee304 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,24 +1,22 @@ -name: NPM Publish - +name: Publish Package to npmjs on: release: types: [published] - jobs: publish: runs-on: ubuntu-latest + permissions: + id-token: write + contents: read steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Install dependencies - run: yarn install --frozen-lockfile - - - name: Verify & Build - run: yarn verify - - - name: Publish + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + cache: 'yarn' + - run: yarn install --frozen-lockfile + - run: yarn verify + - run: npm publish --access public --provenance env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: ./scripts/publish.sh - + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.npmrc b/.npmrc deleted file mode 100644 index ae64359..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -//registry.npmjs.org/:_authToken=${NPM_TOKEN} diff --git a/package.json b/package.json index 713c6aa..54a8a70 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "packsize-cli", - "version": "0.0.1", + "version": "0.0.0-alpha.1", "author": "rakesh ", "license": "MIT", "description": "package size control on a monorepo", diff --git a/scripts/publish.sh b/scripts/publish.sh index ab908ad..68df38a 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,15 +1,18 @@ #!/bin/bash -set -e +set -e -x # Get the current branch name -CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +CURRENT_BRANCH="${GITHUB_REF#refs/heads/}" +echo $CURRENT_BRANCH # Set the npm dist-tag based on the branch name -if [ "$CURRENT_BRANCH" != "main" ]; then - DIST_TAG="experimental" -else +if [ "$CURRENT_BRANCH" == "main" ]; then DIST_TAG="latest" +else + DIST_TAG="experimental" fi +echo $DIST_TAG + # Publish the package with the appropriate dist-tag -npm publish --tag "$DIST_TAG" \ No newline at end of file +# npm publish --tag "$DIST_TAG" \ No newline at end of file