Skip to content

Commit f5fcde1

Browse files
committed
update github actions
auto release creation
1 parent 9badee6 commit f5fcde1

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

.github/workflows/pypi.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Publish Python package
22

33
on:
4-
push:
5-
tags:
4+
push:
5+
branches:
6+
- main
7+
- master
68

79
jobs:
810
publish:
@@ -12,6 +14,12 @@ jobs:
1214
steps:
1315
- uses: actions/checkout@v2
1416

17+
- name: get release info
18+
id: release_info
19+
run: |
20+
version="$(awk '/^## / { print tolower($2) }' CHANGELOG.md | head -1)"
21+
echo "::set-output name=version::$version"
22+
1523
- name: Set up Python 3.7
1624
uses: actions/setup-python@v2
1725
with:
@@ -41,7 +49,7 @@ jobs:
4149
python setup.py sdist bdist_wheel
4250
4351
- name: Publish distribution to PyPI
44-
if: startsWith(github.ref, 'refs/tags')
52+
if: steps.release_info.outputs.version != 'unreleased'
4553
uses: pypa/gh-action-pypi-publish@master
4654
with:
4755
password: ${{ secrets.pypi_password }}

.github/workflows/release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: get release info
19+
id: release_info
20+
run: |
21+
version="$(awk '/^## / { print tolower($2) }' CHANGELOG.md | head -1)"
22+
changelog="$(sed -e "1,/^## ${version}/d" -e "/^## /,\$d" CHANGELOG.md)"
23+
changelog="${changelog//'%'/'%25'}"
24+
changelog="${changelog//$'\n'/'%0A'}"
25+
changelog="${changelog//$'\r'/'%0D'}"
26+
echo "::set-output name=version::$version"
27+
echo "::set-output name=changelog::$changelog"
28+
29+
- name: create release
30+
if: steps.release_info.outputs.version != 'unreleased'
31+
uses: actions/create-release@v1
32+
id: create_release
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
tag_name: ${{ steps.release_info.outputs.version }}
37+
release_name: Release ${{ steps.release_info.outputs.version }}
38+
body: ${{ steps.release_info.outputs.changelog }}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## unreleased
8+
9+
### Changed
10+
- updated github actions to automatically create releases
11+
712
## 2.4.0 - 2021-02-22
813

914
### Changed

0 commit comments

Comments
 (0)