Skip to content

Commit

Permalink
Adding app publishing workflow and some minor improvements (#374)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thiagozanetti authored Mar 8, 2023
1 parent e3e3cef commit 7aeff7d
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 18 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/publish-app.yml
Original file line number Diff line number Diff line change
@@ -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 }}
54 changes: 39 additions & 15 deletions .github/workflows/publish-lib.yml
Original file line number Diff line number Diff line change
@@ -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}}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Temporary Items
# turbo repos
.turbo

# vercel
.vercel/

# Logs
logs
*.log
Expand Down Expand Up @@ -232,4 +235,4 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/node,linux,react,windows,macos
# End of https://www.toptal.com/developers/gitignore/api/node,linux,react,windows,macos
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.github/
.turbo/
.vscode/
.vercel/
dist/app/
app/
node_modules/
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"homepage": "https://github.com/thiagozanetti/react-intl-currency-input#readme",
"engines": {
"node": "16",
"node": "18",
"npm": "9"
},
"workspaces": [
Expand Down

0 comments on commit 7aeff7d

Please sign in to comment.