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

build(release): configure semantic release #289

Closed
wants to merge 19 commits into from
Closed
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
13 changes: 13 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
allowMergeCommits: true
allowRevertCommits: true
titleAndCommits: true
types:
- feat
- fix
- style
- refactor
- perf
- test
- build
- docs
- chore
33 changes: 33 additions & 0 deletions .github/workflows/release-alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Alpha release
on:
push:
branches:
- alpha
jobs:
Release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node_modules
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Release
run: npm run semver
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93 changes: 93 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Release
on:
push:
branches:
- master
jobs:
CurrentTag:
runs-on: ubuntu-latest
outputs:
CURRENT_TAG: ${{ steps.save-current-tag.outputs.CURRENT_TAG }}
steps:
- name: Checkout main
uses: actions/checkout@v2
with:
ref: main
- name: Reset branch
run: |
git fetch origin master:master
git reset --hard master
- name: Get current tag
id: current-tag
uses: WyriHaximus/github-action-get-previous-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save current tag
id: save-current-tag
run: echo '::set-output name=CURRENT_TAG::${{ steps.current-tag.outputs.tag }}'
Release:
runs-on: ubuntu-latest
needs: [CurrentTag]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node_modules
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Release
run: npm run semver
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR:
runs-on: ubuntu-latest
needs: [CurrentTag, Release]
steps:
- name: Checkout main
uses: actions/checkout@v2
with:
ref: main
- name: Reset branch
run: |
git fetch origin master:master
git reset --hard master
- name: Get latest tag
id: latest-tag
uses: WyriHaximus/github-action-get-previous-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Show current tag
run: echo 'The current tag is ${{ needs.CurrentTag.outputs.CURRENT_TAG }}'
- name: Has new tag
if: needs.CurrentTag.outputs.CURRENT_TAG != steps.latest-tag.outputs.tag
run: echo 'The current tag is not the same after the release. A new tag has been created'
- name: Has same tag
if: needs.CurrentTag.outputs.CURRENT_TAG == steps.latest-tag.outputs.tag
run: echo 'The current tag did not change'
- name: Create PR from master to main
if: needs.CurrentTag.outputs.CURRENT_TAG != steps.latest-tag.outputs.tag
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: 'chore(main): merge master into main due to new version v${{ steps.latest-tag.outputs.tag }}'
branch: feature/merge-master-into-main
commit-message: 'chore(main): merge master into main'
body: |
This PR was generated after the creation of the version v${{ steps.latest-tag.outputs.tag }}

The release is available on:
- [GitHub release](https://github.com/actions/stale/releases/tag/${{ steps.latest-tag.outputs.tag }})
68 changes: 68 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"branches": [
"master",
{
"name": "alpha",
"prerelease": true
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "angular"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "angular",
"writerOpts": {
"commitsSort": [
"subject",
"scope"
]
},
"linkCompare": true,
"linkReferences": true,
"commit": "commit",
"issue": "issues"
}
],
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md",
"changelogTitle": "# Stale Changelog"
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md"
],
"message": "build(release): new version v${nextRelease.version}"
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "dist/index.js",
"name": "stale-${nextRelease.gitTag}.js",
"label": "Stale ${nextRelease.gitTag} release"
}
],
"addReleases": "bottom"
}
]
],
"dryRun": false,
"ci": true,
"debug": false,
"tagFormat": "v${version}"
}
Empty file added CHANGELOG.md
Empty file.
Loading