diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..72243b8 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,24 @@ +name: Vercel Production Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +on: + push: + branches: + - main +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + working-directory: ./example + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + working-directory: ./example + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + working-directory: ./example + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..68c8d28 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,21 @@ +name: Publish to NPM + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '18.x' + registry-url: 'https://registry.npmjs.org' + - run: npm ci + - run: npm run build + - name: Publish package to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/example/package.json b/example/package.json index a4d2361..9669074 100644 --- a/example/package.json +++ b/example/package.json @@ -15,7 +15,7 @@ "eslint": "8.43.0", "eslint-config-next": "13.4.7", "next": "13.4.7", - "next13-progressbar": "../", + "next13-progressbar": "latest", "react": "18.2.0", "react-dom": "18.2.0", "typescript": "5.1.5" diff --git a/example/src/app/providers.tsx b/example/src/app/providers.tsx index d689ec0..c31710b 100644 --- a/example/src/app/providers.tsx +++ b/example/src/app/providers.tsx @@ -1,6 +1,10 @@ 'use client'; -import { Next13ProgressBar } from '../../../dist'; +// use this for local testing +// import { Next13ProgressBar } from '../../../dist'; + +// this for deploying example +import { Next13ProgressBar } from 'next13-progressbar'; const Providers = ({ children }: { children: React.ReactNode }) => { return ( diff --git a/package.json b/package.json index f3003e1..518cbfc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next13-progressbar", - "version": "1.0.0", + "version": "1.0.1", "description": "A ProgressBar for next.js 13 with app directory ", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/AppProgressBar.tsx b/src/AppProgressBar.tsx index a10a8af..556e5c6 100644 --- a/src/AppProgressBar.tsx +++ b/src/AppProgressBar.tsx @@ -149,8 +149,10 @@ export const Next13ProgressBar = React.memo( export function useRouter() { const router = useNextRouter(); + const pathname = usePathname(); function push(href: string, options?: NavigateOptions) { + if (href === pathname) return Promise.resolve(true); NProgress.start(); return router.push(href, options); }