Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
fix(ci): updating ci workflows (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
omercnet authored Feb 7, 2024
1 parent 3ba7f03 commit cd33a76
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 96 deletions.
86 changes: 21 additions & 65 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,33 @@ on:
branches:
- main

env:
NODE_VERSION: 16.14

jobs:
build:
name: 👷 Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://npm.pkg.github.com/
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
node-version-file: package.json
- run: npm ci
- name: Building
run: yarn build
env:
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
run: npm run build

lint:
name: 🪥 Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://npm.pkg.github.com/
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
node-version-file: package.json
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
- name: Linting
run: npm run lint
run: npm ci
- name: Lint Check
run: npm run lint-check
- name: Format check
run: npm run format-check

Expand All @@ -63,17 +41,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
node-version-file: package.json
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
run: npm ci
- name: Gitleaks
run: npm run leaks
shell: bash
Expand All @@ -83,20 +56,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/setup-node@v3
uses: actions/checkout@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://npm.pkg.github.com/
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
node-version-file: package.json
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
run: npm ci
- name: Testing
run: npm run test
- name: Coverage check
Expand All @@ -112,20 +76,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://npm.pkg.github.com/
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
node-version-file: package.json
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
run: npm ci
- name: License validation
shell: bash
run: ./thirdPartyLicenseCollector_linux_amd64 -npm-project .
15 changes: 4 additions & 11 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org/
node-version-file: package.json
- name: Get Short SHA
run: echo "SHORT_SHA=`echo ${{ github.sha }} | cut -c1-8`" >> $GITHUB_ENV
- name: Get Next Version
Expand All @@ -38,14 +37,8 @@ jobs:
yarn version --new-version ${NEW_VERSION}
cat package.json
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
run: npm ci
- name: Publish to NPM Package Registry
run: npm publish --access=public --tag next
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_REGISTRY }}
20 changes: 4 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
tags:
- 'release/**'

env:
NODE_VERSION: 16.14

jobs:
publish:
name: 📢 Publish
Expand All @@ -17,23 +14,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org/
# Skip post-install scripts here, as a malicious
# script could steal NODE_AUTH_TOKEN.
node-version-file: package.json
- name: Install dependencies
run: npm ci --ignore-scripts
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_READ_ORG }}
# `npm rebuild` will run all those post-install scripts for us.
- run: npm rebuild && npm run prepare --if-present
run: npm ci

- name: Publish to NPM Package Registry
run: npm publish --access=public
env:
CI: true
NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_REGISTRY }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
if: "contains(github.event.head_commit.message, 'RELEASE')"
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath "{}"' .
npx lint-staged
3 changes: 3 additions & 0 deletions package-lock.json

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

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,18 @@
"format": "prettier . -w --ignore-path .gitignore",
"format-check": "prettier . --check --ignore-path .gitignore",
"leaks": "bash ./scripts/gitleaks/gitleaks.sh",
"lint": "eslint '+(src)/**/*.+(ts|tsx)' --fix",
"lint": "npm run lint-check -- --fix",
"lint-check": "eslint '+(src)/**/*.+(ts|tsx)'",
"prepare": "husky install",
"prepublishOnly": "npm run build",
"start": "npm run build && (cd examples/app-router && npm run dev)",
"test": "jest"
},
"lint-staged": {
"+(src|test|examples)/**/*.{js,ts,jsx,tsx}": [
"npm run lint"
"npm run lint",
"npm run format",
"npm run leaks"
]
},
"dependencies": {
Expand Down Expand Up @@ -141,5 +144,8 @@
},
"optionalDependencies": {
"@descope/web-js-sdk": ">=1"
},
"engines": {
"node": "^18 || ^20"
}
}

0 comments on commit cd33a76

Please sign in to comment.