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 ecf3063 commit 78e0b8a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: GitHub
on:
pull_request:
branches: [main]
#on:
# push:
# tags: ["*"]

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

steps:
- uses: actions/checkout@v4
- name: Extract the change log from CHANGES.(rst|md)
id: changelog
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
output=$(sed -n "${first},${last}p;${end}q" CHANGES.rst)
# GITHUB_OUTPUT needs a delimiter for multi line strings
delimiter="$(openssl rand -hex 8)"
echo "log<<${delimiter}" >> "${GITHUB_OUTPUT}"
echo "${output}" >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name: debug
run: echo '{"tag_name":"${{ github.ref_name }}","name":"${{ github.ref_name }}","body":"${{ steps.changelog.outputs.log }}"}'
# - name: Create a new GitHub release
# run: |
# curl -L \
# -X POST \
# --header "Accept: application/vnd.github+json" \
# --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
# --header "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/repos/${{ github.repository }}/releases \
# -d '{"tag_name":"${{ github.ref_name }}","name":"${{ github.ref_name }}","body":"${{ steps.changelog.outputs.log }}"}'

0 comments on commit 78e0b8a

Please sign in to comment.