-
Notifications
You must be signed in to change notification settings - Fork 3
78 lines (64 loc) · 2.28 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
71
72
73
74
75
76
77
78
name: Release
on:
push:
tags:
- v?[0-9]+.[0-9]+**
workflow_call:
inputs:
tag:
description: Target tag
required: true
type: string
jobs:
release:
name: page
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: extract tag (version)
id: version
run: |
if [ -z "${{ inputs.tag }}" ]; then
echo "value=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
else
echo "value=${{ inputs.tag }}" >> $GITHUB_OUTPUT
fi
# checkout needed for changelog only
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ steps.version.outputs.value }}
- id: changelog
name: Generate Changelog
continue-on-error: true
run: |
git fetch --tags --all --prune-tags --force
TAG_FIRST=$(git describe --abbrev=0 --tags $(git describe --abbrev=0)^)
TAG_SECOND=$(git describe --abbrev=0)
echo "Generating changelog between tags: ${{ steps.version.outputs.value }}...$TAG_FIRST...$TAG_SECOND"
RESULT_FILE=generated-changelog.md
RESULT_LOG_ACT="$(git log $TAG_SECOND...${{ steps.version.outputs.value }} --pretty=format:'- %s [·](${{ github.event.repository.html_url }}/commit/%H)' --reverse)"
RESULT_LOG_POST="$(git log $TAG_FIRST...$TAG_SECOND --pretty=format:'- %s [·](${{ github.event.repository.html_url }}/commit/%H)' --reverse)"
echo "
## TODO: EDIT ME BEFORE PUBLISH
__Changelog ${{ steps.version.outputs.value }}__…${TAG_SECOND}
$RESULT_LOG_ACT
__${TAG_SECOND}__…${TAG_FIRST}
$RESULT_LOG_POST
<!-- Built with ♥️. -->
" > $RESULT_FILE
echo "file=$RESULT_FILE" >> $GITHUB_OUTPUT
- id: release
name: create release "${{ steps.version.outputs.value }}"
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
prerelease: true
tag_name: ${{ steps.version.outputs.value }}
release_name: ${{ steps.version.outputs.value }}
body_path: ${{ steps.changelog.outputs.file }}