Create GitHub releases #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}"}' | |