166 lignes
5.6 KiB
YAML
166 lignes
5.6 KiB
YAML
name: "Release"
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Extract version from tag
|
|
id: version
|
|
run: |
|
|
TAG="${GITHUB_REF_NAME}"
|
|
VERSION="${TAG#v}"
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: "10.0.x"
|
|
|
|
- name: Update version in .csproj
|
|
run: |
|
|
CSPROJ="Jellyfin.Plugin.ShareLinks/Jellyfin.Plugin.ShareLinks.csproj"
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
sed -i "s|<Version>.*</Version>|<Version>${VERSION}</Version>|" "$CSPROJ"
|
|
sed -i "s|<AssemblyVersion>.*</AssemblyVersion>|<AssemblyVersion>${VERSION}</AssemblyVersion>|" "$CSPROJ"
|
|
sed -i "s|<FileVersion>.*</FileVersion>|<FileVersion>${VERSION}</FileVersion>|" "$CSPROJ"
|
|
grep -E "Version>" "$CSPROJ"
|
|
|
|
- name: Build
|
|
run: dotnet build Jellyfin.Plugin.ShareLinks -c Release
|
|
|
|
- name: Compute build timestamp
|
|
id: timestamp
|
|
run: |
|
|
TS=$(date -u +"%Y-%m-%dT%H:%M:%S.%6N0Z")
|
|
echo "timestamp=${TS}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Update meta.json
|
|
run: |
|
|
META="Jellyfin.Plugin.ShareLinks/meta.json"
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
TIMESTAMP="${{ steps.timestamp.outputs.timestamp }}"
|
|
jq --arg v "$VERSION" --arg ts "$TIMESTAMP" \
|
|
'.version = $v | .timestamp = $ts' \
|
|
"$META" > "${META}.tmp"
|
|
mv "${META}.tmp" "$META"
|
|
cat "$META"
|
|
|
|
- name: Package release archive
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
OUT="Jellyfin.Plugin.ShareLinks/bin/Release/net9.0"
|
|
STAGING="staging"
|
|
mkdir -p "$STAGING"
|
|
cp "${OUT}/Jellyfin.Plugin.ShareLinks.dll" "$STAGING/"
|
|
cp "Jellyfin.Plugin.ShareLinks/meta.json" "$STAGING/"
|
|
cd "$STAGING"
|
|
zip -r "../sharelinks_${VERSION}.zip" .
|
|
cd ..
|
|
ls -la sharelinks_${VERSION}.zip
|
|
|
|
- name: Compute checksum
|
|
id: checksum
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
CHECKSUM=$(md5sum "sharelinks_${VERSION}.zip" | awk '{print $1}')
|
|
echo "checksum=${CHECKSUM}" >> "$GITHUB_OUTPUT"
|
|
echo "MD5: ${CHECKSUM}"
|
|
|
|
- name: Update manifest.json
|
|
run: |
|
|
MANIFEST="manifest.json"
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
TIMESTAMP="${{ steps.timestamp.outputs.timestamp }}"
|
|
CHECKSUM="${{ steps.checksum.outputs.checksum }}"
|
|
|
|
jq \
|
|
--arg version "$VERSION" \
|
|
--arg timestamp "$TIMESTAMP" \
|
|
--arg checksum "$CHECKSUM" \
|
|
'
|
|
.[0].versions |= (
|
|
if any(.[]; .version == $version) then
|
|
|
|
map(
|
|
if .version == $version then
|
|
if has("changelog") | not then
|
|
.changelog = ""
|
|
else
|
|
.
|
|
end
|
|
| if has("targetAbi") then
|
|
.targetAbi = "10.11.0.0"
|
|
else
|
|
.
|
|
end
|
|
| if has("sourceUrl") then
|
|
.sourceUrl = "https://git.celjim.fr/public/jellyfin-plugin-sharelinks/releases/download/v\($version)/sharelinks_\($version).zip"
|
|
else
|
|
.
|
|
end
|
|
| if has("checksum") then
|
|
.checksum = $checksum
|
|
else
|
|
.
|
|
end
|
|
| if has("timestamp") then
|
|
.timestamp = $timestamp
|
|
else
|
|
.
|
|
end
|
|
else
|
|
.
|
|
end
|
|
)
|
|
|
|
else
|
|
|
|
[{
|
|
"version": $version,
|
|
"changelog": "",
|
|
"targetAbi": "10.11.0.0",
|
|
"sourceUrl": "https://git.celjim.fr/public/jellyfin-plugin-sharelinks/releases/download/v\($version)/sharelinks_\($version).zip",
|
|
"checksum": $checksum,
|
|
"timestamp": $timestamp
|
|
}] + .
|
|
|
|
end
|
|
)
|
|
' "$MANIFEST" > "${MANIFEST}.tmp"
|
|
|
|
mv "${MANIFEST}.tmp" "$MANIFEST"
|
|
|
|
cat "$MANIFEST"
|
|
|
|
- name: Commit and push manifest
|
|
run: |
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@celjim.fr"
|
|
|
|
git add manifest.json Jellyfin.Plugin.ShareLinks/meta.json Jellyfin.Plugin.ShareLinks/Jellyfin.Plugin.ShareLinks.csproj
|
|
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit"
|
|
exit 0
|
|
fi
|
|
|
|
git commit -m "Update manifest/meta for v${{ steps.version.outputs.version }}"
|
|
git push origin HEAD:${{ github.event.repository.default_branch }}
|
|
|
|
- name: Publish Gitea release
|
|
uses: https://gitea.com/actions/gitea-release-action@main
|
|
with:
|
|
files: |-
|
|
sharelinks_${{ steps.version.outputs.version }}.zip
|
|
token: "${{ secrets.RELEASE_TOKEN }}"
|