-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to create a github release pushing a git tag
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
PACKAGE_VERSION=${1:-$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py)} | ||
|
||
# Make sure the version is in the changelog | ||
grep -n "^## \[v$PACKAGE_VERSION] \(.*\)" CHANGELOG.md >/dev/null \ | ||
|| (echo "Error. Version $PACKAGE_VERSION not in changelog" \ | ||
&& exit 1) | ||
LINE_BEFORE=$( \ | ||
grep -n "^## \[v$PACKAGE_VERSION] \(.*\)" CHANGELOG.md \ | ||
| cut -d: -f1 \ | ||
| head -n 1 \ | ||
) | ||
|
||
# * cut from after the header of the current package version | ||
# * select all the other headers, showing the linue numbers | ||
# * get the line number of the first header | ||
LINE_AFTER=$( \ | ||
tail -n +$LINE_BEFORE CHANGELOG.md \ | ||
| tail -n +2 \ | ||
| grep -n "^## \[v.*\] \(.*\)" \ | ||
| sed -r 's/(.*):## \[v(.*)\] \(.*\)/\1:\2/' \ | ||
| cut -d: -f1 \ | ||
| head -1 | ||
) | ||
|
||
LINE_BEFORE=$((LINE_BEFORE + 1)) | ||
LINE_AFTER=$((LINE_AFTER + LINE_BEFORE)) | ||
LINE_AFTER=$((LINE_AFTER - 2)) | ||
# Extract range and remove empty lines from the beginning and end of the file | ||
sed -n "$LINE_BEFORE,$LINE_AFTER p" CHANGELOG.md \ | ||
| awk 'NF {p=1} p' | tac | awk 'NF {p=1} p' | tac |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Create a github release for a git tag | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
- 'v*.*' | ||
jobs: | ||
# Check that the tag matches the lastest version in the code | ||
check-version: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check version | ||
run: | | ||
# Get the latest version from the code | ||
latest_version=$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py) | ||
# Get the tag from the git tag | ||
tag=$(echo $GITHUB_REF | sed -r 's/refs\/tags\/v(.*)/\1/') | ||
# Check that the tag matches the latest version | ||
if [ "$latest_version" != "$tag" ]; then | ||
echo "The tag $tag does not match the latest version $latest_version" | ||
exit 1 | ||
fi | ||
# Create a release | ||
github-release: | ||
name: >- | ||
📦✍ Sign the package with Sigstore | ||
and upload them to GitHub Release | ||
runs-on: ubuntu-latest | ||
needs: check-version | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Dump the changelog | ||
run: .github/changelogtext.sh > '${{ github.ref_name }}.md' | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: | | ||
latest_version=$(sed -r 's/__version__ = "(.*)"/\1/' ravenpackapi/version.py) | ||
gh release create '${{ github.ref_name }}' -F '${{ github.ref_name }}.md' --title "Version $latest_version" --repo '${{ github.repository }}' |