Skip to content

Commit f461eda

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 a1703dc commit f461eda

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
@@ -66,16 +66,64 @@ jobs:
6666
path: dist/
6767
if-no-files-found: error
6868

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

80128
- name: Publish the Python distribution to PyPI
81129
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)