Skip to content

Commit

Permalink
refactor: combine release and tag creation
Browse files Browse the repository at this point in the history
  • Loading branch information
suft committed Dec 19, 2024
1 parent fc698e0 commit 2c62474
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 73 deletions.
26 changes: 22 additions & 4 deletions .github/scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#!/bin/bash

set -e

release_has_public_changes=false

url=$(git remote get-url origin | sed -r 's/(.*)\.git/\1/')

previous_tag=$(git describe --tags --abbrev=0 HEAD~)

echo "Changes since $previous_tag:"
echo

# Loop through all commits since previous tag
for rev in $(git log $previous_tag..HEAD --format="%H" --reverse --no-merges)
for rev in $(git log "$previous_tag"..HEAD --format="%H" --reverse --no-merges)
do
summary=$(git log $rev~..$rev --format="%s")
summary=$(git log "$rev"~.."$rev" --format="%s")
# Exclude commits starting with "Meta"
if [[ $summary != Meta* ]]
then
# Print markdown list of commit headlines
echo "* [$summary]($url/commit/$rev)"
# Append commit body indented (blank lines and signoff trailer removed)
git log $rev~..$rev --format="%b" | sed '/^\s*$/d' | sed '/^Signed-off-by:/d' | \
git log "$rev"~.."$rev" --format="%b" | sed '/^\s*$/d' | sed '/^Signed-off-by:/d' | \
while read -r line
do
# Escape markdown formatting symbols _ * `
Expand All @@ -34,3 +35,20 @@ then
echo "No public changes since $previous_tag." >&2
exit 1
fi

head_tag=$(git describe --exact-match 2>/dev/null || true)

git log --color=always --format="%C(auto)%h %s%d" | head

if [[ ${head_tag} =~ [\d{2}\.\d{2}\.\d+] ]]; then
echo "Version tag ${head_tag} already exists."
else
git config --local user.email "[email protected]"
git config --local user.name "github-actions"
version=$(date +'%y.%m.0')
git tag -a "${version}" -m "Release ${version}"
git push origin "${version}"
git log --color=always --format="%C(auto)%h %s%d" | head -1
echo "Pushed new tag:"
echo "${url}/releases/tag/${version}"
fi
40 changes: 0 additions & 40 deletions .github/scripts/tag.sh

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: "${{secrets.COMMIT_KEY}}"

- name: Create Package
run: tar -czf forgit-${{github.ref_name}}.tar.gz --exclude LICENSE --exclude README.md *

- name: Generate Changelog
- name: Generate Changelog and Tag
id: changelog
run: .github/scripts/changelog.sh > CHANGELOG.md
env:
REPO_URL: ${{github.server_url}}/${{github.repository}}
continue-on-error: true

- name: Release
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/tag.yaml

This file was deleted.

0 comments on commit 2c62474

Please sign in to comment.