From 71cefc59c171422a3c73cfabf000cb9c8ea4dcfb Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 15:34:49 -0700 Subject: [PATCH 01/10] Update build_and_publish.yml --- .github/workflows/build_and_publish.yml | 79 ++++++++++++++----------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 6abc9ee..fb05984 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -1,45 +1,56 @@ name: Build jsgeoda -on: [push] +on: [push, pull_request] jobs: build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x] - permissions: packages: write contents: read - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - registry-url: https://npm.pkg.github.com/ - scope: '@geodacenter' - - - name: Build&Test jsgeoda - run: | - npm install - npm run build --if-present - npm test - env: - # replace ${GITHUB_TOKEN} in .npmrc - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - # Publish to GitHub Package Registry - - name: Publish to GitHub Package Registry - # Only when release + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + - name: Build&Test jsgeoda + run: | + npm install + npm run build --if-present + npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + #if: startsWith(github.ref, 'refs/tags/v') + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + + publish-gpr: + needs: build + runs-on: ubuntu-latest + steps: if: startsWith(github.ref, 'refs/tags/v') - run: | - npm publish - env: - # replace ${GITHUB_TOKEN} in .npmrc - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 12 + registry-url: https://npm.pkg.github.com/ + scope: '@geodacenter' + - run: npm ci + - run: | + echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > .npmrc + echo "@geodacenter:registry=https://npm.pkg.github.com" >> .npmrc + echo "always-auth=true" >> .npmrc + - run: npm publish + env: + # replace ${GITHUB_TOKEN} in .npmrc + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From 54c1d255442c8eb370c1d332be908e01f1733720 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 15:39:12 -0700 Subject: [PATCH 02/10] Update build_and_publish.yml --- .github/workflows/build_and_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index fb05984..7972a2a 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -38,13 +38,13 @@ jobs: needs: build runs-on: ubuntu-latest steps: - if: startsWith(github.ref, 'refs/tags/v') - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: 12 registry-url: https://npm.pkg.github.com/ scope: '@geodacenter' + #if: startsWith(github.ref, 'refs/tags/v') - run: npm ci - run: | echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > .npmrc From 228c3f8a9967a1de27b5f02e02467973d8ea8918 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 15:45:04 -0700 Subject: [PATCH 03/10] Update build_and_publish.yml --- .github/workflows/build_and_publish.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 7972a2a..ab26017 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -23,14 +23,16 @@ jobs: needs: build runs-on: ubuntu-latest steps: - #if: startsWith(github.ref, 'refs/tags/v') - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: 12 registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish --access public + - name: publis-npm + #if: startsWith(github.ref, 'refs/tags/v') + run: | + npm ci + npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} @@ -44,13 +46,14 @@ jobs: node-version: 12 registry-url: https://npm.pkg.github.com/ scope: '@geodacenter' - #if: startsWith(github.ref, 'refs/tags/v') - - run: npm ci - - run: | - echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" > .npmrc - echo "@geodacenter:registry=https://npm.pkg.github.com" >> .npmrc - echo "always-auth=true" >> .npmrc - - run: npm publish + - name: publish-gpr + #if: startsWith(github.ref, 'refs/tags/v') + run: | + echo //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} > .npmrc + echo @geodacenter:registry=https://npm.pkg.github.com >> .npmrc + echo always-auth=true >> .npmrc + npm ci + npm publish env: # replace ${GITHUB_TOKEN} in .npmrc GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file From 5dc55ae46f5055178b16fa2cb410d0d96a027bf5 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 15:57:46 -0700 Subject: [PATCH 04/10] Delete .npmrc --- .npmrc | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .npmrc diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 164db61..0000000 --- a/.npmrc +++ /dev/null @@ -1,3 +0,0 @@ -//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} -@geodacenter:registry=https://npm.pkg.github.com -always-auth=true From 0640b9ee3e7d3b157e2f07b7f1a1db4a916e2d1b Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 16:03:00 -0700 Subject: [PATCH 05/10] Update build_and_publish.yml --- .github/workflows/build_and_publish.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index ab26017..0aa0149 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -31,7 +31,8 @@ jobs: - name: publis-npm #if: startsWith(github.ref, 'refs/tags/v') run: | - npm ci + npm install + npm run build --if-present npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} @@ -52,7 +53,8 @@ jobs: echo //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} > .npmrc echo @geodacenter:registry=https://npm.pkg.github.com >> .npmrc echo always-auth=true >> .npmrc - npm ci + npm install + npm run build --if-present npm publish env: # replace ${GITHUB_TOKEN} in .npmrc From 1ff2f50ed04454522d28e36463ef870836c63606 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 16:10:47 -0700 Subject: [PATCH 06/10] Update build_and_publish.yml --- .github/workflows/build_and_publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 0aa0149..3f32edc 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -38,7 +38,7 @@ jobs: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} publish-gpr: - needs: build + needs: publish-npm runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 25f7811cce3a285c9270cf92f7fc3d19cf423122 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 16:12:39 -0700 Subject: [PATCH 07/10] Update package.json --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 8825bc1..ee892e7 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,5 @@ }, "engines": { "node": ">=12" - }, - "publishConfig": { - "@geodacenter:registry": "https://npm.pkg.github.com" } } From 08d59989ba5228b7102e19db93396c083ea6f253 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 16:28:16 -0700 Subject: [PATCH 08/10] avoid redundant publication --- .github/workflows/build_and_publish.yml | 4 ++-- package.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 3f32edc..e6b5fd7 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -32,7 +32,7 @@ jobs: #if: startsWith(github.ref, 'refs/tags/v') run: | npm install - npm run build --if-present + npm run build npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} @@ -54,7 +54,7 @@ jobs: echo @geodacenter:registry=https://npm.pkg.github.com >> .npmrc echo always-auth=true >> .npmrc npm install - npm run build --if-present + npm run build npm publish env: # replace ${GITHUB_TOKEN} in .npmrc diff --git a/package.json b/package.json index ee892e7..16c0bd4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "serve": "http-server", "start": "npm run build && npm run serve", "doc": "jsdoc -d docs --configure jsconf.json --readme README.md", - "publish": "npm run build:bundle && npm publish --access public", "test": "tape tests/**/*.js" }, "devDependencies": { From e4c5d1a0c105698aab16171817776f2beae5bc25 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 16:32:32 -0700 Subject: [PATCH 09/10] change task dependency --- .github/workflows/build_and_publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index e6b5fd7..9ca2ddb 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -38,7 +38,7 @@ jobs: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} publish-gpr: - needs: publish-npm + needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -50,11 +50,11 @@ jobs: - name: publish-gpr #if: startsWith(github.ref, 'refs/tags/v') run: | + npm install + npm run build echo //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} > .npmrc echo @geodacenter:registry=https://npm.pkg.github.com >> .npmrc echo always-auth=true >> .npmrc - npm install - npm run build npm publish env: # replace ${GITHUB_TOKEN} in .npmrc From 6e78338d72eb9f956503cd818006dac2cc53b621 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Thu, 16 Sep 2021 16:37:29 -0700 Subject: [PATCH 10/10] add condition "tag" for publishing --- .github/workflows/build_and_publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml index 9ca2ddb..52d32e7 100644 --- a/.github/workflows/build_and_publish.yml +++ b/.github/workflows/build_and_publish.yml @@ -29,7 +29,7 @@ jobs: node-version: 12 registry-url: https://registry.npmjs.org/ - name: publis-npm - #if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') run: | npm install npm run build @@ -48,7 +48,7 @@ jobs: registry-url: https://npm.pkg.github.com/ scope: '@geodacenter' - name: publish-gpr - #if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') run: | npm install npm run build