chore: create_gh_release job

This commit is contained in:
td 2024-04-23 15:39:46 +05:30
parent 7f1146434f
commit a0545cd0a7
No known key found for this signature in database
GPG Key ID: 62A30523D4D6CE28
2 changed files with 44 additions and 0 deletions

View File

@ -14,3 +14,29 @@ jobs:
uses: famedly/frontend-ci-templates/.github/workflows/publish-pub.yml@main uses: famedly/frontend-ci-templates/.github/workflows/publish-pub.yml@main
with: with:
env_file: ".github/workflows/versions.env" env_file: ".github/workflows/versions.env"
create_gh_release:
env:
GH_TOKEN: ${{ github.token }}
needs: [publish]
runs-on: ubuntu-latest
steps:
- name: Create release
run: |
version=$(echo ${{ github.ref_name }} | sed 's/^v//')
releaseRegex="^v[0-9]+\.[0-9]+\.[0-9]+$"
releaseCandidateRegex="^v[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+$"
notes="$(./scripts/extract_changelog.sh $version)"
if [ -z $notes ]; then
if [[ ${{ github.ref_name }} =~ $releaseRegex ]]; then
gh release create ${{ github.ref_name }} --notes $notes -t ${{ github.ref_name }} --verify-tag
elif [[ ${{ github.ref_name }} =~ $releaseCandidateRegex ]]; then
gh release create ${{ github.ref_name }} --notes $notes --prerelease -t ${{ github.ref_name }} --verify-tag
fi
else
if [[ ${{ github.ref_name }} =~ $releaseRegex ]]; then
gh release create ${{ github.ref_name }} --generate-notes -t ${{ github.ref_name }} --verify-tag
elif [[ ${{ github.ref_name }} =~ $releaseCandidateRegex ]]; then
gh release create ${{ github.ref_name }} --generate-notes --prerelease -t ${{ github.ref_name }} --verify-tag
fi

18
scripts/extract_changelog.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
echo "$(awk -v ver=$1 '
/^(##|###) \[?[0-9]+.[0-9]+.[0-9]+/ {
if (p) { exit };
if (index($2, "[")) {
split($2, a, "[");
split(a[2], a, "]");
if (a[1] == ver) {
p = 1
}
} else {
if ($2 == ver) {
p = 1
}
}
} p
' CHANGELOG.md)"