Skip to content

Commit

Permalink
feat: add automated release (#12)
Browse files Browse the repository at this point in the history
* feat: add semantic-release

* feat: add release and package workflows
  • Loading branch information
rpidanny authored Jul 11, 2024
1 parent 1b08689 commit ffe2417
Show file tree
Hide file tree
Showing 12 changed files with 25,747 additions and 13,437 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local_tests
21 changes: 14 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
branches:
- '*'


jobs:
build:
Expand All @@ -22,7 +22,14 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Build
run: |
npm ci
npm run build:dev
- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Build Dev
run: npm run build:dev

- name: Build Prod
run: npm run build
43 changes: 43 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Package

on:
# release:
# types: [published]
# support manual release in case something goes wrong and needs to be repeated or tested
workflow_dispatch:
inputs:
tag:
description: tag that needs to publish
type: string
required: true

env:
NODE_VERSION: 18

jobs:
pack:
name: Package Extension
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
cache: 'npm'

- name: NPM Install
run: npm ci

- run: npm run build

- name: Attach artifacts to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: './zip/*.zip'
file_glob: true
overwrite: true
tag: ${{ github.event.release.tag_name || inputs.tag }}
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 'Release'

on:
push:
branches:
- 'main'

env:
NODE_VERSION: 18

jobs:
build-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Clone Repo
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
cache: 'npm'

- name: NPM Install
run: npm ci

- name: NPM Lint
run: npm run lint

- name: NPM Build
run: npm run build --if-present

- name: NPM Test
run: npm run test --if-present

newRelease:
name: Create New Release
needs: [build-test]
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
cache: 'npm'

- name: NPM Install
run: npm ci

- name: NPM Build
run: npm run build --if-present

- name: Release
run: npm run release
env:
GITHUB_TOKEN: ${{secrets.GLOBAL_GITHUB_TOKEN}}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
CI: true
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
5 changes: 5 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"src/**/*.{ts,js,json,md,html,css,scss}": [
"npm run lint"
]
}
64 changes: 64 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"type": "docs",
"scope": "README",
"release": "patch"
},
{
"type": "refactor",
"release": "patch"
},
{
"type": "style",
"release": "patch"
}
],
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES"
]
}
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/github",
{
"assets": []
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


module.exports = { extends: ['@commitlint/config-conventional'] }
Loading

0 comments on commit ffe2417

Please sign in to comment.