From 95f7b0bb954a19f8a09226b8eeaa41b1a897580f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Ribo=CC=81?= Date: Mon, 16 Sep 2024 17:54:16 +0200 Subject: [PATCH] fix: pipeline improvement --- .github/workflows/release.yml | 18 +-- ts/CHANGELOG.md | 33 ++++-- ts/package-lock.json | 150 +++++++++++++++++++++++- ts/package.json | 9 +- ts/publish.sh | 35 +++--- ts/{.releaserc.js => release.config.js} | 20 ++-- ts/tests/schemas.test.ts | 1 + 7 files changed, 207 insertions(+), 59 deletions(-) rename ts/{.releaserc.js => release.config.js} (50%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b39db16..e3237b0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,15 +7,6 @@ permissions: on: workflow_dispatch: inputs: - branch: - description: 'Select the branch to release from' - required: true - default: 'main' - type: choice - options: - - main - - develop - # Add more branches if necessary rc: description: 'Publish as a release candidate (RC)?' required: true @@ -30,7 +21,7 @@ jobs: working-directory: ./ts # Set default working directory to ./ts steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.branch }} token: ${{ secrets.GH_TOKEN }} @@ -39,10 +30,11 @@ jobs: # Removed the redundant 'Change directory' step - name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '20' registry-url: 'https://registry.npmjs.org/' + scope: '@elribonazo' cache: 'npm' cache-dependency-path: ./ts/package-lock.json # Specify the correct path @@ -56,7 +48,7 @@ jobs: run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Install dependencies - run: npm ci + run: npm ci && chmod +x publish.sh - name: Build the project run: npm run build @@ -69,7 +61,7 @@ jobs: - name: Run semantic-release env: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - RELEASE_BRANCH: ${{ github.event.inputs.branch }} RC: ${{ github.event.inputs.rc }} run: npx semantic-release diff --git a/ts/CHANGELOG.md b/ts/CHANGELOG.md index 60246e0..7acc7b2 100644 --- a/ts/CHANGELOG.md +++ b/ts/CHANGELOG.md @@ -1,16 +1,33 @@ +## [0.0.1-rc.1](https://github.com/atala-community-projects/RIDB/compare/v0.0.0...v0.0.1-rc.1) (2024-09-16) + + +### Bug Fixes + +* ci setting correct tag ([0501bff](https://github.com/atala-community-projects/RIDB/commit/0501bff8c036b47d8c2d12e0d8e640c9d796c359)) +* find, update, findOne, create and delete 83fadb1 Javier Ribó 15 sept 2024, 16:32 ([559f191](https://github.com/atala-community-projects/RIDB/commit/559f19146c3ce71314a278e8ad74ad327f0f377a)) +* pipeline ([523bfd3](https://github.com/atala-community-projects/RIDB/commit/523bfd32e85be83aa158c9f6828cf4e6c6e4edbe)) +* release ([7765d1f](https://github.com/atala-community-projects/RIDB/commit/7765d1ff88c07936f0eb36d2945259aee282f04f)) +* release ([84c3784](https://github.com/atala-community-projects/RIDB/commit/84c3784dd8bd683af6f0153a7c4e7e2ef17663e1)) +* release pipeline ([3c427e9](https://github.com/atala-community-projects/RIDB/commit/3c427e9670590faa7a8a452c2f20de3e4af7556d)) +* release pipeline ([67cc617](https://github.com/atala-community-projects/RIDB/commit/67cc617cd3a159b93ea0bd3640bebc8cab8008f3)) +* release pipeline ([c0021d9](https://github.com/atala-community-projects/RIDB/commit/c0021d9bda045f9cd6052fb05713cb5fe7e4dcab)) +* release pipeline ([be7dbdf](https://github.com/atala-community-projects/RIDB/commit/be7dbdf29dbb7f838f5a08c307446ad2cce14555)) + # 1.0.0 (2024-09-15) ### Bug Fixes -* release pipeline ([8e7b2d8](https://github.com/atala-community-projects/RIDB/commit/8e7b2d80b3ec23cbbfa8be3a9ccbaaec96d101ad)) -* release pipeline ([11d31ed](https://github.com/atala-community-projects/RIDB/commit/11d31edfb52f124dae7bf0bb367491ef25690e51)) -* release pipeline ([34a9649](https://github.com/atala-community-projects/RIDB/commit/34a9649a6deca1f987d6bad15415ffa4d0feaed0)) -* release pipeline ([fa88fb1](https://github.com/atala-community-projects/RIDB/commit/fa88fb1fe5184fbd7332048b95f0a91b9a38009b)) -* release pipeline ([5a840eb](https://github.com/atala-community-projects/RIDB/commit/5a840ebb2d87d87f9d55a92bfb534fa1a7b49590)) -* repo url ([d2bf585](https://github.com/atala-community-projects/RIDB/commit/d2bf585825b389e80b71adeb0233a664b9974add)) +* find, update, findOne, create and delete 83fadb1 Javier Ribó 15 sept 2024, 16:32 ([559f191](https://github.com/atala-community-projects/RIDB/commit/559f19146c3ce71314a278e8ad74ad327f0f377a)) +* release pipeline ([22b8690](https://github.com/atala-community-projects/RIDB/commit/22b8690dcd9cbd7d0b2d5426e6b712eb8aa802d6)) +* release pipeline ([d0fe911](https://github.com/atala-community-projects/RIDB/commit/d0fe911fdc7611ce5a50574e2a16320db6dcc4fa)) +* release pipeline ([c8ab868](https://github.com/atala-community-projects/RIDB/commit/c8ab86845d81aa0fc7c01473a6d8f473922d1e0f)) + +# 1.0.0 (2024-09-15) -### Features +### Bug Fixes -* find, update, findOne, create and delete ([83fadb1](https://github.com/atala-community-projects/RIDB/commit/83fadb18338bd818c9c850bfed823ed08587810c)) +* find, update, findOne, create and delete 83fadb1 Javier Ribó 15 sept 2024, 16:32 ([559f191](https://github.com/atala-community-projects/RIDB/commit/559f19146c3ce71314a278e8ad74ad327f0f377a)) +* release pipeline ([d0fe911](https://github.com/atala-community-projects/RIDB/commit/d0fe911fdc7611ce5a50574e2a16320db6dcc4fa)) +* release pipeline ([c8ab868](https://github.com/atala-community-projects/RIDB/commit/c8ab86845d81aa0fc7c01473a6d8f473922d1e0f)) diff --git a/ts/package-lock.json b/ts/package-lock.json index a152604..be1d75e 100644 --- a/ts/package-lock.json +++ b/ts/package-lock.json @@ -1,12 +1,12 @@ { "name": "@elribonazo/ridb", - "version": "1.0.0", + "version": "0.0.1-rc.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@elribonazo/ridb", - "version": "1.0.0", + "version": "0.0.1-rc.1", "license": "Apache-2.0", "dependencies": { "chromedriver": "^128.0.3" @@ -15,6 +15,7 @@ "@esbuild-plugins/node-resolve": "^0.2.2", "@semantic-release/changelog": "^6.0.3", "@semantic-release/commit-analyzer": "^13.0.0", + "@semantic-release/exec": "^6.0.3", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^10.3.3", "@semantic-release/npm": "^12.0.1", @@ -1478,6 +1479,151 @@ "node": ">=14.17" } }, + "node_modules/@semantic-release/exec": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-6.0.3.tgz", + "integrity": "sha512-bxAq8vLOw76aV89vxxICecEa8jfaWwYITw6X74zzlO0mc/Bgieqx9kBRz9z96pHectiTAtsCwsQcUyLYWnp3VQ==", + "dev": true, + "dependencies": { + "@semantic-release/error": "^3.0.0", + "aggregate-error": "^3.0.0", + "debug": "^4.0.0", + "execa": "^5.0.0", + "lodash": "^4.17.4", + "parse-json": "^5.0.0" + }, + "engines": { + "node": ">=14.17" + }, + "peerDependencies": { + "semantic-release": ">=18.0.0" + } + }, + "node_modules/@semantic-release/exec/node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/@semantic-release/exec/node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@semantic-release/exec/node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/@semantic-release/exec/node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@semantic-release/exec/node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@semantic-release/exec/node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@semantic-release/exec/node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@semantic-release/exec/node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@semantic-release/exec/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/@semantic-release/exec/node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@semantic-release/git": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/@semantic-release/git/-/git-10.0.1.tgz", diff --git a/ts/package.json b/ts/package.json index 89b5b2a..a17d5cd 100644 --- a/ts/package.json +++ b/ts/package.json @@ -1,6 +1,6 @@ { "name": "@elribonazo/ridb", - "version": "0.0.0", + "version": "0.0.1-rc.1", "description": "RIDB ES Module", "main": "./build/cjs/index.cjs", "module": "./build/esm/index.mjs", @@ -35,14 +35,14 @@ "postpublish": "rm ./README.MD" }, "devDependencies": { - "semantic-release": "^24.1.1", + "@esbuild-plugins/node-resolve": "^0.2.2", "@semantic-release/changelog": "^6.0.3", + "@semantic-release/commit-analyzer": "^13.0.0", + "@semantic-release/exec": "^6.0.3", "@semantic-release/git": "^10.0.1", "@semantic-release/github": "^10.3.3", "@semantic-release/npm": "^12.0.1", - "@semantic-release/commit-analyzer": "^13.0.0", "@semantic-release/release-notes-generator": "^14.0.1", - "@esbuild-plugins/node-resolve": "^0.2.2", "@types/node": "^20.14.2", "@vitest/browser": "^1.6.0", "@vitest/coverage-istanbul": "^1.6.0", @@ -51,6 +51,7 @@ "esbuild-plugin-wasm": "^1.1.0", "esbuild-plugin-wasm-pack": "^1.1.0", "jsdom": "^24.1.0", + "semantic-release": "^24.1.1", "ts-node": "^10.9.2", "typedoc": "^0.26.1", "typedoc-plugin-external-module-map": "^2.0.1", diff --git a/ts/publish.sh b/ts/publish.sh index 482986a..d417f76 100644 --- a/ts/publish.sh +++ b/ts/publish.sh @@ -2,35 +2,32 @@ set -e -if [ -z "$1" ]; then - echo "Error: Missing release_version parameter. Please check what happened." +release_version="$1" +release_channel="$2" + +if [ -z "$release_version" ]; then + echo "Error: Missing release_version parameter." exit 1 fi -release_version="$1" - -# Determine the publish tag based on the RC environment variable -if [ -z "$RC" ]; then - publish_tag="latest" -else +# Determine the publish tag based on the release channel +if [ "$release_channel" == "rc" ]; then publish_tag="rc" +else + publish_tag="latest" fi -echo "Publishing with tag: $publish_tag" +echo "Publishing version: $release_version with tag: $publish_tag" -# Updates the version to the release -npm version "$release_version" --git-tag-version false +# Update the version in package.json without creating a git tag +npm version "$release_version" -# Generates the build +# Generate the build npm run build -# Gets the published versions in the registry -version_list=$(npm view @elribonazo/ridb versions) -published_versions=${version_list//[\[\]]/} - -# Checks if it's been already published to npmjs -if [[ ${published_versions[@]} =~ "'$release_version'" ]]; then - echo "$release_version is already published. Skipping publication." +# Check if the version is already published +if npm view "@elribonazo/ridb@$release_version" > /dev/null 2>&1; then + echo "Version $release_version is already published. Skipping publication." else npm publish --access public --tag "$publish_tag" fi diff --git a/ts/.releaserc.js b/ts/release.config.js similarity index 50% rename from ts/.releaserc.js rename to ts/release.config.js index 6ecf17f..99843ad 100644 --- a/ts/.releaserc.js +++ b/ts/release.config.js @@ -1,23 +1,18 @@ -// At the top of your release.config.js -const setRcPrerelease = { - prepare: async (pluginConfig, context) => { - if (process.env.RC === 'true') { - context.nextRelease.version += '-rc.' + context.nextRelease.gitTag.split('.').pop(); - context.nextRelease.channel = 'rc'; - context.nextRelease.type = 'prerelease'; - } - }, -}; + module.exports = { repositoryUrl: 'https://github.com/atala-community-projects/RIDB.git', - branches: ['main', 'develop', { name: 'release/*' }], + branches: [ + { name: 'rc/*', prerelease: 'rc', channel: 'rc' }, + { name: "main" }, + 'v+([0-9])?(.{+([0-9]),x}).x', + ], plugins: [ '@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', - setRcPrerelease, // Add the custom plugin here '@semantic-release/github', '@semantic-release/changelog', + '@semantic-release/npm', [ '@semantic-release/git', { @@ -26,7 +21,6 @@ module.exports = { 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}', }, ], - ['@semantic-release/exec', { "prepareCmd": './publish.sh ${nextRelease.version}' }], ], }; diff --git a/ts/tests/schemas.test.ts b/ts/tests/schemas.test.ts index 0304dfc..db37884 100644 --- a/ts/tests/schemas.test.ts +++ b/ts/tests/schemas.test.ts @@ -71,6 +71,7 @@ describe(`[${platform}] Testing`, () => { } } ) + await db.start(storage); expect(db).to.not.be.undefined;