Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: PRSDM-5464 setup semantic release #127

Merged
merged 19 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- PRS-123: Short description of change -->

## Description
<!-- A longer description of the change -->

## Issue
- [ ] :clipboard: JIRA_TICKET_URL

## Screenshots
<!-- If relevant -->

## PR Readiness Checks
- [ ] Your PR title conforms to conventional commits `<type>: <jira-ticket-num><title>`, for example: `fix: PRSDM-123 issue with login` with a maximum of 100 characters
- [ ] You have performed a self-review of your changes via the GitHub UI
- [ ] Comments were added to new code that can not explain itself (see [reference 1](https://bpoplauschi.github.io/2021/01/20/Clean-Code-Comments-by-Uncle-Bob-part-2.html) and [reference 2](https://blog.cleancoder.com/uncle-bob/2017/02/23/NecessaryComments.html))
- [ ] New code adheres to the following quality standards:
- Function Length ([see reference](https://martinfowler.com/bliki/FunctionLength.html))
- Meaningful Names ([see reference](https://learning.oreilly.com/library/view/clean-code-a/9780136083238/chapter02.xhtml))
- DRY ([see reference](https://java-design-patterns.com/principles/#keep-things-dry))
- YAGNI ([see reference](https://java-design-patterns.com/principles/#yagni))
- [ ] Tests were added to prove the correctness and ensure extendability of the functionality added (unless agreed upon by the reviewers that it's not necessary) and the changes were tested locally
31 changes: 31 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: build-and-release
on:
push:
branches:
- develop
- main
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: npm

- name: Install Dependencies
run: npm ci

- name: Build Project
run: npm run build

- name: Semantic Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.ref_name }}
run: npx semantic-release

21 changes: 21 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
permissions:
pull-requests: read
contents: read
packages: read
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

18 changes: 0 additions & 18 deletions GitVersion.yml

This file was deleted.

5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
commitlint:
npm install
npm install -g commitizen
mkdir .husky
echo "npx --no -- commitlint --edit \$$1" > .husky/commit-msg
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,83 @@ $ npm run start
```bash
$ mocha --compilers js:babel-core/register --recursive test/
```

---

## Conventional Commits

At SPAN we use [Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/) to make our commit messages more useful.

### Installation

To install the dependencies for the conventional commits, please use:
```bash
make commitlint
```

### Usage

After installation you can use `git cz` and run through the options and it will build your commit message. For example:

```
? Select the type of change that you're committing: refactor: A code change that neither fixes a bug nor adds a feature (formatting, performance improvement, etc)
? Enter JIRA issue (AK-12345) (optional): PRSDM-5026
? What is the scope of this change (e.g. component or file name): (press enter to skip)
? Write a short, imperative tense description of the change:
[------------------------------------------------------------------------] 51 chars left
refactor: PRSDM-5026 update makefile and readme
? Provide a longer description of the change: (press enter to skip)

? Are there any breaking changes? No
? Does this change affect any open issues? No
```

> **Important!** Any use of `breaking changes` needs to be confirmed with the team as this increments the major version number.

### Commitizen

[Commitizen](http://commitizen.github.io/cz-cli/) is a CLI tool that prompts you to fill in the required commit fields at commit time.
After the setup, you should be able to use `git cz` to build your commit messages.

[Commitizen Jira Smart Commit Plugin](https://github.com/anastariqkhan/cz-conventional-changelog-jira-smart-commits) expands to traditional
commitizen prompt to also prompts for a Jira issue and how you would like update the Jira issue.

### Conventional Commit Intellij Plugin

If you use Intellij IDEA as your IDE, you could install the [Conventional Commit Plugin](https://plugins.jetbrains.com/plugin/13389-conventional-commit), and then
you can build your conventional commit messages directly in the IDE.

### Commit Linting

[Commitlint](https://commitlint.js.org/#/) is used for linting the commit messages on the CI pipeline to ensure that all commit messages adhere to the Conventional Commits 1.0.0 specification.

[Husky](https://typicode.github.io/husky/) is used for a [commit hook](https://commitlint.js.org/guides/local-setup.html#using-a-git-hooks-manager).

---

## Semantic Releases

This repository uses [Semantic Release](https://semantic-release.gitbook.io/semantic-release/) tool to automate version management and package publishing.

Upon merging into to the main or develop branch, Semantic Release tool will:
- Calculate the new release version based on the commits
- Generate the CHANGELOG file
- Update the VERSION file
- Create a git commit and a git tag for the release
- Create a Release on Github

---

## Branching

Please see this [Presidium Git Strategy Miro board](https://miro.com/app/board/uXjVPK0XxiU=/).

In summary:
- `main` -> production
- Only hotfixes or `develop` get merged into `main`
- `develop`
- Feature branches and bugfixes are branched from and merged into `develop`
- `feat: <TITLE>`
- If there is a feature in development it will be on a feature branch

---
51 changes: 0 additions & 51 deletions build/github_release.sh

This file was deleted.

49 changes: 0 additions & 49 deletions build/include.sh

This file was deleted.

42 changes: 0 additions & 42 deletions build/tag_code.sh

This file was deleted.

Loading