Skip to content

Commit

Permalink
DRAFT: create a GitHub release
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Nov 12, 2023
1 parent f67c0b7 commit bed3bc3
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: GitHub
on:
pull_request:
branches: [main]
#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"

0 comments on commit bed3bc3

Please sign in to comment.