Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta: do not create tag when there are no public changes #414

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 0 additions & 21 deletions .github/scripts/tag.sh

This file was deleted.

10 changes: 9 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
# The COMMIT_KEY secret contains a private SSH key. The associated public key
# has been added as a deploy key in the GitHub project. See:
# https://docs.github.com/en/developers/overview/managing-deploy-keys#deploy-keys
# This is necessary to make commits done by github-actions able to trigger
# further github-actions. See: https://stackoverflow.com/q/60418323/3018229.
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.