Skip to content

Commit

Permalink
chore: add semantic release GH action (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
easingthemes authored Dec 13, 2024
1 parent 3242315 commit f419274
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 89 deletions.
31 changes: 31 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@ This project adheres to the Adobe [code of conduct](../CODE_OF_CONDUCT.md). By p
you are expected to uphold this code. Please report unacceptable behavior to
[[email protected]](mailto:[email protected]).

## Release
- based on Angular Commit Message Conventions in commits -
https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-header
- Commit message format is used to build:
* Release notes
* Changelog updates
* NPM package semver

## Commit message Convention

```
<type>(<scope>): <short summary>
│ │ │
│ │ └─⫸ Summary in present tense. Not capitalized. No period at the end.
│ │
│ └─⫸ Commit Scope (optional): project|based|list
└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test
```


### Major Version Release:

In order to trigger Major Version upgrade, `BREAKING CHANGE:` needs to be in the footer of a commit message:

```
<type>(<scope>): <short summary>
<BLANK LINE>
BREAKING CHANGE: <breaking change summary>
```

## Have A Question?

Start by filing an issue. The existing committers on this project work to reach
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [ '**' ]
pull_request:
branches: [ $default-branch ]

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node-version: [20.x]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
75 changes: 75 additions & 0 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Manual Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
type: choice
required: true
default: fix
options:
- fix
- feat
- BREAKING CHANGE
dryRun:
description: 'DryRun'
type: boolean
default: true
# ENV and Config
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: [email protected]
CI: true
CONFIG_NODE_VERSION: '["20.x"]'
CONFIG_OS: '["ubuntu-latest"]'
# Main Job
jobs:
config:
runs-on: ubuntu-latest
outputs:
NODE_VERSION: ${{ steps.set-config.outputs.CONFIG_NODE_VERSION }}
OS: ${{ steps.set-config.outputs.CONFIG_OS }}
steps:
- id: set-config
run: |
echo "CONFIG_NODE_VERSION=${{ toJSON(env.CONFIG_NODE_VERSION) }}" >> $GITHUB_OUTPUT
echo "CONFIG_OS=${{ toJSON(env.CONFIG_OS) }}" >> $GITHUB_OUTPUT
release:
name: Test, Build and force Release
needs: config

runs-on: ${{ matrix.OS }}
strategy:
matrix:
OS: ${{ fromJSON(needs.config.outputs.OS) }}
NODE_VERSION: ${{ fromJSON(needs.config.outputs.NODE_VERSION) }}

steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.NODE_VERSION }}
- name: Commit trigger
run: |
git commit --allow-empty -m "${{ github.event.inputs.version }}: Trigger Manual Release
${{ github.event.inputs.version }}:Forced Manual Release without code changes"
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
- name: Publish npm package
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
27 changes: 0 additions & 27 deletions .github/workflows/nodejs.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/on-push-publish-to-npm.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Test, Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 20.x ]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix['node-version'] }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
- name: Release
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: [email protected]
CI: true
42 changes: 0 additions & 42 deletions .github/workflows/version-bump-publish.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": ["docs/CHANGELOG.md", "package.json"]
}
]
]
}
Empty file added docs/CHANGELOG.md
Empty file.

0 comments on commit f419274

Please sign in to comment.