From 85ad74e8cf2b2cfa453e4219a179843a2e78d0e9 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Tue, 14 Feb 2023 01:05:55 +0800 Subject: [PATCH 1/7] ci: add GitHub Actions to publish npm package Signed-off-by: Bofu Chen (bafu) --- .github/workflows/publish-npm.yml | 35 +++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-npm.yml diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..4ad82c9 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,35 @@ +# This workflow will build and publish a package to npmjs when a version release is created +# https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages#publishing-packages-using-yarn + +name: Publish Package to npmjs + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + +env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup .npmrc file to publish to npm + uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: 'https://registry.npmjs.org' + # Defaults to the user or organization that owns the workflow file + scope: '@numbersprotocol' + + - name: Build project + run: yarn build + + - name: Publish to npm + run: yarn publish --no-git-tag-version + env: + NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }} \ No newline at end of file diff --git a/package.json b/package.json index 963dfe4..e9ccea3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@numbersprotocol/nit", - "version": "1.2.9", + "version": "1.2.10", "description": "git for web3 digital asset", "main": "lib/nit.js", "repository": "https://github.com/numbersprotocol/nit", From 893fc8c346a24c4f4d1e12f21e3bf2d1ad56c702 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Tue, 14 Feb 2023 01:09:18 +0800 Subject: [PATCH 2/7] ci: add installing dependencies step Signed-off-by: Bofu Chen (bafu) --- .github/workflows/publish-npm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 4ad82c9..63a5cbc 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -26,6 +26,9 @@ jobs: # Defaults to the user or organization that owns the workflow file scope: '@numbersprotocol' + - name: Install dependencies + run: yarn install + - name: Build project run: yarn build From 043ac02f629b734d4ab7aeba612f03fdc5f97efb Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Tue, 14 Feb 2023 01:17:30 +0800 Subject: [PATCH 3/7] fix: bump @types/node to fix building issue https://github.com/microsoft/TypeScript/issues/51567 Signed-off-by: Bofu Chen (bafu) --- package.json | 2 +- yarn.lock | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e9ccea3..3b6e51a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@types/command-line-usage": "^5.0.2", "@types/crypto-js": "^4.1.1", "@types/mocha": "^9.1.0", - "@types/node": "^17.0.25", + "@types/node": "^18.13.0", "@typescript-eslint/eslint-plugin": "^5.51.0", "@typescript-eslint/parser": "^5.51.0", "chai": "^4.3.6", diff --git a/yarn.lock b/yarn.lock index 7907dcd..31c3b57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -725,16 +725,11 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== -"@types/node@*", "@types/node@>=13.7.0": +"@types/node@*", "@types/node@>=13.7.0", "@types/node@^18.13.0": version "18.13.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850" integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg== -"@types/node@^17.0.25": - version "17.0.45" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.45.tgz#2c0fafd78705e7a18b7906b5201a522719dc5190" - integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== - "@types/normalize-package-data@^2.4.0": version "2.4.1" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" From 9b085b7de043542a4486e23653b5cbabaa1988fb Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Tue, 14 Feb 2023 01:33:41 +0800 Subject: [PATCH 4/7] fix: remove scope in workflow which has been indicated in package name Signed-off-by: Bofu Chen (bafu) --- .github/workflows/publish-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 63a5cbc..4e77d4b 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -24,7 +24,7 @@ jobs: node-version: 16 registry-url: 'https://registry.npmjs.org' # Defaults to the user or organization that owns the workflow file - scope: '@numbersprotocol' + #scope: '@numbersprotocol' - name: Install dependencies run: yarn install From 04410cc1a73f2f98c7d0ad4fcba32f9e77ef20ec Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Tue, 14 Feb 2023 01:38:34 +0800 Subject: [PATCH 5/7] fix: add permissions to avoid %2f issue https://github.com/actions/setup-node/issues/269#issuecomment-869133236 Signed-off-by: Bofu Chen (bafu) --- .github/workflows/publish-npm.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 4e77d4b..58f4331 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -14,6 +14,9 @@ env: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout code uses: actions/checkout@v3 @@ -24,7 +27,7 @@ jobs: node-version: 16 registry-url: 'https://registry.npmjs.org' # Defaults to the user or organization that owns the workflow file - #scope: '@numbersprotocol' + scope: '@numbersprotocol' - name: Install dependencies run: yarn install From 36ccf263ec04f2254c3c68b4a8da082f20f7f5d0 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Thu, 11 Jan 2024 01:00:03 +0800 Subject: [PATCH 6/7] ci(.github/workflows/build.yml): add workflow for testing package creation Signed-off-by: Bofu Chen (bafu) --- .github/workflows/build.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7db8f33 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Build npm package + +on: + push: + branches: + - 'feature-*' + - 'fix-*' + pull_request: + branches: + - 'main' + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x, 18.x, 20.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn build From a46f59ed1de9dfc54e51bd6a0986c156311ee603 Mon Sep 17 00:00:00 2001 From: "Bofu Chen (bafu)" Date: Thu, 11 Jan 2024 01:03:30 +0800 Subject: [PATCH 7/7] fix(.github/workflows/build.yml): install deps before building pkg Signed-off-by: Bofu Chen (bafu) --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7db8f33..0238af7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,4 +28,5 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'yarn' + - run: yarn install - run: yarn build