-
Notifications
You must be signed in to change notification settings - Fork 324
65 lines (58 loc) · 2.45 KB
/
changelog-preview.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
name: Changelog preview
on:
pull_request:
branches:
- main
types: [opened, synchronize]
jobs:
generate_changelog_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: develop
# pulls all commits (needed for semantic release to correctly version)
fetch-depth: '0'
# pulls all tags (needed for semantic release to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- name: Installation
run: |
yarn --frozen-lockfile
cd package/
yarn --frozen-lockfile
cd native-package/
yarn
cd ../../examples/SampleApp/
yarn
- name: Generate Changelog
id: generate_changelog
run: |
GITHUB_REF='refs/heads/develop' yarn extract-changelog
echo "Changelog script finished! Checking if there are changes..."
CHANGELOG_PREVIEW=$(cat NEXT_RELEASE_CHANGELOG.md || true)
if [[ ! -z "${CHANGELOG_PREVIEW}" ]]; then
echo "Changelog found! Writing header to the file..."
echo '# Next releases' | cat - NEXT_RELEASE_CHANGELOG.md > NEXT_RELEASE_CHANGELOG.tmp.md && mv NEXT_RELEASE_CHANGELOG.tmp.md NEXT_RELEASE_CHANGELOG.md
echo "Changelog file ready! Setting up outputs"
CHANGELOG_PREVIEW=$(cat NEXT_RELEASE_CHANGELOG.md)
CHANGELOG_PREVIEW_ESCAPED="${CHANGELOG_PREVIEW//'%'/'%25'}"
CHANGELOG_PREVIEW_ESCAPED="${CHANGELOG_PREVIEW_ESCAPED//$'\n'/'%0A'}"
CHANGELOG_PREVIEW_ESCAPED="${CHANGELOG_PREVIEW_ESCAPED//$'\r'/'%0D'}"
echo "::set-output name=exists::true"
echo "::set-output name=preview::$CHANGELOG_PREVIEW_ESCAPED"
fi
- uses: marocchino/sticky-pull-request-comment@v2
if: steps.generate_changelog.outputs.exists == 'true'
with:
header: changelog_preview
message: ${{ steps.generate_changelog.outputs.preview }}
- uses: marocchino/sticky-pull-request-comment@v2
if: steps.generate_changelog.outputs.exists != 'true'
with:
header: changelog_preview
message: No changelog generated for the current changes on this pull request.