# 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) curl -fsS -X POST -H "Authorization: token $TOKEN" -F "attachment=@$ZIP" "$API/releases/$ID/assets?name=$ZIP" >/dev/null # Jellyfin only installs from URLs ending in .zip, so use the release download path # (the API's browser_download_url is /attachments/). URL="${{ gitea.server_url }}/${{ gitea.repository }}/releases/download/${{ gitea.ref_name }}/$ZIP" curl -fsSI "$URL" >/dev/null 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"