chore(base): Projektstruktur mit Gitea und Changelog-Support eingerichtet
This commit is contained in:
100
.gitea/workflows/release.yml
Executable file
100
.gitea/workflows/release.yml
Executable file
@ -0,0 +1,100 @@
|
||||
name: Create Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*' # Nur bei Tags wie v1.0.0, v2.0.0
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Enable debug output
|
||||
run: set -x
|
||||
|
||||
- name: Checkout full history including tags
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Show environment variables for debugging
|
||||
run: |
|
||||
echo "GIT_REMOTE_URL=$(git config --get remote.origin.url)"
|
||||
echo "GITHUB_REF=$GITHUB_REF"
|
||||
|
||||
- name: Extract OWNER and REPO from git remote URL
|
||||
id: repo-info
|
||||
run: |
|
||||
REMOTE_URL=$(git config --get remote.origin.url)
|
||||
OWNER=$(echo "$REMOTE_URL" | sed -E 's#.*/([^/]+)/([^/]+)(\.git)?#\1#')
|
||||
REPO=$(echo "$REMOTE_URL" | sed -E 's#.*/([^/]+)/([^/]+)(\.git)?#\2#')
|
||||
echo "OWNER=$OWNER" >> $GITHUB_ENV
|
||||
echo "REPO=$REPO" >> $GITHUB_ENV
|
||||
|
||||
- name: Install git-chglog binary (no Go needed)
|
||||
run: |
|
||||
GIT_CHGLOG_VERSION="0.15.1"
|
||||
curl -sSL "https://github.com/git-chglog/git-chglog/releases/download/v${GIT_CHGLOG_VERSION}/git-chglog_${GIT_CHGLOG_VERSION}_linux_amd64.tar.gz" -o git-chglog.tar.gz
|
||||
tar -xzf git-chglog.tar.gz
|
||||
chmod +x git-chglog
|
||||
sudo mv git-chglog /usr/local/bin/
|
||||
|
||||
- name: Determine current and previous tag
|
||||
id: tags
|
||||
run: |
|
||||
CURRENT_TAG="${GITHUB_REF##*/}"
|
||||
PREVIOUS_TAG=$(git describe --tags --abbrev=0 "${CURRENT_TAG}^" 2>/dev/null || true)
|
||||
|
||||
echo "CURRENT_TAG=$CURRENT_TAG"
|
||||
echo "PREVIOUS_TAG=$PREVIOUS_TAG"
|
||||
|
||||
echo "CURRENT_TAG=$CURRENT_TAG" >> $GITHUB_ENV
|
||||
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
|
||||
|
||||
- name: Generate CHANGELOG.md
|
||||
run: |
|
||||
# Optional: kompletter Changelog (nicht für Release-Body)
|
||||
git-chglog -o CHANGELOG.md
|
||||
|
||||
# Nur der relevante Abschnitt zwischen Tags
|
||||
if [ -n "$PREVIOUS_TAG" ]; then
|
||||
git-chglog "$PREVIOUS_TAG..$CURRENT_TAG" > RELEASE_BODY.md
|
||||
else
|
||||
git-chglog "$CURRENT_TAG" > RELEASE_BODY.md
|
||||
fi
|
||||
|
||||
echo "Release changelog content:"
|
||||
cat RELEASE_BODY.md
|
||||
|
||||
- name: Replace issue references with Markdown links
|
||||
env:
|
||||
OWNER: ${{ env.OWNER }}
|
||||
REPO: ${{ env.REPO }}
|
||||
run: |
|
||||
sed -i -E "s/([^\\[])#([0-9]+)/\1[#\2](https:\/\/dev.ksite.de\/${OWNER}\/${REPO}\/issues\/\2)/g" RELEASE_BODY.md
|
||||
|
||||
- name: Create Gitea Release via API
|
||||
env:
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
OWNER: ${{ env.OWNER }}
|
||||
REPO: ${{ env.REPO }}
|
||||
CURRENT_TAG: ${{ env.CURRENT_TAG }}
|
||||
run: |
|
||||
# Base64-encode und sicher escapen für JSON
|
||||
BODY=$(base64 -w0 RELEASE_BODY.md)
|
||||
DECODED_BODY=$(echo "$BODY" | base64 -d | jq -Rs .)
|
||||
|
||||
echo "Creating release for tag $CURRENT_TAG"
|
||||
|
||||
curl -s -X POST "https://dev.ksite.de/api/v1/repos/${OWNER}/${REPO}/releases" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-d @- <<EOF
|
||||
{
|
||||
"tag_name": "${CURRENT_TAG}",
|
||||
"name": "${REPO} ${CURRENT_TAG}",
|
||||
"body": ${DECODED_BODY}
|
||||
}
|
||||
EOF
|
Reference in New Issue
Block a user