File tree Expand file tree Collapse file tree 2 files changed +74
-0
lines changed
Expand file tree Collapse file tree 2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -e
3+
4+ PACKAGE_VERSION=${1:- $(sed -r ' s/__version__ = "(.*)"/\1/' ravenpackapi/ version.py)}
5+
6+ # Make sure the version is in the changelog
7+ grep -n " ^## \[v$PACKAGE_VERSION ] \(.*\)" CHANGELOG.md > /dev/null \
8+ || (echo " Error. Version $PACKAGE_VERSION not in changelog" \
9+ && exit 1)
10+ LINE_BEFORE=$( \
11+ grep -n " ^## \[v$PACKAGE_VERSION ] \(.*\)" CHANGELOG.md \
12+ | cut -d: -f1 \
13+ | head -n 1 \
14+ )
15+
16+ # * cut from after the header of the current package version
17+ # * select all the other headers, showing the linue numbers
18+ # * get the line number of the first header
19+ LINE_AFTER=$( \
20+ tail -n +$LINE_BEFORE CHANGELOG.md \
21+ | tail -n +2 \
22+ | grep -n " ^## \[v.*\] \(.*\)" \
23+ | sed -r ' s/(.*):## \[v(.*)\] \(.*\)/\1:\2/' \
24+ | cut -d: -f1 \
25+ | head -1
26+ )
27+
28+ LINE_BEFORE=$(( LINE_BEFORE + 1 ))
29+ LINE_AFTER=$(( LINE_AFTER + LINE_BEFORE))
30+ LINE_AFTER=$(( LINE_AFTER - 2 ))
31+ # Extract range and remove empty lines from the beginning and end of the file
32+ sed -n " $LINE_BEFORE ,$LINE_AFTER p" CHANGELOG.md \
33+ | awk ' NF {p=1} p' | tac | awk ' NF {p=1} p' | tac
Original file line number Diff line number Diff line change 1+ name : Create a github release for a git tag
2+ on :
3+ push :
4+ tags :
5+ - ' v*.*.*'
6+ - ' v*.*'
7+ jobs :
8+ # Check that the tag matches the lastest version in the code
9+ check-version :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v4
13+ - name : Check version
14+ run : |
15+ # Get the latest version from the code
16+ latest_version=$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py)
17+ # Get the tag from the git tag
18+ tag=$(echo $GITHUB_REF | sed -r 's/refs\/tags\/v(.*)/\1/')
19+ # Check that the tag matches the latest version
20+ if [ "$latest_version" != "$tag" ]; then
21+ echo "The tag $tag does not match the latest version $latest_version"
22+ exit 1
23+ fi
24+
25+ # Create a release
26+ github-release :
27+ name : >-
28+ 📦✍ Sign the package with Sigstore
29+ and upload them to GitHub Release
30+ runs-on : ubuntu-latest
31+ needs : check-version
32+ steps :
33+ - uses : actions/checkout@v4
34+ - name : Dump the changelog
35+ run : .github/changelogtext.sh > '${{ github.ref_name }}.md'
36+ - name : Create GitHub Release
37+ env :
38+ GITHUB_TOKEN : ${{ github.token }}
39+ run : |
40+ latest_version=$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py)
41+ gh release create '${{ github.ref_name }}' -F '${{ github.ref_name }}.md' --title "Version $latest_version" --repo '${{ github.repository }}'
You can’t perform that action at this time.
0 commit comments