-
Notifications
You must be signed in to change notification settings - Fork 26
59 lines (50 loc) · 1.92 KB
/
generate-changelog.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
name: 'Generate Changelog'
on:
workflow_dispatch:
inputs:
current-release-tag:
type: string
description: 'The tag of the current release starting with v'
required: false
default: ''
push:
tags:
- 'v*'
jobs:
Changelog:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Git repository with history for all branches and tags'
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive # Needed in order to fetch Kalium sources for building
- name: 'Set current Git tag from input'
env:
INPUT_RELEASE_TAG: ${{github.event.inputs.current-release-tag}}
if: "${{ github.event.inputs.current-release-tag != '' }}"
run: echo "CURRENT_TAG=$INPUT_RELEASE_TAG" >> "$GITHUB_ENV"
- name: 'Set current Git tag from commit'
if: "${{ github.event.inputs.current-release-tag == '' }}"
run: echo "CURRENT_TAG=$(git tag --points-at ${{github.sha}} | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | tail -n 1)" >> "$GITHUB_ENV"
- name: 'Set previous Git tag from commit'
run: echo "PREVIOUS_TAG=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(\+|$)' | tail -n 2 | head -n 1)" >> "$GITHUB_ENV"
- name: 'Print environment variables'
run: |
echo -e "PREVIOUS_TAG = $PREVIOUS_TAG"
echo -e "CURRENT_TAG = $CURRENT_TAG"
echo -e "Node.js version = $(node --version)"
- name: 'Generate changelog'
run: |
echo "{}" > ./package.json
npx [email protected] -t "$PREVIOUS_TAG...$CURRENT_TAG"
- name: 'Attach changelog to tag'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{github.token}}
with:
tag_name: ${{env.CURRENT_TAG}}
name: ${{env.CURRENT_TAG}}
body_path: ./CHANGELOG.md
draft: false
prerelease: false