From 7aeff7db6bd184ba9d5457a11a7fa74a5941e76a Mon Sep 17 00:00:00 2001 From: Thiago Zanetti Date: Wed, 8 Mar 2023 16:34:57 -0300 Subject: [PATCH] Adding app publishing workflow and some minor improvements (#374) * Starting the refactoring with React 18 and modern JS * Working with pnpm * Adding tsup to build the project * Back to npm and node16 for storybook compatibility * Fixing repo by splitting both lib and app (turbo) * Tweaking projects to function properly * Adding big.js to work with precision float points * Removing React import since it's not needed anymore * Using a more meaningful name and adding types * Adding default value for inputRef * Adding types * Re-issuing the example app * Adding the global start:app task * Moving component to its individual file * Adding react-syntax-highliter and some css * Improving ts configuration * Improving app css * adding lint * adding ci workflow * Removing node 14.x from CI matrix * Adding files and folders to .npmignore * Adding publish workflow * Renaming publish to publish-lib * Building app * Moving to node 18 * Ignoring vercel data * Improving lib publishing worflow * Adding app publishing workflow --- .github/workflows/publish-app.yml | 61 +++++++++++++++++++++++++++++++ .github/workflows/publish-lib.yml | 54 +++++++++++++++++++-------- .gitignore | 5 ++- .node-version | 1 + .npmignore | 1 + package-lock.json | 2 +- package.json | 2 +- 7 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/publish-app.yml create mode 100644 .node-version diff --git a/.github/workflows/publish-app.yml b/.github/workflows/publish-app.yml new file mode 100644 index 0000000..c540a96 --- /dev/null +++ b/.github/workflows/publish-app.yml @@ -0,0 +1,61 @@ +# This workflow will run tests using node and then publish to vercel when a release is created +name: Publish to Vercel + +on: + release: + types: [created] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + - run: npm ci + - run: npx turbo run lint + - run: npx turbo run build:app + + - name: Sav app artifacts + uses: actions/upload-artifact@v3 + with: + name: app + path: dist/app + + publish: + + needs: build + + runs-on: ubuntu-latest + + environment: Production + + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + + steps: + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Download previously built app artifacts + uses: actions/download-artifact@v3 + with: + name: app + + - name: Pull Vercel Environment Information + run: npx vercel@latest pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: npx vercel@latest build --prod --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + run: npx vercel@latest deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/publish-lib.yml b/.github/workflows/publish-lib.yml index 07d0b41..3eea9d8 100644 --- a/.github/workflows/publish-lib.yml +++ b/.github/workflows/publish-lib.yml @@ -1,34 +1,58 @@ # This workflow will run tests using node and then publish a package to NPM when a release is created # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages name: Publish to NPM + on: release: types: [created] + jobs: build: + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 with: - node-version: 16 - - run: npm i -g turbo + node-version: 18 - run: npm ci - - run: turbo run lint - - run: turbo run build:lib + - run: npx turbo run lint + - run: npx turbo run build:lib + + - name: Save lib artifacts + uses: actions/upload-artifact@v3 + with: + name: lib + path: dist/lib + publish-npm: + needs: build + runs-on: ubuntu-latest + + environment: Production + steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 registry-url: https://registry.npmjs.org/ - - run: npm i -g turbo - - run: npm ci - - run: turbo run lint - - run: turbo run build:lib - - run: npm publish + + - name: Download previously built lib artifacts + uses: actions/download-artifact@v3 + with: + name: lib + + - name: Publish npm package + run: npm publish env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.gitignore b/.gitignore index d03e0f0..42ca5dd 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,9 @@ Temporary Items # turbo repos .turbo +# vercel +.vercel/ + # Logs logs *.log @@ -232,4 +235,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# End of https://www.toptal.com/developers/gitignore/api/node,linux,react,windows,macos \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/node,linux,react,windows,macos diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..0828ab7 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v18 \ No newline at end of file diff --git a/.npmignore b/.npmignore index b4fc097..2dea2c0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ .github/ .turbo/ .vscode/ +.vercel/ dist/app/ app/ node_modules/ diff --git a/package-lock.json b/package-lock.json index c361d0e..775d495 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "vite": "^4.1.4" }, "engines": { - "node": "16", + "node": "18", "npm": "9" } }, diff --git a/package.json b/package.json index 9150082..38c59ba 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ }, "homepage": "https://github.com/thiagozanetti/react-intl-currency-input#readme", "engines": { - "node": "16", + "node": "18", "npm": "9" }, "workspaces": [