GPL-3.0-or-later, Gitea CI and release pipeline
- License the project under GPL-3.0-or-later (LICENSE + SPDX headers). - CI workflow builds every push and pull request and checks manifest.json. - Release workflow: an annotated v* tag builds that version, creates a Gitea release with the zip attached and adds it to manifest.json. - Release zips now live in Gitea releases instead of dist/; build.sh is a local test build only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d456442e6
commit
7398e590e6
15 files changed
+823
-55
No files matched your search
@@ -0,0 +1,75 @@
|
||||
# Release: push an annotated tag like v1.0.3.0 (its message becomes the release notes).
|
||||
# git tag -a v1.0.3.0 -m "What changed" && git push origin v1.0.3.0
|
||||
# Builds that version, creates the Gitea release with the zip attached, and adds the
|
||||
# version to manifest.json on master so Jellyfin servers using the repository see it.
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
env:
|
||||
TARGET_ABI: "12.2.0.0"
|
||||
PROJECT: src/Jellyfin.Plugin.LightsOffTimer/Jellyfin.Plugin.LightsOffTimer.csproj
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: dotnet
|
||||
steps:
|
||||
- name: Checkout tag
|
||||
run: |
|
||||
git clone -q "${{ gitea.server_url }}/${{ gitea.repository }}.git" .
|
||||
git checkout -q "${{ gitea.ref_name }}"
|
||||
apt-get -qq update >/dev/null && apt-get -qq install -y jq zip >/dev/null
|
||||
|
||||
- name: Version
|
||||
id: v
|
||||
run: |
|
||||
TAG="${{ gitea.ref_name }}"
|
||||
VERSION="${TAG#v}"
|
||||
echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' || { echo "Tag must look like v1.2.3.4, got $TAG"; exit 1; }
|
||||
NOTES=$(git tag -l --format='%(contents)' "$TAG")
|
||||
[ -n "$NOTES" ] || NOTES=$(git log -1 --format=%s "$TAG")
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
printf '%s' "$NOTES" > notes.txt
|
||||
echo "Releasing $VERSION"; cat notes.txt
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
V="${{ steps.v.outputs.version }}"
|
||||
dotnet publish "$PROJECT" -c Release -o out --nologo \
|
||||
-p:Version="$V" -p:AssemblyVersion="$V" -p:FileVersion="$V"
|
||||
ZIP="lightsofftimer_$V.zip"
|
||||
zip -j -q "$ZIP" out/Jellyfin.Plugin.LightsOffTimer.dll
|
||||
md5sum "$ZIP" | cut -d' ' -f1 > md5.txt
|
||||
echo "$ZIP md5 $(cat md5.txt)"
|
||||
|
||||
- name: Create Gitea release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
V="${{ steps.v.outputs.version }}"; ZIP="lightsofftimer_$V.zip"
|
||||
API="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
|
||||
BODY=$(jq -n --arg tag "${{ gitea.ref_name }}" --arg name "Lights Off Timer $V" --rawfile notes notes.txt \
|
||||
--arg abi "$TARGET_ABI" --arg md5 "$(cat md5.txt)" \
|
||||
'{tag_name: $tag, name: $name, body: ($notes + "\n\n---\nJellyfin targetAbi `" + $abi + "` · MD5 `" + $md5 + "`")}')
|
||||
ID=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" -d "$BODY" "$API/releases" | jq -r .id)
|
||||
URL=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -F "attachment=@$ZIP" "$API/releases/$ID/assets?name=$ZIP" | jq -r .browser_download_url)
|
||||
echo "release $ID asset $URL"
|
||||
echo "$URL" > asset_url.txt
|
||||
|
||||
- name: Add version to manifest.json
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
V="${{ steps.v.outputs.version }}"
|
||||
git fetch -q origin master && git checkout -q -B master origin/master
|
||||
jq --arg v "$V" --arg abi "$TARGET_ABI" --arg url "$(cat asset_url.txt)" --arg md5 "$(cat md5.txt)" \
|
||||
--rawfile notes notes.txt --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
'.[0].versions = ([{version: $v, changelog: $notes, targetAbi: $abi, sourceUrl: $url, checksum: $md5, timestamp: $ts}]
|
||||
+ (.[0].versions | map(select(.version != $v))))' manifest.json > manifest.new
|
||||
mv manifest.new manifest.json
|
||||
git -c user.name="Gitea Actions" -c user.email="actions@git.piskot.si" commit -q -am "Release $V [skip ci]"
|
||||
HOST="${{ gitea.server_url }}"; HOST="${HOST#https://}"
|
||||
git push -q "https://oauth2:${TOKEN}@${HOST}/${{ gitea.repository }}.git" master
|
||||
echo "manifest.json updated for $V"
|
||||
Reference in new issue
Block a user