-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
81 lines (78 loc) · 3.07 KB
/
action.yaml
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
79
80
81
name: 'Create changelog based release'
author: 'brainelectronics'
description: 'changelog2version based release action'
inputs:
github-token:
description: 'GitHub token for release'
required: true
default: ${{ github.token }}
changelog-path:
description: 'Path to changelog used for releasing'
required: false
default: 'changelog.md'
tag-name-prefix:
description: 'Prefix of tag name before extracted x.y.z from changelog'
required: false
default: ''
tag-name-extension:
description: 'Extension of tag name after extracted x.y.z from changelog'
required: false
default: -rc${{ github.run_number }}.dev${{ github.event.number }}
release-name-prefix:
description: 'Prefix of release name before extracted x.y.z from changelog'
required: false
default: ''
release-name-extension:
description: 'Extension of release name after extracted x.y.z from changelog'
required: false
default: -rc${{ github.run_number }}.dev${{ github.event.number }}
draft-release:
description: 'Is this a draft release'
required: true
default: false
prerelease:
description: 'Is this a Prerelease'
required: true
default: false
outputs:
latest-description:
description: "Content of latest changelog entry"
value: "${{ steps.parse-changelog.outputs.LATEST_DESCRIPTION }}"
latest-version:
description: "Latest changelog version"
value: ${{ steps.parse-changelog.outputs.LATEST_VERSION }}
runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install required packages
run: pip install -r requirements.txt
shell: bash
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Print changelog2version version
run: changelog2version --version
shell: bash
- name: Parse changelog
id: parse-changelog
run: |
changelog2version --changelog_file ${{ inputs.changelog-path }} --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['description'])" > latest_description.txt
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
latest_version=$(changelog2version --changelog_file ${{ inputs.changelog-path }} --print | python -c "import sys, json; print(json.load(sys.stdin)['info']['version'])")
echo "LATEST_VERSION=$latest_version" >> $GITHUB_OUTPUT
shell: bash
- name: Create (Pre)Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
with:
tag_name: ${{ inputs.tag-name-prefix }}${{ steps.parse-changelog.outputs.LATEST_VERSION }}${{ inputs.tag-name-extension }}
release_name: ${{ inputs.tag-name-prefix }}${{ steps.parse-changelog.outputs.LATEST_VERSION }}${{ inputs.release-name-extension }}
body: ${{ steps.parse-changelog.outputs.LATEST_DESCRIPTION }}
draft: ${{ inputs.draft-release }}
prerelease: ${{ inputs.prerelease }}