-
Notifications
You must be signed in to change notification settings - Fork 44
73 lines (71 loc) · 2.47 KB
/
publish.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
71
72
73
name: Publish
on:
push:
branches:
- v14.x
- v15.x
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 10
token: ${{ secrets.GH_TOKEN }}
- name: Check out release commit
# The CHANGELOG has been touched by lerna during the creation of the
# latest release; so the respective commit SHA is the one we need
# to publish from.
run: |
SHA=$(git log -n 1 --pretty=format:%H -- CHANGELOG.md | tr -d '\n')
git checkout ${SHA}
- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.OS }}-node-14.x-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-14.x-
${{ runner.OS }}-node-
${{ runner.OS }}-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Push version tag
id: push-version-tag
run: |
git config user.name hops-untool
git config user.email [email protected]
version="v$(jq -r .version lerna.json)"
echo "::set-output name=version::${version}"
git tag $version
git push origin --tags
- name: Extract changelog
run: |
git diff HEAD^ -- CHANGELOG.md > diff.patch
sed -i diff.patch -e 's/CHANGELOG.md/release_changelog.md/g'
touch release_changelog.md
git apply --recount -C0 diff.patch
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ steps.push-version-tag.outputs.version }}
release_name: Release ${{ steps.push-version-tag.outputs.version }}
body_path: release_changelog.md
draft: false
prerelease: false
- name: Publish to registry
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
yarn lerna publish from-git --yes --no-verify-access