Skip to content

Commit

Permalink
fix: pipeline improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
elribonazo committed Sep 16, 2024
1 parent 559f191 commit 95f7b0b
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 59 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
33 changes: 25 additions & 8 deletions ts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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ó <elribonazo@gmail.com> 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ó <elribonazo@gmail.com> 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ó <elribonazo@gmail.com> 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))
150 changes: 148 additions & 2 deletions ts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions ts/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
35 changes: 16 additions & 19 deletions ts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 7 additions & 13 deletions ts/.releaserc.js → ts/release.config.js
Original file line number Diff line number Diff line change
@@ -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',
{
Expand All @@ -26,7 +21,6 @@ module.exports = {
'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
['@semantic-release/exec', { "prepareCmd": './publish.sh ${nextRelease.version}' }],

],
};
Loading

0 comments on commit 95f7b0b

Please sign in to comment.