From d805e9cee7232c7c7b4a5679ca2c810f595518c2 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Tue, 5 Jul 2022 15:43:55 +1000 Subject: [PATCH 01/14] Commence release-npm DEVOPS-946 copied latest build-npm 2be9ebc as base --- .github/workflows/release-npm.yml | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/release-npm.yml diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml new file mode 100644 index 0000000..79a5606 --- /dev/null +++ b/.github/workflows/release-npm.yml @@ -0,0 +1,61 @@ +name: build-npm + +on: + workflow_dispatch: + +env: + NODEJS_VERSION: '16' + FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' + COMPILE_TRANSLATION_FILES: 'true' + +jobs: + build-npm: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Get version from package.json + id: package_version + uses: notiz-dev/github-action-json-property@release + with: + path: 'package.json' + prop_path: 'version' + - name: Gather some variables + run: | + echo "PACKAGE_VERSION=${{ steps.package_version.outputs.prop }}" >> $GITHUB_ENV + echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV + - name: Report some variables + run: | + echo "PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}" + echo "github.REF=${{ github.REF }}" + echo "DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }}" + - name: Setup kernel for react native, increase watchers + run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODEJS_VERSION }} + check-latest: true + always-auth: true + - name: Set yarn config + run: yarn config set @folio:registry $FOLIO_NPM_REGISTRY + - name: Run yarn install + run: yarn install --ignore-scripts + - name: Run yarn list of modules + run: yarn list --pattern "@folio|@reshare|@indexdata" + - name: Run yarn lint + run: yarn lint + continue-on-error: true + - name: Run yarn formatjs-compile + if: ${{ env.COMPILE_TRANSLATION_FILES == 'true' }} + run: yarn formatjs-compile + - name: Generate FOLIO module descriptor + run: yarn build-mod-descriptor + - name: Print FOLIO module descriptor + run: cat module-descriptor.json + - name: Publish yarn.lock + uses: actions/upload-artifact@v3 + with: + name: yarn.lock + path: yarn.lock + retention-days: 5 From 3ceebf7a1f489d23328b05cdbf0207fc933e69fd Mon Sep 17 00:00:00 2001 From: David Crossley Date: Tue, 5 Jul 2022 16:30:32 +1000 Subject: [PATCH 02/14] Ensure version numbers --- .github/workflows/release-npm.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 79a5606..3b5bedb 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -1,19 +1,28 @@ -name: build-npm +name: release-npm + +# Status: In development. +# Is only triggered via push to branch (later will only be triggered via git tag) on: - workflow_dispatch: + push: + branches: [ DEVOPS-946-workflows-npm ] env: + TAG_GIT: 'v0.0.1' # FIXME: Temporary for testing. Later will use actual git tag. NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' COMPILE_TRANSLATION_FILES: 'true' jobs: - build-npm: + release-npm: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Set TAG_VERSION + # FIXME: When in production, use actual git tag. + # run: echo "TAG_VERSION=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV + run: echo "TAG_VERSION=$(echo ${TAG_GIT#v})" >> $GITHUB_ENV - name: Get version from package.json id: package_version uses: notiz-dev/github-action-json-property@release @@ -27,8 +36,14 @@ jobs: - name: Report some variables run: | echo "PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}" + echo "TAG_VERSION=${{ env.TAG_VERSION }}" echo "github.REF=${{ github.REF }}" echo "DEFAULT_BRANCH=${{ env.DEFAULT_BRANCH }}" + - name: Ensure that git tag matches the version from package.json + if: ${{ env.TAG_VERSION != env.PACKAGE_VERSION }} + run: | + echo "Git tag version '${{ env.TAG_VERSION }}' does not match package.json version '${{ env.PACKAGE_VERSION }}'." + exit 1 - name: Setup kernel for react native, increase watchers run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: Use Node.js From 44dd95573b1258d618cd17e491f5926f54b12c8a Mon Sep 17 00:00:00 2001 From: David Crossley Date: Tue, 5 Jul 2022 16:35:47 +1000 Subject: [PATCH 03/14] Test version mismatch --- .github/workflows/release-npm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 3b5bedb..395878d 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -8,7 +8,7 @@ on: branches: [ DEVOPS-946-workflows-npm ] env: - TAG_GIT: 'v0.0.1' # FIXME: Temporary for testing. Later will use actual git tag. + TAG_GIT: 'v0.0.2' # FIXME: Temporary for testing. Later will use actual git tag. NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' COMPILE_TRANSLATION_FILES: 'true' From fb5e4a312f2820222e4945b803bc0824f08dfbe0 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Tue, 5 Jul 2022 17:05:42 +1000 Subject: [PATCH 04/14] Add steps for ModuleDescriptor publish --- .github/workflows/release-npm.yml | 48 ++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 395878d..5593ca6 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -8,9 +8,12 @@ on: branches: [ DEVOPS-946-workflows-npm ] env: - TAG_GIT: 'v0.0.2' # FIXME: Temporary for testing. Later will use actual git tag. + TAG_GIT: 'v0.0.1' # FIXME: Temporary for testing. Later will use actual git tag. + DO_PUBLISH_MD: 'false' # FIXME: For testing. + DO_PUBLISH_NPM: 'false' # FIXME: For testing. NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' + FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com' COMPILE_TRANSLATION_FILES: 'true' jobs: @@ -68,6 +71,49 @@ jobs: run: yarn build-mod-descriptor - name: Print FOLIO module descriptor run: cat module-descriptor.json + - name: Read module descriptor + id: moduleDescriptor + uses: juliangruber/read-file-action@v1 + with: + path: ./module-descriptor.json + - name: Login ModuleDescriptor registry + id: login-md-registry + uses: indiesdev/curl@v1.1 + with: + url: "${{ env.FOLIO_MD_REGISTRY }}/authn/login" + method: "POST" + accept: 201 + headers: | + { + "content-type": "application/json", + "x-okapi-tenant": "${{ secrets.FOLIO_REGISTRY_TENANT }}" + } + body: | + { + "username": "${{ secrets.FOLIO_REGISTRY_USERNAME }}", + "password": "${{ secrets.FOLIO_REGISTRY_PASSWORD }}" + } + - name: Get the MD registry login token + run: | + echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV + # FIXME: Login to public NPM registry for namespace indexdata + # FIXME: Login to docker registry to get okapi docker image + # FIXME: Start local Okapi, pull MDs from both FOLIO and Indexdata MD registries, do dependency check + - name: Publish ModuleDescriptor to MD registry + if: ${{ env.DO_PUBLISH_MD == 'true' }} + id: result-md-registry + uses: indiesdev/curl@v1.1 + with: + url: "${{ env.FOLIO_MD_REGISTRY }}/_/proxy/modules" + method: "POST" + accept: 201 + headers: | + { + "content-type": "application/json", + "x-okapi-tenant": "${{ secrets.FOLIO_REGISTRY_TENANT }}", + "x-okapi-token": "${{ env.TOKEN_MD_REGISTRY }}" + } + body: ${{ steps.moduleDescriptor.outputs.content }} - name: Publish yarn.lock uses: actions/upload-artifact@v3 with: From 8ca2944e2e86ad5542939d8eeb3325ae10068408 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 12:01:03 +1000 Subject: [PATCH 05/14] Do login docker, pull, start local okapi --- .github/workflows/release-npm.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 5593ca6..aaad9ed 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -97,8 +97,17 @@ jobs: run: | echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV # FIXME: Login to public NPM registry for namespace indexdata - # FIXME: Login to docker registry to get okapi docker image - # FIXME: Start local Okapi, pull MDs from both FOLIO and Indexdata MD registries, do dependency check + - name: Docker registry login + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login https://docker.io/v2/ -u "${{ secrets.DOCKER_USER }}" --password-stdin + - name: Start a local instance of Okapi + run: | + docker pull folioorg/okapi:latest + docker run --name okapi -t -detach folioorg/okapi:latest dev + echo "OKAPI_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' okapi)" >> $GITHUB_ENV + sleep 10 + - name: Docker registry logout + run: docker logout https://docker.io/v2/ + # FIXME: Okapi pull MDs from both FOLIO and Indexdata MD registries, do dependency check - name: Publish ModuleDescriptor to MD registry if: ${{ env.DO_PUBLISH_MD == 'true' }} id: result-md-registry From 0870116faab8bd10eb6118429b525cedfc84f2cc Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 12:22:04 +1000 Subject: [PATCH 06/14] Use docker login-action --- .github/workflows/release-npm.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index aaad9ed..6596442 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -97,8 +97,13 @@ jobs: run: | echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV # FIXME: Login to public NPM registry for namespace indexdata +# - name: Docker registry login +# run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login https://docker.io/v2/ -u "${{ secrets.DOCKER_USER }}" --password-stdin - name: Docker registry login - run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login https://docker.io/v2/ -u "${{ secrets.DOCKER_USER }}" --password-stdin + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: Start a local instance of Okapi run: | docker pull folioorg/okapi:latest From 73ec1e4249cea96da6a726969b30972deb7093a4 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 13:44:40 +1000 Subject: [PATCH 07/14] Do Okapi pull MDs and deps check --- .github/workflows/release-npm.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 6596442..46a38ea 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -14,6 +14,7 @@ env: NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com' + OKAPI_PULL: '{ "urls" : [ "https://folio-registry.dev.folio.org", "https://registry.folio-dev.indexdata.com" ] }' COMPILE_TRANSLATION_FILES: 'true' jobs: @@ -97,8 +98,6 @@ jobs: run: | echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV # FIXME: Login to public NPM registry for namespace indexdata -# - name: Docker registry login -# run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login https://docker.io/v2/ -u "${{ secrets.DOCKER_USER }}" --password-stdin - name: Docker registry login uses: docker/login-action@v2 with: @@ -112,7 +111,31 @@ jobs: sleep 10 - name: Docker registry logout run: docker logout https://docker.io/v2/ - # FIXME: Okapi pull MDs from both FOLIO and Indexdata MD registries, do dependency check + - name: Pull all Module descriptors to local Okapi instance + uses: indiesdev/curl@v1.1 + with: + url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/pull/modules" + method: "POST" + accept: 200 + timeout: 60000 + headers: | + { + "content-type": "application/json; charset=utf-8", + "accept": "application/json; charset=utf-8" + } + body: ${{ env.OKAPI_PULL }} + - name: Perform local Okapi dependency check + uses: indiesdev/curl@v1.1 + with: + url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=false&npmSnapshot=false" + method: "POST" + accept: 201 + headers: | + { + "content-type": "application/json; charset=utf-8", + "accept": "application/json; charset=utf-8" + } + body: ${{ steps.moduleDescriptor.outputs.content }} - name: Publish ModuleDescriptor to MD registry if: ${{ env.DO_PUBLISH_MD == 'true' }} id: result-md-registry From 8fa21ed92b2e319e236feeb621b3e1a31114a2c9 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 13:52:22 +1000 Subject: [PATCH 08/14] Increase timeout Okapi deps check --- .github/workflows/release-npm.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 46a38ea..a3150ee 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -130,6 +130,7 @@ jobs: url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=false&npmSnapshot=false" method: "POST" accept: 201 + timeout: 60000 headers: | { "content-type": "application/json; charset=utf-8", From 67fb60c77306f4bb0489ee35f6fde328c9b91832 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 15:14:57 +1000 Subject: [PATCH 09/14] Do separate MD pulls --- .github/workflows/release-npm.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index a3150ee..8b560d8 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -14,7 +14,8 @@ env: NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com' - OKAPI_PULL: '{ "urls" : [ "https://folio-registry.dev.folio.org", "https://registry.folio-dev.indexdata.com" ] }' + OKAPI_PULL_FOLIO: '{ "urls" : [ "https://folio-registry.dev.folio.org" ] }' + OKAPI_PULL_INDEXDATA: '{ "urls" : [ "https://registry.folio-dev.indexdata.com" ] }' COMPILE_TRANSLATION_FILES: 'true' jobs: @@ -111,7 +112,7 @@ jobs: sleep 10 - name: Docker registry logout run: docker logout https://docker.io/v2/ - - name: Pull all Module descriptors to local Okapi instance + - name: Pull FOLIO ModuleDescriptors to local Okapi uses: indiesdev/curl@v1.1 with: url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/pull/modules" @@ -123,7 +124,20 @@ jobs: "content-type": "application/json; charset=utf-8", "accept": "application/json; charset=utf-8" } - body: ${{ env.OKAPI_PULL }} + body: ${{ env.OKAPI_PULL_FOLIO }} + - name: Pull Index Data ModuleDescriptors to local Okapi + uses: indiesdev/curl@v1.1 + with: + url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/pull/modules" + method: "POST" + accept: 200 + timeout: 60000 + headers: | + { + "content-type": "application/json; charset=utf-8", + "accept": "application/json; charset=utf-8" + } + body: ${{ env.OKAPI_PULL_INDEXDATA }} - name: Perform local Okapi dependency check uses: indiesdev/curl@v1.1 with: From b2310860f059ae8ef618fb4b1f54884af24febb1 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 15:30:36 +1000 Subject: [PATCH 10/14] Do log response curl --- .github/workflows/release-npm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 8b560d8..bdc6fb8 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -119,6 +119,7 @@ jobs: method: "POST" accept: 200 timeout: 60000 + log-response: true headers: | { "content-type": "application/json; charset=utf-8", @@ -132,6 +133,7 @@ jobs: method: "POST" accept: 200 timeout: 60000 + log-response: true headers: | { "content-type": "application/json; charset=utf-8", @@ -145,6 +147,7 @@ jobs: method: "POST" accept: 201 timeout: 60000 + log-response: true headers: | { "content-type": "application/json; charset=utf-8", From a0de95bf805bad43e203265314c58dcec124133f Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 15:39:39 +1000 Subject: [PATCH 11/14] Disable log response curl --- .github/workflows/release-npm.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index bdc6fb8..8b560d8 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -119,7 +119,6 @@ jobs: method: "POST" accept: 200 timeout: 60000 - log-response: true headers: | { "content-type": "application/json; charset=utf-8", @@ -133,7 +132,6 @@ jobs: method: "POST" accept: 200 timeout: 60000 - log-response: true headers: | { "content-type": "application/json; charset=utf-8", @@ -147,7 +145,6 @@ jobs: method: "POST" accept: 201 timeout: 60000 - log-response: true headers: | { "content-type": "application/json; charset=utf-8", From 18b46931a041f9dcf5f02cafbb154f09bb3d051b Mon Sep 17 00:00:00 2001 From: David Crossley Date: Thu, 14 Jul 2022 15:48:49 +1000 Subject: [PATCH 12/14] Enable preRelease=true as mod-harvester-admin is not yet --- .github/workflows/release-npm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 8b560d8..43a0c41 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -141,7 +141,8 @@ jobs: - name: Perform local Okapi dependency check uses: indiesdev/curl@v1.1 with: - url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=false&npmSnapshot=false" + # FIXME: Using preRelease for testing. + url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=true&npmSnapshot=false" method: "POST" accept: 201 timeout: 60000 From 18d7bcd07395991682f91ce586b04b587b481007 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Mon, 18 Jul 2022 13:29:14 +1000 Subject: [PATCH 13/14] Do npm publish dry-run --- .github/workflows/release-npm.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index 43a0c41..bd18140 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -10,7 +10,6 @@ on: env: TAG_GIT: 'v0.0.1' # FIXME: Temporary for testing. Later will use actual git tag. DO_PUBLISH_MD: 'false' # FIXME: For testing. - DO_PUBLISH_NPM: 'false' # FIXME: For testing. NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com' @@ -51,7 +50,7 @@ jobs: exit 1 - name: Setup kernel for react native, increase watchers run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - - name: Use Node.js + - name: Setup NPM for install uses: actions/setup-node@v3 with: node-version: ${{ env.NODEJS_VERSION }} @@ -98,7 +97,6 @@ jobs: - name: Get the MD registry login token run: | echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV - # FIXME: Login to public NPM registry for namespace indexdata - name: Docker registry login uses: docker/login-action@v2 with: @@ -141,7 +139,7 @@ jobs: - name: Perform local Okapi dependency check uses: indiesdev/curl@v1.1 with: - # FIXME: Using preRelease for testing. + # FIXME: Using preRelease for testing, as mod-harvester-admin is not yet released. url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=true&npmSnapshot=false" method: "POST" accept: 201 @@ -152,6 +150,22 @@ jobs: "accept": "application/json; charset=utf-8" } body: ${{ steps.moduleDescriptor.outputs.content }} + - name: Setup NPM for publish + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODEJS_VERSION }} + check-latest: true + always-auth: true + registry-url: "https://registry.npmjs.org" + - name: Exclude some CI-generated artifacts in package + run: | + echo ".github" >> .npmignore + echo "artifacts" >> .npmignore + - name: Publish NPM to npmjs registry + # FIXME: Using dry-run for testing. + run: npm publish --access=public --dry-run + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NPMJS }} - name: Publish ModuleDescriptor to MD registry if: ${{ env.DO_PUBLISH_MD == 'true' }} id: result-md-registry From df8fb1e198361191f5a195636df780fa4747b740 Mon Sep 17 00:00:00 2001 From: David Crossley Date: Mon, 18 Jul 2022 14:03:02 +1000 Subject: [PATCH 14/14] Prepare for production --- .github/workflows/release-npm.yml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml index bd18140..16a562a 100644 --- a/.github/workflows/release-npm.yml +++ b/.github/workflows/release-npm.yml @@ -1,15 +1,11 @@ name: release-npm -# Status: In development. -# Is only triggered via push to branch (later will only be triggered via git tag) - on: push: - branches: [ DEVOPS-946-workflows-npm ] + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' # i.e. release tag only env: - TAG_GIT: 'v0.0.1' # FIXME: Temporary for testing. Later will use actual git tag. - DO_PUBLISH_MD: 'false' # FIXME: For testing. NODEJS_VERSION: '16' FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/' FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com' @@ -24,9 +20,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - name: Set TAG_VERSION - # FIXME: When in production, use actual git tag. - # run: echo "TAG_VERSION=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV - run: echo "TAG_VERSION=$(echo ${TAG_GIT#v})" >> $GITHUB_ENV + run: echo "TAG_VERSION=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV - name: Get version from package.json id: package_version uses: notiz-dev/github-action-json-property@release @@ -139,8 +133,7 @@ jobs: - name: Perform local Okapi dependency check uses: indiesdev/curl@v1.1 with: - # FIXME: Using preRelease for testing, as mod-harvester-admin is not yet released. - url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=true&npmSnapshot=false" + url: "http://${{ env.OKAPI_IP }}:9130/_/proxy/modules?preRelease=false&npmSnapshot=false" method: "POST" accept: 201 timeout: 60000 @@ -162,12 +155,10 @@ jobs: echo ".github" >> .npmignore echo "artifacts" >> .npmignore - name: Publish NPM to npmjs registry - # FIXME: Using dry-run for testing. - run: npm publish --access=public --dry-run + run: npm publish --access=public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_NPMJS }} - name: Publish ModuleDescriptor to MD registry - if: ${{ env.DO_PUBLISH_MD == 'true' }} id: result-md-registry uses: indiesdev/curl@v1.1 with: