-
Notifications
You must be signed in to change notification settings - Fork 18
70 lines (61 loc) · 2.5 KB
/
release.yml
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
name: Release
on:
workflow_dispatch:
inputs:
strategy:
description: Valid semver number <x.x.x> or strategy <patch, minor, major>
default: "patch"
required: false
jobs:
release:
runs-on: ubuntu-latest
if: ${{ github.actor == 'pebie' || github.actor == 'Crow-EH' || github.actor == 'fthouraud' || github.actor == 'leguellec' || github.actor == 'rande' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Bump the version using input strategy
run: yarn version ${{ github.event.inputs.strategy }}
- name: Update changelog
id: changelog
run: |
yarn install
CHANGELOG=$(yarn conventional-changelog -p conventionalcommits -r -u 0)
echo -e "${CHANGELOG}\n\n\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
BODY=$(echo -e "${CHANGELOG}" | sed -e "1,2d")
BODY="${BODY//'%'/'%25'}"
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'\r'/'%0D'}"
echo "::set-output name=body::${BODY}"
- name: Log changes
run: |
echo "The changelog will be : ${{ steps.changelog.outputs.body }}"
- name: Get version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.1.0
- name: Create tag
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "chore(bump): release v${{ steps.package-version.outputs.current-version }}"
git push
git tag -a v${{ steps.package-version.outputs.current-version }} -m "chore(tag): release v${{ steps.package-version.outputs.current-version }}"
git push origin v${{ steps.package-version.outputs.current-version }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
body: ${{ steps.changelog.outputs.body }}
tag_name: v${{ steps.package-version.outputs.current-version }}
name: v${{ steps.package-version.outputs.current-version }}
- name: Setup npmrc
uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM
run: npm publish --access public
env:
VERSION: ${{ steps.package-version.outputs.current-version }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}