Skip to content

Commit

Permalink
Merge pull request #2276 from prince-deriv/trigger-publish-workflow
Browse files Browse the repository at this point in the history
chore: trigger workflow
  • Loading branch information
prince-deriv authored Dec 16, 2024
2 parents a56343c + b33fbea commit 1fad000
Show file tree
Hide file tree
Showing 6 changed files with 595 additions and 28 deletions.
31 changes: 4 additions & 27 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,18 @@ jobs:
node-version: '20'


- name: Check changes in marketing-scripts
id: marketing-changes
run: |
if git diff --quiet HEAD^ HEAD -- public/scripts/marketing-scripts/src/; then
echo "changed=false" >> $GITHUB_ENV
else
echo "changed=true" >> $GITHUB_ENV
fi
continue-on-error: true


- name: Check changes in cs-scripts
id: cs-changes
run: |
if git diff --quiet HEAD^ HEAD -- public/scripts/cs-scripts/src/; then
echo "changed=false" >> $GITHUB_ENV
else
echo "changed=true" >> $GITHUB_ENV
fi
continue-on-error: true


- name: Install dependencies and build marketing-scripts
if: ${{ env.changed == 'true' && steps.marketing-changes.outputs.changed == 'true' }}
- name: Install dependencies, build and publish marketing-scripts
working-directory: public/scripts/marketing-scripts
run: |
npm install
npm run build
npx semantic-release
- name: Install dependencies and build cs-scripts
if: ${{ env.changed == 'true' && steps.cs-changes.outputs.changed == 'true' }}
- name: Install dependencies, build and publish cs-scripts
working-directory: public/scripts/cs-scripts
run: |
npm install
npm run build
npx semantic-release
77 changes: 77 additions & 0 deletions public/scripts/packages/cs/release.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const transform = require("./release.utils.cjs");

module.exports = {
branches: [
"+([0-9])?(.{+([0-9]),x}).x",
"master",
"next",
"next-major",
{ name: "beta", prerelease: true },
{ name: "alpha", prerelease: true },
],
repositoryUrl: "git@github.com:deriv-com/cs-scripts.git",
plugins: [
[
"@semantic-release/commit-analyzer",
{
releaseRules: [
{
type: "feat",
release: "minor",
},
{
type: "build",
release: "patch",
},
{
type: "ci",
release: "patch",
},
{
type: "chore",
release: "patch",
},
{
type: "docs",
release: "patch",
},
{
type: "refactor",
release: "patch",
},
{
type: "style",
release: "patch",
},
{
type: "test",
release: "patch",
},
{
type: "fix",
release: "patch",
},
],
},
],
[
"@semantic-release/release-notes-generator",
{
parserOpts: {
mergePattern: /^Merge pull request #(\d+) from (.*)$/,
mergeCorrespondence: ["id", "source"],
},
writerOpts: { transform: transform },
},
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
npmPublish: true,
},
],
"@semantic-release/github",
],
};
218 changes: 218 additions & 0 deletions public/scripts/packages/cs/release.utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
const types = {
maxSubjectLength: 72,
bodyLineLength: 100,
typesOrder: [
"feat",
"fix",
"perf",
"build",
"refactor",
"docs",
"test",
"ci",
"chore",
"style",
"revert",
"initial",
"dependencies",
"peerDependencies",
"devDependencies",
"metadata",
],
types: {
feat: {
description: "A new feature",
title: "Features",
emoji: "✨",
changelog: true,
release: "minor",
aliases: {
initial: {
description: "Initial commit",
title: "Initial",
emoji: "🎉",
},
},
},
fix: {
description: "A bug fix",
title: "Bug Fixes",
emoji: "🐛",
changelog: true,
release: "patch",
aliases: {
dependencies: {
description: "Update dependency",
title: "Dependencies",
emoji: "⬆️",
scope: "package",
},
peerDependencies: {
description: "Update peer dependency",
title: "Peer dependencies",
emoji: "⬆️",
scope: "package",
},
metadata: {
description: "Update metadata (package.json)",
title: "Metadata",
emoji: "📦",
scope: "package",
},
},
},
docs: {
description: "Documentation only changes",
title: "Documentation",
emoji: "📚",
changelog: true,
release: { scope: "readme", release: "patch" },
},
style: {
description:
"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
title: "Styles",
emoji: "💎",
changelog: true,
release: false,
},
refactor: {
description:
"A code change that neither fixes a bug nor adds a feature",
title: "Code Refactoring",
emoji: "📦",
changelog: true,
release: false,
},
perf: {
description: "A code change that improves performance",
title: "Performance Improvements",
emoji: "🚀",
changelog: true,
release: "patch",
},
test: {
description: "Adding missing tests or correcting existing tests",
title: "Tests",
emoji: "🚨",
changelog: true,
release: false,
},
build: {
description:
"Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
title: "Builds",
emoji: "🛠",
changelog: true,
release: "patch",
},
ci: {
description:
"Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
title: "Continuous Integrations",
emoji: "⚙️",
changelog: true,
release: false,
},
chore: {
description: "Other changes that don't modify src or test files",
title: "Chores",
emoji: "♻️",
changelog: true,
release: false,
aliases: {
devDependencies: {
description: "Update dev dependencies",
title: "Dev dependencies",
emoji: "⬆️",
scope: "package",
},
},
},
revert: {
description: "Reverts a previous commit",
title: "Reverts",
emoji: "🗑",
changelog: true,
release: false,
},
},
};

const COMMIT_HASH_LENGTH = 7;

/**
* Transform a parsed commit to render the changelog.
*
* @param {Object} commit commit parsed with `conventional-changelog-parser`.
* @param {Object} context `conventional-changelog` context.
* @return {Object} the transformed commit.
*/
const customTransform = (commit, context) => {
const commitObject = {}
if (commitObject.notes) {
commit.notes.forEach((note, index) => {
commitObject.notes[index].note.title = "Breaking changes";
});
}

if (
types.types[commit.type] &&
(types.types[commit.type].changelog ||
(commit.notes && commit.notes.length > 0))
) {
commitObject.type = `${
types.types[commit.type].emoji ? types.types[commit.type].emoji : ""
} \t ${types.types[commit.type].title}`;
} else {
return null;
}

if (commit.scope === "*") {
commitObject.scope = "";
}

if (typeof commit.hash === "string") {
commitObject.shortHash = commit.hash.slice(0, COMMIT_HASH_LENGTH);
}

const references = [];

if (typeof commit.subject === "string") {
let url = context.repository
? `${context.host}/${context.owner}/${context.repository}`
: context.repoUrl;

if (url) {
url += "/issues/";
// Issue URLs.
commitObject.subject = commit.subject.replace(/#(\d+)/g, (_, issue) => {
references.push(issue);
return `[#${issue}](${url}${issue})`;
});
}

if (context.host) {
// User URLs.
commitObject.subject = commit.subject.replace(
/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g,
`[@$1](${context.host}/$1)`,
);
}
}

if (commit.references) {
// Remove references that already appear in the subject
commitObject.references = commit.references.filter((reference) => {
if (!references.includes(reference.issue)) {
return true;
}

return false;
});
}

return commitObject;
};

module.exports = customTransform;
Loading

0 comments on commit 1fad000

Please sign in to comment.