This repository was archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (62 loc) · 2.48 KB
/
cd.yml
File metadata and controls
74 lines (62 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: "CD"
on:
workflow_dispatch:
inputs:
release-type:
description: "Type of release?"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
name: "Release"
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_PAT }}
- name: "Set up Node"
uses: actions/setup-node@v2
with:
node-version: '12'
cache: 'yarn'
- name: "Install dependencies"
run: yarn install --frozen-lockfile
- name: "Bump package versions"
id: bump
run: |
yarn bump ${{ github.event.inputs.release-type }}
echo "::set-output name=version::$(node --print 'require("./lerna.json").version')"
- name: "Update the changelog"
# Find the first line that starts with `###` or `## [<number>` from the CHANGELOG and insert the new version header before it.
run: sed -i "0,/^\(###\|## *\[[0-9]\).*/{s//## [${{ steps.bump.outputs.version }}] - $(date -u '+%Y-%m-%d')\n\n&/}" CHANGELOG.md
- name: "Extract version's changelog for release notes"
# 1. Find the lines between the first `## [<number>` and the second `## [<number>`.
# 2. Remove all leading and trailing newlines from the output.
run: sed '1,/^## *\[[0-9]/d;/^## *\[[0-9]/Q' CHANGELOG.md | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > release_notes.txt
- name: "Commit and tag the changes"
run: |
git config user.name 'github-actions'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add lerna.json \*package.json CHANGELOG.md
git commit --message='Release ${{ steps.bump.outputs.version }}'
git tag --annotate --message='' v${{ steps.bump.outputs.version }}
- name: "Build the sources"
run: yarn build
- name: "Publish to npm"
run: |
echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > .npmrc
yarn release
- name: "Push the changes"
run: git push --follow-tags
- name: "Create a GitHub release"
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
with:
tag_name: v${{ steps.bump.outputs.version }}
name: v${{ steps.bump.outputs.version }}
body_path: release_notes.txt