Skip to content

Commit

Permalink
Merge pull request #13 from stanleyzapata/add-release-workflow
Browse files Browse the repository at this point in the history
Adds Release Workflow
  • Loading branch information
cesarParra authored Nov 21, 2024
2 parents cc7ce48 + 0420f27 commit 7dbdeed
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Semantic Release

on:
push:
branches:
- main
workflow_dispatch:
inputs:
dry_run:
description: "Run in dry mode"
required: false
default: "true"

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"

- name: Install Dependencies
run: npm ci

- name: Set Dry Run Mode
id: dry_run_mode
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ "${{ inputs.dry_run }}" != "" ]; then
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_OUTPUT
else
echo "dry_run=false" >> $GITHUB_OUTPUT
fi
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: ${{ steps.dry_run_mode.outputs.dry_run }}
extra_plugins: |
@semantic-release/exec
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ A simple yet powerful reactive state management solution for Lightning Web Compo
---

![GitHub Workflow Status](https://github.com/cesarParra/lwc-signals/actions/workflows/ci.yml/badge.svg)
![Version](https://img.shields.io/badge/version-1.0.0-blue)

Inspired by the Signals technology behind SolidJs, Preact, Svelte 5 Runes and the Vue 3 Composition API, LWC Signals is
a
Expand Down
92 changes: 92 additions & 0 deletions release.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* @type {import('semantic-release').GlobalConfig}
*/
export default {
branches: [
"main"
],
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
releaseRules: [
{ type: "feat", release: "minor" },
{ type: "refactor", scope: "major-change", release: "minor" },
{ type: "fix", release: "patch" },
{ type: "perf", release: "patch" },
{ type: "refactor", release: "patch" },
{ type: "style", release: "patch" },
{ type: "revert", release: "patch" },
{ type: "release", release: "major" },
{ breaking: true, release: "major" },
{ type: "build", release: false },
{ type: "chore", release: false },
{ type: "ci", release: false },
{ type: "docs", release: false },
{ scope: "no-release", release: false },
{ type: "test", release: false }
]
}
],
[
"@semantic-release/release-notes-generator",
{
preset: "conventionalcommits",
presetConfig: {
types: [
{ type: "feat", section: "✨ Features", hidden: false },
{ type: "fix", section: "🐞 Bug Fixes", hidden: false },
{ type: "docs", section: "📚 Documentation Updates", hidden: false },
{ type: "style", section: "🎨 Style Changes", hidden: false },
{ type: "refactor", section: "🔨 Code Refactoring", hidden: false },
{ type: "chore", section: "🛠️ Chores", hidden: false },
{ type: "perf", section: "⚡ Performance Improvements", hidden: false },
{ type: "test", section: "✅ Tests", hidden: true },
{ type: "build", section: "🏗️ Build Changes", hidden: true },
{ type: "ci", section: "🤖 Continuous Integration", hidden: false },
{ type: "revert", section: "⏪ Reverts", hidden: false }
]
},
parserOpts: {
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
},
writerOpts: {
headerPartial: "### 🚀 Release Notes\n\n**Version**: {{version}}\n**Date**: {{date}}\n"
}
}
],
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md"
}
],
[
"@semantic-release/npm",
{
npmPublish: false
}
],
[
"@semantic-release/exec",
{
prepareCmd: "node scripts/update-badge.js ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
assets: [
"sfdx-project.json",
"README.md",
"CHANGELOG.md",
"package.json",
"package-lock.json"
],
message: "chore(release): Version ${nextRelease.version} - Automated release [skip ci]\n\nSee the release details: ${nextRelease.gitTag}"
}
],
"@semantic-release/github"
]
};
20 changes: 20 additions & 0 deletions scripts/update-badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require("fs");

const filePath = "README.md";
const version = process.argv[2]; // Read the version from the command-line arguments

if (!version) {
console.error("No version provided to update badge.");
process.exit(1);
}

let content = fs.readFileSync(filePath, "utf8");

// Replace the version badge placeholder
content = content.replace(
/!\[Version\]\(https:\/\/img\.shields\.io\/badge\/version-.*?-blue\)/,
`![Version](https://img.shields.io/badge/version-${version}-blue)`
);

fs.writeFileSync(filePath, content);
console.log(`Updated version badge to ${version} in ${filePath}`);

0 comments on commit 7dbdeed

Please sign in to comment.