Skip to content

Commit

Permalink
build: setup automatic release
Browse files Browse the repository at this point in the history
  • Loading branch information
Th3S4mur41 authored Dec 9, 2022
1 parent 988dd17 commit f3f683c
Show file tree
Hide file tree
Showing 5 changed files with 9,680 additions and 1,489 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ jobs:
name: '▶️ actions'
needs: [lint-code]
uses: ./.github/workflows/codeql.yml

release:
name: '▶️ actions'
needs: [lint-code, codeql]
uses: ./.github/workflows/release.yml
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Token with repo write permission & admin rights to push to protected branches
53 changes: 53 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This is the workflow to trigger a release
#
name: Semantic release

on:
# Allows you to call this workflow from other workflows
workflow_call:
secrets:
NPM_TOKEN:
required: false
GH_TOKEN:
required: false

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
release:
name: '🏷️ Release'
runs-on: ubuntu-latest

environment:
name: production
url: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.release.outputs.version }}

outputs:
version: ${{ steps.release.outputs.version }}

steps:
- name: '☁️ Checkout repository'
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: '⚙️ Use Node.js'
uses: actions/setup-node@v3
with:
check-latest: true
cache: 'npm'

- name: '⛓️ Install dependencies'
run: npm ci --omit=optional --audit=false --prefer-offline --progress=false

- name: '📦 Release'
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} # Needed to push to GitHub
HUSKY: 0 # disable pre-commit hooks
run: |
npm run release
echo "::set-output name=version::$(npm run env | grep npm_package_version | cut -d '=' -f 2)"
50 changes: 50 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"branches": ["main", "next", { "name": "beta", "prerelease": true }, { "name": "alpha", "prerelease": true }],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"type": "build",
"scope": "deps",
"release": "patch"
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "build",
"section": "Dependencies and Other Build Updates",
"hidden": false
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": ["CHANGELOG.md", "package.json", "package-lock.json"]
}
],
"@semantic-release/github"
]
}
Loading

0 comments on commit f3f683c

Please sign in to comment.