Skip to content

Commit 4e24e9d

Browse files
committed
ci: Create GitHub Release automatically
Add a GitHub workflow to create the GitHub Release automatically when a version is tagged. Also use the GitHub feature to create the CHANGELOG automatically. When creating the GitHub release the contents of the file RELEASE_NOTES.md will be used as release notes, so it should only contain an explanation on the release main changes and be user-facing. Also add the release notes for the current release. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 4e70924 commit 4e24e9d

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,64 @@ jobs:
6565
path: dist/
6666
if-no-files-found: error
6767

68-
publish-to-pypi:
68+
create-github-release:
6969
needs: ["test", "build-dist"]
70-
# Publish only on tags creation
70+
# Create a release only on tags creation
7171
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
72+
permissions:
73+
# We need write permissions on contents to create GitHub releases and on
74+
# discussions to create the release announcement in the discussion forums
75+
contents: write
76+
discussions: write
77+
runs-on: ubuntu-20.04
78+
steps:
79+
- name: Download dist files
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: frequenz-sdk-python-dist
83+
path: dist
84+
85+
- name: Download RELEASE_NOTES.md
86+
run: |
87+
set -ux
88+
gh api \
89+
-X GET \
90+
-f ref=$REF \
91+
-H "Accept: application/vnd.github.raw" \
92+
"/repos/$REPOSITORY/contents/RELEASE_NOTES.md" \
93+
> RELEASE_NOTES.md
94+
env:
95+
REF: ${{ github.ref }}
96+
REPOSITORY: ${{ github.repository }}
97+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
99+
- name: Create GitHub release
100+
run: |
101+
set -ux
102+
extra_opts=
103+
if echo "$REF_NAME" | grep -- -; then extra_opts=" --prerelease"; fi
104+
gh release create \
105+
-R "$REPOSITORY" \
106+
--discussion-category announcements \
107+
--notes-file RELEASE_NOTES.md \
108+
--generate-notes \
109+
$extra_opts \
110+
$REF_NAME \
111+
dist/*
112+
env:
113+
REF_NAME: ${{ github.ref_name }}
114+
REPOSITORY: ${{ github.repository }}
115+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
117+
publish-to-pypi:
118+
needs: ["create-github-release"]
72119
runs-on: ubuntu-20.04
73120
steps:
74121
- name: Download dist files
75122
uses: actions/download-artifact@v3
76123
with:
77124
name: frequenz-sdk-python-dist
125+
path: dist
78126

79127
- name: Publish the Python distribution to PyPI
80128
uses: pypa/gh-action-pypi-publish@release/v1

RELEASE_NOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `frequenz-sdk` Release Notes
2+
3+
## Summary
4+
5+
This is the first public open source release based on the internal SDK version v0.10.0. There are no breaking changes in this release, only changes to the project structure, metadata, and automation. Packages are also now uploaded to PyPI as [`frequenz-sdk`](https://pypi.org/project/frequenz-sdk/), so this project now can be installed normally via `pip`:
6+
7+
```sh
8+
python -m pip install frequenz-sdk
9+
```
10+
11+
The GitHub issues were also improved, adding templates for [reporting issues](https://github.com/frequenz-floss/frequenz-sdk-python/issues/new?assignees=&labels=priority%3A%E2%9D%93%2C+type%3Abug&template=bug.yml) and [requesting features](https://github.com/frequenz-floss/frequenz-sdk-python/issues/new?assignees=&labels=part%3A%E2%9D%93%2C+priority%3A%E2%9D%93%2C+type%3Aenhancement&template=feature.yml). Users are also pointed to the [Discussion forums](https://github.com/frequenz-floss/frequenz-sdk-python/issues/new/choose) when trying to open an issue if they have questions instead. Also many labels are assigned automatically on issue and pull request creation.

0 commit comments

Comments
 (0)