chore(release): release on separate branch with changelog (#73)

* chore(release): release on separate branch with changelog

* chore: update changelog

* chore(ci): add required build step

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
Jeroen de Bruijn 2020-05-11 09:44:48 +02:00 committed by GitHub
parent a5501b90ee
commit c6cec8c885
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 122 additions and 325 deletions

View file

@ -64,9 +64,65 @@ jobs:
with:
configurationFile: example/renovate-config.js
token: ${{ secrets.RENOVATE_TOKEN }}
build:
needs: [lint, commitlint, e2e]
runs-on: ubuntu-latest
steps:
- run: echo 'Dummy'
- run: echo 'dummy'
release:
needs: [build]
runs-on: ubuntu-latest
if: |
startsWith(github.event.commits[0].message,
'fix(deps): update renovate/renovate docker tag ')
&& github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
with:
fetch-depth: 0
ref: 'release'
- name: Fetch tags
run: git fetch --tags
- name: Setup Git user
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Merge master
run: |
git merge -m 'chore(release): merge master (${{ github.sha }})' ${{ github.sha }}
- name: Setup node
uses: actions/setup-node@v1.4.1
with:
node-version: '12.x'
- name: Install project
run: npm ci --ignore-scripts
- name: Get version
id: release
run: npm run release:version
- name: Release
run: npm run release -- "${{ steps.release.outputs.version }}"
- name: Get changelog section
id: changelog
run: |
changelog="$(git show --unified=0 CHANGELOG.md \
| tail +12 \
| sed -e 's/^\+//' \
| sed -z 's/\n/%0A/g;s/\r/%0D/g')"
echo "::set-output name=changelog::${changelog}"
- name: Publish release
run: git push --follow-tags
- name: Publish GitHub release
uses: actions/create-release@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.release.outputs.version }}
release_name: v${{ steps.release.outputs.version }}
body: |
*See the the [changelog](
https://github.com/${{ github.repository }}/blob/release/CHANGELOG.md
) for changes in all releases.*
${{ steps.changelog.outputs.changelog }}

View file

@ -1,65 +0,0 @@
name: Release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
if: |
startsWith(github.event.commits[0].message, 'fix(deps): update renovate/renovate docker tag ')
steps:
- name: Checkout
uses: actions/checkout@v2.1.0
with:
fetch-depth: 0
- name: Fetch tags
run: git fetch --tags
- name: Setup Git user
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v1.4.1
with:
node-version: '12.x'
- name: Install project
run: npm ci
- name: Release
run: |
SEMVER_REGEX="v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
if [[ ! "${{ github.event.commits[0].message }}" =~ ${SEMVER_REGEX} ]]; then
echo Not a semver like version - aborting: ${1}
exit 1
fi
NEXT_VERSION="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
MAJOR_VERSION="${BASH_REMATCH[1]}"
echo "::set-env name=NEXT_VERSION::${NEXT_VERSION}"
echo "::set-env name=MAJOR_VERSION::${MAJOR_VERSION}"
npm version ${NEXT_VERSION} -m "chore(release): ${NEXT_VERSION}"
git tag "v${MAJOR_VERSION}"
- name: Publish release
run: |
git push origin "v${NEXT_VERSION}"
git push -f origin "v${MAJOR_VERSION}"
# - name: Publish GitHub release
# uses: actions/create-release@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ env.NEXT_VERSION }}
# release_name: v${{ env.NEXT_VERSION }}
# body: |
# See the the [changelog](
# https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md
# ) for the changes included in this release.
prevent_failed_status:
name: Prevent failed status when skipped
runs-on: ubuntu-latest
steps:
- name: Prevent failed status when skipped
run: |
echo "Run this job to prevent the workflow status from showing as" \
"failed when all other jobs are skipped."