-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (79 loc) · 3.9 KB
/
release.yml
File metadata and controls
93 lines (79 loc) · 3.9 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
# Contact @moabu
name: release
on:
push:
paths:
- __version__.py
branches-ignore:
- master
- main
tags-ignore:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.7]
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2.2.2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
sudo apt-get update
sudo apt-get install ruby
- name: Checkout code
uses: actions/checkout@master
- name: Get version
id: get_version
run: |
mkdir /home/runner/work/test
cp -r . /home/runner/work/test/
cd /home/runner/work/test/
echo "::set-output name=version::$(python3 -c 'import __version__ ; print(__version__.__version__)')"
echo "::set-output name=pversion::$(python3 -c 'import __version__ ; print(__version__.__previous_version__)')"
echo "::set-output name=gituser::$(python3 -c 'import os ; REPO = os.environ.get("GITHUB_REPOSITORY") ; print(str(REPO).split("/")[0])')"
echo "::set-output name=gitproject::$(python3 -c 'import os ; REPO = os.environ.get("GITHUB_REPOSITORY") ; print(str(REPO).split("/")[1])')"
echo "::set-output name=gitbranch::$(python3 -c 'import os ; BRANCH = os.environ.get("GITHUB_REF") ; print(str(BRANCH).split("/")[2])')"
echo "::set-output name=releasedate::$(date +'%d-%m-%Y')"
- name: Install Changelog autogenerator
run: |
cd /home/runner/work/test/
sudo gem install github_changelog_generator
github_changelog_generator --user ${{ steps.get_version.outputs.gituser }} --project ${{ steps.get_version.outputs.gitproject }} --date-format "%m/%d/%Y" --header-label "# Release Notes" --output release_notes.md --token ${{ secrets.token }} --include-labels ${{ steps.get_version.outputs.gitbranch }} --since-tag ${{ steps.get_version.outputs.pversion }} --author false
sed -i '$ d' release_notes.md
github_changelog_generator --user ${{ steps.get_version.outputs.gituser }} --project ${{ steps.get_version.outputs.gitproject }} --date-format "%m/%d/%Y" --token ${{ secrets.token }} --author false
sed -i '$ d' CHANGELOG.md
- name: Read CHANGELOG
id: changelog
run: |
release_notes=$(sed -e '1,6d;' /home/runner/work/test/release_notes.md)
release_notes="${release_notes//'%'/'%25'}"
release_notes="${release_notes//$'\n'/'%0A'}"
release_notes="${release_notes//$'\r'/'%0D'}"
echo "::set-output name=body::$release_notes"
cp /home/runner/work/test/CHANGELOG.md .
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
# in order for this to trigger proceeding action the token cannot be github default token.
GITHUB_TOKEN: ${{ secrets.MOWORKFLOWTOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ steps.get_version.outputs.version }}
body: |
# Release Notes
## [${{ steps.get_version.outputs.version }}](https://github.com/${{ steps.get_version.outputs.gituser }}/${{ steps.get_version.outputs.gitproject }}/tree/${{ steps.get_version.outputs.version }}) (${{ steps.get_version.outputs.releasedate }})
[Full Changelog](https://github.com/${{ steps.get_version.outputs.gituser }}/${{ steps.get_version.outputs.gitproject }}/compare/${{ steps.get_version.outputs.pversion }}...${{ steps.get_version.outputs.version }})
${{ steps.changelog.outputs.body }}
draft: false
prerelease: true