Skip to content

Commit

Permalink
Добавляет автогенерацию релиза
Browse files Browse the repository at this point in the history
  • Loading branch information
igsekor committed Jul 28, 2024
1 parent 909e286 commit 90d1f89
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/scripts/update-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
MONTH_TO_ENG() {
case "$1" in
01) echo "December" ;;
02) echo "January" ;;
03) echo "February" ;;
04) echo "March" ;;
05) echo "April" ;;
06) echo "May" ;;
07) echo "June" ;;
08) echo "July" ;;
09) echo "August" ;;
10) echo "September" ;;
11) echo "October" ;;
12) echo "November" ;;
esac
}

MONTH_TO_RUS() {
case "$1" in
01) echo "декабрь" ;;
02) echo "январь" ;;
03) echo "февраль" ;;
04) echo "март" ;;
05) echo "апрель" ;;
06) echo "май" ;;
07) echo "июнь" ;;
08) echo "июль" ;;
09) echo "август" ;;
10) echo "сентябрь" ;;
11) echo "октябрь" ;;
12) echo "ноябрь" ;;
esac
}

CURRENT_MONTH=$(date -u +"%m")
CURRENT_YEAR=$(date -u +"%Y")
SHORT_YEAR=$(date -u +"%y")
if [[ "$CURRENT_MONTH" == "01" ]]; then
CURRENT_YEAR="$(($CURRENT_YEAR - 1))"
SHORT_YEAR="$(($SHORT_YEAR - 1))"
fi

TAG="v.$(($CURRENT_MONTH - 1)).$SHORT_YEAR"
TITLE="$(MONTH_TO_ENG $CURRENT_MONTH) $CURRENT_YEAR ($TAG)"

SUBTITLE_OLD_1="## What's Changed"
SUBTITLE_OLD_2="## New Contributors"
SUBTITLE_OLD_3="Full Changelog"

SUBTITLE_NEW_1="## Ченджлог ($(MONTH_TO_RUS $CURRENT_MONTH) $CURRENT_YEAR)"
SUBTITLE_NEW_2="## Новые контрибьюторы"
SUBTITLE_NEW_3="Весь ченджлог"

gh repo set-default doka-guide/content
gh release create "$TAG" --draft --title="$TITLE" --generate-notes --verify-tag
gh release view --repo=github.com/doka-guide/content >> auto-notes.md
sed -E 's/\* /- /g' auto-notes.md | sed -E 's/'"$SUBTITLE_OLD_1"'/'"$SUBTITLE_NEW_1"'/' | sed -E 's/'"$SUBTITLE_OLD_2"'/'"$SUBTITLE_NEW_2"'/' | sed -E 's/'"$SUBTITLE_OLD_3"'/'"$SUBTITLE_NEW_3"'/' > notes.md
gh release edit "$TAG" --draft --notes-file notes.md
18 changes: 18 additions & 0 deletions .github/workflows/update-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Create Release Draft

on:
schedule:
- cron: '0 5 1 * *'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-22.04
steps:
- name: Создание черновика релиза
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: sh .github/scripts/update-release.sh

0 comments on commit 90d1f89

Please sign in to comment.