From b0c5bbb8e7440dcc99c3395de86606cdb4ce9874 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Wed, 10 Jan 2024 10:35:02 +0100 Subject: [PATCH 1/4] chore: add missing exports for NPM package generation --- libs/ui/catalog/src/index.ts | 1 + libs/ui/elements/src/index.ts | 1 + libs/ui/inputs/src/index.ts | 3 +++ 3 files changed, 5 insertions(+) diff --git a/libs/ui/catalog/src/index.ts b/libs/ui/catalog/src/index.ts index 3cebead339..6e32ac7e87 100644 --- a/libs/ui/catalog/src/index.ts +++ b/libs/ui/catalog/src/index.ts @@ -3,3 +3,4 @@ export * from './lib/catalog-title/catalog-title.component' export * from './lib/language-switcher/language-switcher.component' export * from './lib/organisation-preview/organisation-preview.component' export * from './lib/organisations-filter/organisations-filter.component' +export * from './lib/organisations-result/organisations-result.component' diff --git a/libs/ui/elements/src/index.ts b/libs/ui/elements/src/index.ts index a94569feb5..61cb50dd29 100644 --- a/libs/ui/elements/src/index.ts +++ b/libs/ui/elements/src/index.ts @@ -18,3 +18,4 @@ export * from './lib/pagination/pagination.component' export * from './lib/related-record-card/related-record-card.component' export * from './lib/search-results-error/search-results-error.component' export * from './lib/user-preview/user-preview.component' +export * from './lib/record-api-form/record-api-form.component' diff --git a/libs/ui/inputs/src/index.ts b/libs/ui/inputs/src/index.ts index 9c6351d75c..4bda2ddfb1 100644 --- a/libs/ui/inputs/src/index.ts +++ b/libs/ui/inputs/src/index.ts @@ -16,3 +16,6 @@ export * from './lib/copy-text-button/copy-text-button.component' export * from './lib/drag-and-drop-file-input/drag-and-drop-file-input.component' export * from './lib/navigation-button/navigation-button.component' export * from './lib/viewport-intersector/viewport-intersector.component' +export * from './lib/checkbox/checkbox.component' +export * from './lib/search-input/search-input.component' +export * from './lib/date-range-picker/date-range-picker.component' From 2c215e8753498af9c12349b4620e6525b1a02648 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Wed, 10 Jan 2024 10:47:51 +0100 Subject: [PATCH 2/4] ci: add a build of the npm package in PR checks --- .github/workflows/checks.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c4e0dd39e4..4ebeaa5ed0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -166,3 +166,28 @@ jobs: - name: Run tests run: npx nx run-many --target=e2e + + build-npm-package: + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' + name: Attempt to build the NPM package + runs-on: ubuntu-latest + + steps: + - name: Checkout branch + uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build NPM package + working-directory: package + run: node generate-package.js From 6433178c18e5fb58935890d5b06c22e8d24d8916 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Wed, 10 Jan 2024 11:29:53 +0100 Subject: [PATCH 3/4] feat(tools): add a script to print a dev version --- tools/print-dev-version.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 tools/print-dev-version.sh diff --git a/tools/print-dev-version.sh b/tools/print-dev-version.sh new file mode 100755 index 0000000000..ee9e598aee --- /dev/null +++ b/tools/print-dev-version.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Will print a version tag taking into account the current project version and whether it's a dev version +# on main branch: 1.0.0-dev.1234abcd (commit tag) +# on feature branch: 1.0.0-dev.branch-name +# on git tag: 1.0.0 (git tag) + +npmVersion=$(node --print 'require("../package.json").version') +gitTag=$(git describe --exact-match --tags 2>/dev/null | sed "s/^v//") # remove "v" in front of version if any +gitBranch=$(git symbolic-ref --short HEAD) +gitRef=$(git rev-parse --short HEAD) + +# git tag defined +if [ -n "${gitTag}" ]; then + echo ${gitTag} + exit 0 +fi + +# main branch +if [ ${gitBranch} == "main" ]; then + echo "${npmVersion}.${gitRef}" + exit 0 +fi + +echo "${npmVersion}.${gitBranch}" From d433250ee93ee4c48a4151ee3592bb286ae01879 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Wed, 10 Jan 2024 11:30:37 +0100 Subject: [PATCH 4/4] ci: add npm package build on each commit on main & releases --- .github/workflows/artifacts.yml | 47 ++++++++++++++++++++++++++++++++- tools/print-dev-version.sh | 2 +- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index c757b9b54e..2e6c8f2c17 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -39,7 +39,7 @@ jobs: build-archive-docker: needs: checks if: github.event_name != 'issue_comment' || needs.checks.outputs.shouldRun - name: Build docker images and archives + name: Build and upload docker images and archives runs-on: ubuntu-latest steps: @@ -108,3 +108,48 @@ jobs: run: | docker image ls --format '{{.Repository}}:{{.Tag}}' --filter=reference='geonetwork/*' | \ xargs -r -L1 docker push $1 + + build-npm-package: + if: github.event_name != 'issue_comment' + name: Build and publish NPM package + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ needs.checks.outputs.ref }} # use the PR head ref if applicable; otherwise keep default behaviour + persist-credentials: false + fetch-depth: 0 + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Adjust package version according to branch & commit + working-directory: package + run: npm version $(../tools/print-dev-version.sh) --no-git-tag-version + + - name: Build NPM package + working-directory: package + run: node generate-package.js + + - name: Publish NPM package with @dev tag + if: github.event_name != 'release' + working-directory: package/dist + run: npm publish --tag dev + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish NPM package + if: github.event_name == 'release' + working-directory: package/dist + run: npm publish --tag latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/tools/print-dev-version.sh b/tools/print-dev-version.sh index ee9e598aee..46ec3d22e0 100755 --- a/tools/print-dev-version.sh +++ b/tools/print-dev-version.sh @@ -17,7 +17,7 @@ if [ -n "${gitTag}" ]; then fi # main branch -if [ ${gitBranch} == "main" ]; then +if [ "${gitBranch}" == "main" ]; then echo "${npmVersion}.${gitRef}" exit 0 fi