Skip to content

Commit a4c1243

Browse files
committed
ci: Create GitHub Release automatically
Add a GitHub job 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 1bf1993 commit a4c1243

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,67 @@ jobs:
6969
path: dist/
7070
if-no-files-found: error
7171

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

83131
- name: Publish the Python distribution to PyPI
84132
uses: pypa/gh-action-pypi-publish@release/v1
85133
with:
86134
password: ${{ secrets.PYPI_API_TOKEN }}
87-
packages_dir: ./
88135
skip_existing: true

RELEASE_NOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `frequenz-channels` Release Notes
2+
3+
## Summary
4+
5+
This is the first public open source release based on the internal SDK version v0.9.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-channels`](https://pypi.org/project/frequenz-channels/), so this project now can be installed normally via `pip`:
6+
7+
```sh
8+
python -m pip install frequenz-channels
9+
```
10+
11+
The GitHub issues were also improved, adding templates for [reporting issues](https://github.com/frequenz-floss/frequenz-channels/issues/new?assignees=&labels=priority%3A%E2%9D%93%2C+type%3Abug&template=bug.yml) and [requesting features](https://github.com/frequenz-floss/frequenz-channels/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-channels/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)