Skip to content

Commit 4bf9247

Browse files
author
Jan Galek
committed
fixup! Added github actions
1 parent aed3179 commit 4bf9247

File tree

1 file changed

+77
-19
lines changed

1 file changed

+77
-19
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,89 @@ jobs:
5656
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
5757
if [ -z "$PREV_TAG" ]; then
5858
echo "No previous tag found, using initial commit."
59-
COMMITS=$(git log --format="- %s (@%an)" HEAD)
59+
COMMITS="<ul>"
60+
while read -r commit_hash; do
61+
COMMIT_MSG=$(git log -n 1 --pretty=format:"%s" "$commit_hash")
62+
AUTHOR=$(gh api "/repos/${{ github.repository }}/commits/$commit_hash" --jq '.author.login')
63+
COMMITS+="<li>$COMMIT_MSG (@$AUTHOR)</li>"
64+
done < <(git log --format="%H" HEAD)
65+
COMMITS+="</ul>"
6066
else
61-
COMMITS=""
67+
COMMITS="<ul>"
68+
declare -A FIXUPS
69+
70+
# Iterace přes všechny commity od posledního tagu
6271
while read -r commit_hash; do
6372
COMMIT_MSG=$(git log -n 1 --pretty=format:"%s" "$commit_hash")
6473
AUTHOR=$(gh api "/repos/${{ github.repository }}/commits/$commit_hash" --jq '.author.login')
65-
COMMITS+="- $COMMIT_MSG (@$AUTHOR)"
66-
COMMITS+=$'\n'
74+
75+
# Kontrola, zda jde o fixup commit
76+
if [[ "$COMMIT_MSG" == fixup!* ]]; then
77+
ORIGINAL_HASH=$(git log -n 1 --format="%H" "$commit_hash"^)
78+
FIXUPS["$ORIGINAL_HASH"]+="$commit_hash "
79+
continue
80+
fi
81+
82+
# Hledání uzavřených issue nebo PR pro tento commit
83+
COMMIT_URL="https://github.com/${{ github.repository }}/commit/$commit_hash"
84+
echo "Checking commit: $COMMIT_URL"
85+
86+
ISSUE_URLS=$(gh api "/repos/${{ github.repository }}/issues?state=closed" --jq "[.[] | select(.body != null and (.body | test(\"(Resolve|Close).*${commit_hash}\")))][].html_url" || echo "")
87+
ISSUE_COMMENT_URLS=$(gh api "/repos/${{ github.repository }}/issues/comments" --jq "[.[] | select(.body != null and (.body | test(\"(Resolve|Close).*${commit_hash}\")))][].html_url" || echo "")
88+
PR_URLS=$(gh api "/repos/${{ github.repository }}/pulls?state=all" --jq "[.[] | select(.body != null and (.body | contains(\"${commit_hash}\")))][].html_url" || echo "")
89+
REFERENCES="$ISSUE_URLS $ISSUE_COMMENT_URLS"
90+
91+
echo "VANILA"
92+
93+
echo "$ISSUE_URLS"
94+
echo "$ISSUE_COMMENT_URLS"
95+
echo "$PR_URLS"
96+
97+
ISSUE_URLS=$(echo "$ISSUE_URLS" | sed 's/#issuecomment-[0-9]*//g')
98+
ISSUE_COMMENT_URLS=$(echo "$ISSUE_COMMENT_URLS" | sed 's/#issuecomment-[0-9]*//g')
99+
100+
echo "CLEARED"
101+
echo "$ISSUE_URLS"
102+
echo "$ISSUE_COMMENT_URLS"
103+
echo "$PR_URLS"
104+
# Zpracování běžného commitu
105+
COMMITS+="<li>$COMMIT_MSG (@$AUTHOR)"
106+
107+
# Přidání všech odkazů na Issues
108+
if [[ -n "$ISSUE_URLS" ]]; then
109+
COMMITS+=", (Referenced in Issues: "
110+
# Seznam odkazů oddělený mezerou
111+
COMMITS+=$(echo "$ISSUE_URLS" | tr '\n' ' ' | sed -E "s|https://github.com/${{ github.repository }}/issues/([0-9]+)|<a href=\"https://github.com/${{ github.repository }}/issues/\1\">#\1</a>|g" | sed 's/ / , /g')
112+
COMMITS=$(echo "$COMMITS" | sed 's/, $//')
113+
COMMITS+=" )"
114+
fi
115+
116+
# Přidání všech odkazů na komentáře
117+
if [[ -n "$ISSUE_COMMENT_URLS" ]]; then
118+
COMMITS+=", (Referenced in Comments: "
119+
# Seznam odkazů oddělený mezerou
120+
COMMITS+=$(echo "$ISSUE_COMMENT_URLS" | tr '\n' ' '| sed -E "s|https://github.com/${{ github.repository }}/issues/([0-9]+)|<a href=\"https://github.com/${{ github.repository }}/issues/\1\">#\1</a>|g" | sed 's/ / , /g')
121+
COMMITS=$(echo "$COMMITS" | sed 's/, $//')
122+
COMMITS+=" )"
123+
fi
124+
125+
# Přidání všech odkazů na PRs
126+
if [[ -n "$PR_URLS" ]]; then
127+
COMMITS+=", (Referenced in PRs: "
128+
COMMITS+=$(echo "$PR_URLS" | tr '\n' ' '| sed -E "s|https://github.com/${{ github.repository }}/pulls/([0-9]+)|<a href=\"https://github.com/${{ github.repository }}/pulls/\1\">#\1</a>|g" | sed 's/ / , /g')
129+
COMMITS=$(echo "$COMMITS" | sed 's/, $//')
130+
COMMITS+=" )"
131+
fi
132+
133+
COMMITS+="</li>"
67134
done < <(git log --format="%H" $PREV_TAG..HEAD)
135+
COMMITS+="</ul>"
68136
fi
69-
137+
138+
echo "Result: $COMMITS"
139+
# Odstranění nechtěných znaků
70140
COMMITS=$(echo "$COMMITS" | sed 's/[[:cntrl:]]//g')
71-
141+
echo "Result clear: $COMMITS"
72142
echo "commits=$COMMITS" >> $GITHUB_ENV
73143
env:
74144
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -83,16 +153,4 @@ jobs:
83153
${{ env.commits }}
84154
draft: false
85155
prerelease: ${{ env.prerelease }}
86-
name: ${{ github.ref_name }} - ${{ env.release_type }}
87-
88-
# - name: Create release
89-
# uses: actions/create-release@v1
90-
# env:
91-
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92-
# with:
93-
# tag_name: ${{ github.ref_name }}
94-
# release_name: ${{ github.ref_name }} - ${{ env.release_type }}
95-
# body: |
96-
# ${{ env.commits }}
97-
# draft: false
98-
# prerelease: ${{ env.prerelease }}
156+
name: ${{ github.ref_name }} - ${{ env.release_type }}

0 commit comments

Comments
 (0)