Skip to content

Commit

Permalink
Merge pull request #68 from gforcada/create-github-releases
Browse files Browse the repository at this point in the history
Create GitHub releases
  • Loading branch information
gforcada committed Nov 12, 2023
2 parents ecc2f52 + 9d99fd5 commit 2e9d3aa
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: GitHub
on:
push:
tags: ["*"]

jobs:
release:
permissions: write-all
runs-on: "ubuntu-latest"
name: Create a Release

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Create a new GitHub release
run: |
# get the lines where the changelog for the last release starts and finishes
first_line=$(grep -n "\-\-\-\-" CHANGES.rst | cut -d":" -f1 |head -n1)
last_line=$(grep -n "\-\-\-\-" CHANGES.rst | cut -d":" -f1 |head -n2 | tail -n1)
# do some math to adjust the line numbers
first=$((${first_line}+1))
last=$((${last_line}-2))
end=$((${last_line}-1))
# extract the changelog
sed -n "${first},${last}p;${end}q" CHANGES.rst > body.txt
# remove new line characters
sed -z 's/\n/\\n/g' body.txt > body.json
echo '{"tag_name": "${{ github.ref_name }}",' > data.json
echo '"name": "${{ github.ref_name }}",' >> data.json
echo '"body": "' >> data.json
cat body.json >> data.json
echo '"}"' >> data.json
cat data.json
curl -L \
-X POST \
--header "Accept: application/vnd.github+json" \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
https://api.github.com/repos/${{ github.repository }}/releases \
-d "@data.json"
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ CHANGES
- Add support for Python 3.12
[gforcada]

- Automatically create GitHub releases with GitHub Actions.
[gforcada]

5.1.0 (2022-12-03)
------------------

Expand Down

0 comments on commit 2e9d3aa

Please sign in to comment.