ci: release automatically when the version changes

A push to main whose build.yaml version has no tag yet creates the tag and
a release with the plugin zip and an updated repository manifest.
This commit is contained in:
2026-11-13 18:16:22 +01:00
parent 383b90d9b8
commit 7f357cb46c
4 changed files with 86 additions and 29 deletions
+72 -19
View File
@@ -3,18 +3,56 @@ name: Build
on: on:
push: push:
branches: [main] branches: [main]
tags: ['v*']
pull_request: pull_request:
workflow_dispatch:
permissions: permissions:
contents: read contents: read
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: false
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
release: ${{ steps.version.outputs.release }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
# build.yaml is the source of truth for the plugin version.
# A version without a matching tag on main gets released.
- name: Read version
id: version
run: |
version="$(sed -n 's/^version:[[:space:]]*"\{0,1\}\([0-9][0-9.]*\)"\{0,1\}[[:space:]]*$/\1/p' build.yaml)"
if [ -z "$version" ]; then
echo "::error file=build.yaml::could not read the version"
exit 1
fi
props="$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' Directory.Build.props)"
if [ "$props" != "$version" ]; then
echo "::error::build.yaml says $version but Directory.Build.props says $props"
exit 1
fi
tag="v$version"
release=false
if [ "$GITHUB_EVENT_NAME" != "pull_request" ] && [ "$GITHUB_REF" = "refs/heads/main" ]; then
if [ -z "$(git ls-remote --tags origin "refs/tags/$tag")" ]; then
release=true
fi
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "release=$release" >> "$GITHUB_OUTPUT"
echo "Version $version, tag $tag, release: $release"
- uses: actions/setup-dotnet@v4 - uses: actions/setup-dotnet@v4
with: with:
dotnet-version: 9.0.x dotnet-version: 9.0.x
@@ -33,42 +71,57 @@ jobs:
run: | run: |
pip install jprm pip install jprm
mkdir -p artifacts mkdir -p artifacts
if [ "$GITHUB_REF_TYPE" = "tag" ]; then jprm plugin build . --output artifacts --version "${{ steps.version.outputs.version }}"
# v1.2.3 -> 1.2.3.0, Jellyfin wants four parts
version="${GITHUB_REF_NAME#v}"
case "$version" in *.*.*.*) ;; *) version="$version.0" ;; esac
jprm plugin build . --output artifacts --version "$version"
else
jprm plugin build . --output artifacts
fi
ls -l artifacts ls -l artifacts
# The repository manifest travels with the releases: take the one from the
# latest release, add this version, and publish it again as an asset.
- name: Update repository manifest
if: steps.version.outputs.release == 'true'
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: |
mkdir -p repo
if ! gh release download --repo "$GITHUB_REPOSITORY" --pattern manifest.json --dir repo 2>/dev/null; then
jprm repo init repo
fi
zip="$(ls artifacts/*.zip)"
jprm repo add \
--plugin-url "https://github.com/$GITHUB_REPOSITORY/releases/download/$TAG/$(basename "$zip")" \
repo "$zip"
cp repo/manifest.json artifacts/manifest.json
cat artifacts/manifest.json
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: plugin name: plugin
path: artifacts/*.zip path: |
artifacts/*.zip
artifacts/manifest.json
if-no-files-found: error if-no-files-found: error
release: release:
if: github.ref_type == 'tag' if: needs.build.outputs.release == 'true'
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write
steps: steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4 - uses: actions/download-artifact@v4
with: with:
name: plugin name: plugin
path: artifacts path: artifacts
- name: Attach zip to the release - name: Create tag and release
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }} TAG: ${{ needs.build.outputs.tag }}
run: | run: |
md5sum artifacts/*.zip sed -n '/^changelog:/,$p' build.yaml | sed '1d; s/^ //' > notes.md
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then gh release create "$TAG" artifacts/*.zip artifacts/manifest.json \
gh release upload "$GITHUB_REF_NAME" artifacts/*.zip --clobber --target "$GITHUB_SHA" \
else --title "Herald ${TAG#v}" \
gh release create "$GITHUB_REF_NAME" artifacts/*.zip --title "$GITHUB_REF_NAME" --generate-notes --notes-file notes.md
fi
+1
View File
@@ -7,6 +7,7 @@ One line per decision, with the reason.
- Target Jellyfin **10.11.11** (`Jellyfin.Controller` / `Jellyfin.Model` 10.11.11, `net9.0`): it is the last 10.11 release on NuGet; the nuspec of that package lists `net9.0` as its only framework. Versions live in `Directory.Build.props`. - Target Jellyfin **10.11.11** (`Jellyfin.Controller` / `Jellyfin.Model` 10.11.11, `net9.0`): it is the last 10.11 release on NuGet; the nuspec of that package lists `net9.0` as its only framework. Versions live in `Directory.Build.props`.
- `targetAbi` is `10.11.0.0`: the plugin only uses APIs that exist across 10.11, so it should not be pinned to the patch release it was compiled against. - `targetAbi` is `10.11.0.0`: the plugin only uses APIs that exist across 10.11, so it should not be pinned to the patch release it was compiled against.
- Removed the template's `.github` workflows and Renovate preset: they call reusable workflows and secrets of the Jellyfin organisation and cannot run elsewhere. Replaced by one self-contained workflow. - Removed the template's `.github` workflows and Renovate preset: they call reusable workflows and secrets of the Jellyfin organisation and cannot run elsewhere. Replaced by one self-contained workflow.
- Releases are driven by the version, not by hand-made tags: a push to `main` whose `build.yaml` version has no `v<version>` tag is tagged and released by the workflow. The plugin repository manifest is a release asset carried forward from release to release, so nothing has to be committed back by CI.
- Removed the template's `.vscode` folder: it assumes a local checkout of the Jellyfin server and web client next to the repo. - Removed the template's `.vscode` folder: it assumes a local checkout of the Jellyfin server and web client next to the repo.
- No analyzer warnings are suppressed project-wide. The only suppressions are three `CA2100` pragmas in `Storage/` where a command text is assigned from a constant string, which the analyzer cannot see through a helper. - No analyzer warnings are suppressed project-wide. The only suppressions are three `CA2100` pragmas in `Storage/` where a command text is assigned from a constant string, which the analyzer cannot see through a helper.
- The test project does not reference the StyleCop/`AllEnabledByDefault` analyzer set: XML docs and naming rules on test methods add noise without value. It still builds with warnings as errors. - The test project does not reference the StyleCop/`AllEnabledByDefault` analyzer set: XML docs and naming rules on test methods add noise without value. It still builds with warnings as errors.
+12 -7
View File
@@ -19,9 +19,8 @@ Watch-time stats are collected on the server and cover all clients.
### From a plugin repository ### From a plugin repository
1. Host the plugin zip and a `manifest.json` somewhere your server can reach (see [Hosting your own repository](#hosting-your-own-repository)). 1. In Jellyfin: **Dashboard → Plugins → Manage Repositories → New Repository**, enter `https://github.com/JoshiCodes/jellyfin-Herald/releases/latest/download/manifest.json`.
2. In Jellyfin: **Dashboard → Plugins → Manage Repositories → New Repository**, enter the URL of your `manifest.json`. 2. Install **Herald** from the catalogue and restart the server.
3. Install **Herald** from the catalogue and restart the server.
### Manually ### Manually
@@ -178,18 +177,24 @@ jprm plugin build . --output artifacts
This writes `artifacts/herald_<version>.zip`. The Jellyfin version, target framework and SQLite version are set in `Directory.Build.props`; `targetAbi` is in `build.yaml`. This writes `artifacts/herald_<version>.zip`. The Jellyfin version, target framework and SQLite version are set in `Directory.Build.props`; `targetAbi` is in `build.yaml`.
Pushing a tag such as `v1.0.0` runs the GitHub Actions workflow, which builds, tests, packages and attaches the zip to the release of that tag. ## Releasing
The version lives in `build.yaml` (`version`) and `Directory.Build.props` (`Version`, `AssemblyVersion`, `FileVersion`); keep them equal, the workflow fails otherwise. Put the release notes in `changelog` in `build.yaml`.
Every push to `main` builds and tests. If the version has no `v<version>` tag yet, the workflow also creates that tag and a GitHub release with two assets: the plugin zip and a `manifest.json` that lists this and all earlier releases. So a release is: bump the version, push.
## Hosting your own repository ## Hosting your own repository
`manifest.json` in this repository is a sample. Replace the checksum (MD5 of the zip) and the timestamp, or let jprm write it: The `manifest.json` attached to the latest release is a complete plugin repository; the URL under [Installation](#installation) always points at it. The `manifest.json` in the source tree is only a sample of the format.
To host it elsewhere, build the manifest yourself:
```sh ```sh
jprm repo init ./repo jprm repo init ./repo
jprm repo add --plugin-url https://github.com/JoshiCodes/jellyfin-Herald/releases/download/v1.0.0/herald_1.0.0.0.zip ./repo artifacts/herald_1.0.0.0.zip jprm repo add --plugin-url https://example.org/herald/herald_1.0.0.0.zip ./repo artifacts/herald_1.0.0.0.zip
``` ```
Serve the resulting `manifest.json` over HTTP(S) and add its URL in Jellyfin as described above. Serve the resulting `manifest.json` and the zip over HTTP(S) and add the manifest URL in Jellyfin.
## License ## License
+1 -3
View File
@@ -8,7 +8,7 @@
- **Client injection**: registered with the File Transformation plugin by reflection at startup; a warning is logged when that plugin is missing. Manual fallbacks are documented. - **Client injection**: registered with the File Transformation plugin by reflection at startup; a warning is logged when that plugin is missing. Manual fallbacks are documented.
- **Watch-time stats**: playback start/progress/stop events are turned into daily per-user aggregates; `GET /Herald/Stats` and a sortable "Stats" tab show them; a daily scheduled task drops rows older than 90 days. - **Watch-time stats**: playback start/progress/stop events are turned into daily per-user aggregates; `GET /Herald/Stats` and a sortable "Stats" tab show them; a daily scheduled task drops rows older than 90 days.
- **Storage**: one SQLite database in Jellyfin's data directory, using the `Microsoft.Data.Sqlite` that the server ships. Versioned migrations, serialized writes. - **Storage**: one SQLite database in Jellyfin's data directory, using the `Microsoft.Data.Sqlite` that the server ships. Versioned migrations, serialized writes.
- **Project plumbing**: xUnit test project (56 tests), `build.yaml` for jprm, a GitHub Actions workflow (build, test, package, attach zip to the release on tag push), a sample `manifest.json`, `README.md`, `DECISIONS.md`. - **Project plumbing**: xUnit test project (56 tests), `build.yaml` for jprm, a GitHub Actions workflow (build, test, package; tags and releases automatically when the version changes), a sample `manifest.json`, `README.md`, `DECISIONS.md`.
## What was verified, and how ## What was verified, and how
@@ -35,7 +35,6 @@ Two bugs were found and fixed through the container test: the unanchored File Tr
- File Transformation was tested in version 3.0.3.0 only. Its registration API is found by reflection, so a rename on their side turns into the logged warning, not a crash. - File Transformation was tested in version 3.0.3.0 only. Its registration API is found by reflection, so a rename on their side turns into the logged warning, not a crash.
- Stats were verified with simulated reports, not with a real player. The systematic inaccuracies are listed in the README. - Stats were verified with simulated reports, not with a real player. The systematic inaccuracies are listed in the README.
- The UI is English only. - The UI is English only.
- The release part of the GitHub workflow (tag push) has not run yet.
- Must-accept is a record of consent, not an access gate: nothing on the server is blocked for users who have not accepted. - Must-accept is a record of consent, not an access gate: nothing on the server is blocked for users who have not accepted.
## Environment notes ## Environment notes
@@ -46,6 +45,5 @@ Two bugs were found and fixed through the container test: the unanchored File Tr
## Next steps ## Next steps
- Push a `v1.0.0` tag, check the release workflow, and put the real checksum and timestamp into `manifest.json`.
- Try the popup on the themes and devices your users actually have. - Try the popup on the themes and devices your users actually have.
- Optional: start/end dates for notices, a history of earlier rounds in the responses view, translations. - Optional: start/end dates for notices, a history of earlier rounds in the responses view, translations.