fix:: Plugin Erste Tests
All checks were successful
Create Release PR / Create Release PR (push) Successful in 17s
All checks were successful
Create Release PR / Create Release PR (push) Successful in 17s
This commit is contained in:
123
.gitea/workflows/build-publish.yaml
Normal file
123
.gitea/workflows/build-publish.yaml
Normal file
@@ -0,0 +1,123 @@
|
||||
name: Build and Publish Plugin
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build Plugin + Update Manifest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GT_TOKEN }}
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Set version from tag
|
||||
id: vars
|
||||
run: |
|
||||
TAG="${{ gitea.event.release.tag_name }}"
|
||||
VERSION="${TAG#v}" # Remove 'v' prefix
|
||||
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||
echo "TAG=$TAG" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Build plugin
|
||||
run: |
|
||||
dotnet publish Jellyfin.Plugin.SmartNotify/Jellyfin.Plugin.SmartNotify.csproj \
|
||||
--configuration Release \
|
||||
--output ./publish \
|
||||
-p:Version=${VERSION}.0
|
||||
|
||||
- name: Create plugin ZIP
|
||||
run: |
|
||||
cd publish
|
||||
zip -r ../smartnotify_${VERSION}.zip .
|
||||
cd ..
|
||||
|
||||
# Calculate MD5 checksum
|
||||
CHECKSUM=$(md5sum smartnotify_${VERSION}.zip | cut -d' ' -f1)
|
||||
echo "CHECKSUM=$CHECKSUM" >> "$GITHUB_ENV"
|
||||
echo "Checksum: $CHECKSUM"
|
||||
|
||||
- name: Upload ZIP to Release
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
run: |
|
||||
# Get release ID
|
||||
RELEASE_ID=$(curl -s "https://git.tdpi.dev/api/v1/repos/TDPI/jellyfin-plugin-smartnotify/releases/tags/${TAG}" \
|
||||
-H "Authorization: token $GIT_TOKEN" | jq -r '.id')
|
||||
|
||||
# Upload asset
|
||||
curl -X POST "https://git.tdpi.dev/api/v1/repos/TDPI/jellyfin-plugin-smartnotify/releases/${RELEASE_ID}/assets?name=smartnotify_${VERSION}.zip" \
|
||||
-H "Authorization: token $GIT_TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @smartnotify_${VERSION}.zip
|
||||
|
||||
- name: Update manifest.json
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
run: |
|
||||
# Get changelog for this version
|
||||
CHANGELOG=$(awk '/^## '"$VERSION"'/{flag=1} /^## / && flag && !/^## '"$VERSION"'/{exit} flag' CHANGELOG.md | tail -n +2)
|
||||
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
# Update manifest.json with new version
|
||||
python3 << EOF
|
||||
import json
|
||||
|
||||
with open('manifest.json', 'r') as f:
|
||||
manifest = json.load(f)
|
||||
|
||||
new_version = {
|
||||
"version": "${VERSION}.0",
|
||||
"changelog": """${CHANGELOG}""".strip(),
|
||||
"targetAbi": "10.11.0.0",
|
||||
"sourceUrl": "https://git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify/releases/download/${TAG}/smartnotify_${VERSION}.zip",
|
||||
"checksum": "${CHECKSUM}",
|
||||
"timestamp": "${TIMESTAMP}"
|
||||
}
|
||||
|
||||
# Insert at beginning of versions array
|
||||
manifest[0]["versions"].insert(0, new_version)
|
||||
|
||||
# Keep only last 10 versions
|
||||
manifest[0]["versions"] = manifest[0]["versions"][:10]
|
||||
|
||||
with open('manifest.json', 'w') as f:
|
||||
json.dump(manifest, f, indent=2, ensure_ascii=False)
|
||||
|
||||
print("Manifest updated successfully")
|
||||
EOF
|
||||
|
||||
# Commit and push manifest
|
||||
git config user.name "Gitea Actions"
|
||||
git config user.email "actions@git.tdpi.dev"
|
||||
git add manifest.json
|
||||
git commit -m "chore: update manifest for ${TAG}"
|
||||
git push https://x-access-token:${GIT_TOKEN}@git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify.git HEAD:main
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Version:** ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Checksum:** ${CHECKSUM}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Target ABI:** 10.11.0.0" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Manifest URL" >> $GITHUB_STEP_SUMMARY
|
||||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "https://git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify/raw/branch/main/manifest.json" >> $GITHUB_STEP_SUMMARY
|
||||
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
||||
209
.gitea/workflows/create-release-pr.yaml
Normal file
209
.gitea/workflows/create-release-pr.yaml
Normal file
@@ -0,0 +1,209 @@
|
||||
name: Create Release PR
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
release-pr:
|
||||
name: Create Release PR
|
||||
if: "!contains(gitea.event.head_commit.message, 'chore(main): release')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GT_TOKEN }}
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install gitpython packaging
|
||||
|
||||
- name: Create Release PR
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
REPO: "TDPI/jellyfin-plugin-smartnotify"
|
||||
run: |
|
||||
python3 << 'EOF'
|
||||
import re
|
||||
import subprocess
|
||||
import json
|
||||
from packaging import version as pkg_version
|
||||
|
||||
def get_commits_since_last_tag():
|
||||
try:
|
||||
last_tag = subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0'], text=True).strip()
|
||||
commits = subprocess.check_output(['git', 'log', f'{last_tag}..HEAD', '--pretty=format:%s'], text=True).strip().split('\n')
|
||||
except:
|
||||
commits = subprocess.check_output(['git', 'log', '--pretty=format:%s'], text=True).strip().split('\n')
|
||||
return [c for c in commits if c]
|
||||
|
||||
def analyze_commits(commits):
|
||||
has_feat = any(c.startswith('feat') for c in commits)
|
||||
has_fix = any(c.startswith('fix') for c in commits)
|
||||
has_breaking = any('!' in c.split(':')[0] or 'BREAKING CHANGE' in c for c in commits)
|
||||
has_chore = any(c.startswith('chore') for c in commits)
|
||||
return has_breaking, has_feat, has_fix, has_chore
|
||||
|
||||
def get_current_version():
|
||||
try:
|
||||
with open('.release-please-manifest.json', 'r') as f:
|
||||
manifest = json.load(f)
|
||||
return manifest.get('.', '1.0.0')
|
||||
except:
|
||||
return '1.0.0'
|
||||
|
||||
def bump_version(current, has_breaking, has_feat, has_fix, has_chore):
|
||||
v = pkg_version.parse(current)
|
||||
major, minor, patch = v.major, v.minor, v.micro
|
||||
|
||||
if has_breaking:
|
||||
return f'{major + 1}.0.0'
|
||||
elif has_feat:
|
||||
return f'{major}.{minor + 1}.0'
|
||||
elif has_fix or has_chore:
|
||||
return f'{major}.{minor}.{patch + 1}'
|
||||
return None
|
||||
|
||||
commits = get_commits_since_last_tag()
|
||||
if not commits or commits == ['']:
|
||||
print('No commits to release')
|
||||
exit(0)
|
||||
|
||||
has_breaking, has_feat, has_fix, has_chore = analyze_commits(commits)
|
||||
|
||||
if not (has_breaking or has_feat or has_fix or has_chore):
|
||||
print('No release-worthy commits')
|
||||
exit(0)
|
||||
|
||||
current_version = get_current_version()
|
||||
new_version = bump_version(current_version, has_breaking, has_feat, has_fix, has_chore)
|
||||
|
||||
if not new_version:
|
||||
print('No version bump needed')
|
||||
exit(0)
|
||||
|
||||
print(f'Bumping version from {current_version} to {new_version}')
|
||||
|
||||
# Update version in manifest
|
||||
with open('.release-please-manifest.json', 'r') as f:
|
||||
manifest = json.load(f)
|
||||
|
||||
manifest['.'] = new_version
|
||||
|
||||
with open('.release-please-manifest.json', 'w') as f:
|
||||
json.dump(manifest, f, indent=2)
|
||||
|
||||
# Update version in .csproj
|
||||
csproj_path = 'Jellyfin.Plugin.SmartNotify/Jellyfin.Plugin.SmartNotify.csproj'
|
||||
with open(csproj_path, 'r') as f:
|
||||
csproj = f.read()
|
||||
|
||||
csproj = re.sub(r'<AssemblyVersion>.*?</AssemblyVersion>', f'<AssemblyVersion>{new_version}.0</AssemblyVersion>', csproj)
|
||||
csproj = re.sub(r'<FileVersion>.*?</FileVersion>', f'<FileVersion>{new_version}.0</FileVersion>', csproj)
|
||||
|
||||
with open(csproj_path, 'w') as f:
|
||||
f.write(csproj)
|
||||
|
||||
# Generate CHANGELOG
|
||||
changelog_entry = f'## {new_version} ({subprocess.check_output(["date", "+%Y-%m-%d"], text=True).strip()})\n\n'
|
||||
|
||||
if has_breaking:
|
||||
changelog_entry += '### BREAKING CHANGES\n\n'
|
||||
for c in commits:
|
||||
if '!' in c.split(':')[0] or 'BREAKING CHANGE' in c:
|
||||
changelog_entry += f'* {c}\n'
|
||||
changelog_entry += '\n'
|
||||
|
||||
if has_feat:
|
||||
changelog_entry += '### Features\n\n'
|
||||
for c in commits:
|
||||
if c.startswith('feat'):
|
||||
changelog_entry += f'* {c}\n'
|
||||
changelog_entry += '\n'
|
||||
|
||||
if has_fix:
|
||||
changelog_entry += '### Bug Fixes\n\n'
|
||||
for c in commits:
|
||||
if c.startswith('fix'):
|
||||
changelog_entry += f'* {c}\n'
|
||||
changelog_entry += '\n'
|
||||
|
||||
if has_chore:
|
||||
changelog_entry += '### Chores\n\n'
|
||||
for c in commits:
|
||||
if c.startswith('chore'):
|
||||
changelog_entry += f'* {c}\n'
|
||||
changelog_entry += '\n'
|
||||
|
||||
try:
|
||||
with open('CHANGELOG.md', 'r') as f:
|
||||
old_changelog = f.read()
|
||||
except:
|
||||
old_changelog = '# Changelog\n\n'
|
||||
|
||||
with open('CHANGELOG.md', 'w') as f:
|
||||
f.write('# Changelog\n\n' + changelog_entry + '\n' + old_changelog.replace('# Changelog\n', '').lstrip())
|
||||
|
||||
subprocess.run(['git', 'config', 'user.name', 'Gitea Actions'])
|
||||
subprocess.run(['git', 'config', 'user.email', 'actions@git.tdpi.dev'])
|
||||
subprocess.run(['git', 'add', '.release-please-manifest.json', 'CHANGELOG.md', csproj_path])
|
||||
subprocess.run(['git', 'commit', '-m', f'chore(main): release {new_version}'])
|
||||
|
||||
with open('/tmp/new_version', 'w') as f:
|
||||
f.write(new_version)
|
||||
EOF
|
||||
|
||||
NEW_VERSION=$(cat /tmp/new_version 2>/dev/null || echo "")
|
||||
if [ -z "$NEW_VERSION" ]; then
|
||||
echo "No version bump needed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
BRANCH_NAME="release-please--branches--main"
|
||||
|
||||
# Push changes
|
||||
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
|
||||
git push -f origin HEAD:"$BRANCH_NAME"
|
||||
PR_EXISTS=true
|
||||
else
|
||||
git push origin HEAD:"$BRANCH_NAME"
|
||||
PR_EXISTS=false
|
||||
fi
|
||||
|
||||
# Get changelog content for PR body
|
||||
CHANGELOG_CONTENT=$(awk '/^## '"$NEW_VERSION"'/{flag=1} /^## / && flag && !/^## '"$NEW_VERSION"'/{exit} flag' CHANGELOG.md | jq -Rs .)
|
||||
|
||||
if [ "$PR_EXISTS" = true ]; then
|
||||
PR_NUMBER=$(curl -s "https://git.tdpi.dev/api/v1/repos/$REPO/pulls?state=open&head=$BRANCH_NAME" \
|
||||
-H "Authorization: token $GIT_TOKEN" | jq -r '.[0].number')
|
||||
|
||||
if [ "$PR_NUMBER" != "null" ]; then
|
||||
curl -X PATCH "https://git.tdpi.dev/api/v1/repos/$REPO/pulls/$PR_NUMBER" \
|
||||
-H "Authorization: token $GIT_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"chore(main): release $NEW_VERSION\",
|
||||
\"body\": $CHANGELOG_CONTENT
|
||||
}"
|
||||
fi
|
||||
else
|
||||
curl -X POST "https://git.tdpi.dev/api/v1/repos/$REPO/pulls" \
|
||||
-H "Authorization: token $GIT_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"chore(main): release $NEW_VERSION\",
|
||||
\"head\": \"$BRANCH_NAME\",
|
||||
\"base\": \"main\",
|
||||
\"body\": $CHANGELOG_CONTENT
|
||||
}"
|
||||
fi
|
||||
60
.gitea/workflows/create-release.yaml
Normal file
60
.gitea/workflows/create-release.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
name: Create Release
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
publish-release:
|
||||
name: Publish Release
|
||||
if: gitea.event_name == 'pull_request' && gitea.event.pull_request.merged == true && startsWith(gitea.event.pull_request.head.ref, 'release-please')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GT_TOKEN }}
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(jq -r '."."' .release-please-manifest.json)
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Git Tag
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
run: |
|
||||
git config user.name "Gitea Actions"
|
||||
git config user.email "actions@git.tdpi.dev"
|
||||
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
|
||||
git push https://x-access-token:${GIT_TOKEN}@git.tdpi.dev/TDPI/jellyfin-plugin-smartnotify.git "v${{ steps.version.outputs.version }}"
|
||||
|
||||
- name: Create Release
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
CHANGELOG=$(awk '/^## '"$VERSION"'/{flag=1} /^## / && flag && !/^## '"$VERSION"'/{exit} flag' CHANGELOG.md)
|
||||
|
||||
PAYLOAD=$(jq -n \
|
||||
--arg tag "v$VERSION" \
|
||||
--arg name "v$VERSION" \
|
||||
--arg body "$CHANGELOG" \
|
||||
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')
|
||||
|
||||
curl -X POST "https://git.tdpi.dev/api/v1/repos/TDPI/jellyfin-plugin-smartnotify/releases" \
|
||||
-H "Authorization: token $GIT_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$PAYLOAD"
|
||||
|
||||
- name: Cleanup Release Branch
|
||||
env:
|
||||
GIT_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
run: |
|
||||
git push --delete origin release-please--branches--main || true
|
||||
Reference in New Issue
Block a user