Skip to content

Commit

Permalink
Merge pull request #6 from rake7h/publish-setup
Browse files Browse the repository at this point in the history
Publish setup
  • Loading branch information
rake7h authored Feb 11, 2024
2 parents bd69ee7 + 8625230 commit 39e0ffc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
30 changes: 14 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "packsize-cli",
"version": "0.0.1",
"version": "0.0.0-alpha.1",
"author": "rakesh <[email protected]>",
"license": "MIT",
"description": "package size control on a monorepo",
Expand Down
15 changes: 9 additions & 6 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -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"
# npm publish --tag "$DIST_TAG"

0 comments on commit 39e0ffc

Please sign in to comment.