Skip to content

Commit

Permalink
ci: add semantic-release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lcenchew committed Aug 23, 2020
1 parent 814b20b commit 741e3c2
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release
# Release the action on push to master

on:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest

outputs:
published: ${{ steps.release.outputs.published }}
release-version: ${{ steps.release.outputs.release-version }}
release-version-major: ${{ steps.release.outputs.release-version-major }}
release-version-minor: ${{ steps.release.outputs.release-version-minor }}

steps:
- uses: actions/checkout@v2
- id: release
name: semantic-release
uses: ahmadnassri/action-semantic-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

alias:
needs: release
if: needs.release.outputs.published == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
alias:
- version: v${{ needs.release.outputs.release-version-major }}
- version: v${{ needs.release.outputs.release-version-major }}.${{ needs.release.outputs.release-version-minor }}

steps:
- uses: actions/github-script@v2
with:
script: |
const tag = 'tags/${{ matrix.alias.version }}'
const repo = {
owner: context.repo.owner,
repo: context.repo.repo
}
await github.git.deleteRef({ ...repo, ref: tag }).catch(() => {})
await github.git.createRef({ ...repo, ref: `refs/${tag}` , sha: process.env.GITHUB_SHA })
35 changes: 35 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "conventionalcommits",
"releaseRules": [
{ "breaking": true, "release": "major" },
{ "revert": true, "release": "patch" },
{ "type": "build", "release": "patch" },
{ "type": "docs", "release": "patch" },
{ "type": "feat", "release": "minor" },
{ "type": "fix", "release": "patch" },
{ "type": "perf", "release": "patch" },
{ "type": "refactor", "release": "patch" }
]
}],
["@semantic-release/release-notes-generator", {
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{ "type": "build", "section": "Build", "hidden": false },
{ "type": "chore", "section": "Chores", "hidden": false },
{ "type": "ci", "section": "CI/CD", "hidden": false },
{ "type": "docs", "section": "Docs", "hidden": false },
{ "type": "feat", "section": "Features", "hidden": false },
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
{ "type": "perf", "section": "Performance", "hidden": false },
{ "type": "refactor", "section": "Refactor", "hidden": false },
{ "type": "style", "section": "Code Style", "hidden": false },
{ "type": "test", "section": "Tests", "hidden": false }
]
}
}],
"@semantic-release/github"
]
}
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"name": "merge-upstream",
"version": "0.0.0-semantically-released",
"author": {
"name": "lcenchew",
"email": "lcenchew@outlook.com",
"url": "https://github.com/exions/merge-upstream"
},
"license": "MIT",
"dependencies": {
},
"devDependencies": {
}
}

0 comments on commit 741e3c2

Please sign in to comment.