Add nightly job
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: 'Latest Release'
|
||||
name: 'Nightly Build'
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -7,9 +7,10 @@ on:
|
||||
paths-ignore:
|
||||
- '**/*.md'
|
||||
- 'manifest.json'
|
||||
- 'manifest-nightly.json'
|
||||
|
||||
jobs:
|
||||
latest-release:
|
||||
nightly-build:
|
||||
runs-on: linux/amd64
|
||||
container:
|
||||
image: gitea.tourolle.paris/dtourolle/srfplay-builder:latest
|
||||
@@ -20,6 +21,24 @@ jobs:
|
||||
with:
|
||||
path: build-${{ github.run_id }}
|
||||
|
||||
- name: Compute nightly version
|
||||
id: version
|
||||
run: |
|
||||
# Date-based nightly version: 1.0.<YYYYMMDD>.<run_number>
|
||||
# The run_number suffix keeps multiple builds on the same day
|
||||
# monotonically increasing so Jellyfin always offers the newest.
|
||||
DATE=$(date -u +"%Y%m%d")
|
||||
VERSION="1.0.${DATE}.${{ github.run_number }}"
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "Nightly version: ${VERSION}"
|
||||
|
||||
- name: Set build version
|
||||
working-directory: build-${{ github.run_id }}
|
||||
run: |
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
sed -i "s/^version:.*/version: \"${VERSION}\"/" build.yaml
|
||||
cat build.yaml
|
||||
|
||||
- name: Restore dependencies
|
||||
working-directory: build-${{ github.run_id }}
|
||||
run: dotnet restore Jellyfin.Plugin.SRFPlay.sln
|
||||
@@ -52,7 +71,7 @@ jobs:
|
||||
echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT
|
||||
echo "Checksum: ${CHECKSUM}"
|
||||
|
||||
- name: Delete existing latest release
|
||||
- name: Delete existing nightly release
|
||||
working-directory: build-${{ github.run_id }}
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -71,7 +90,7 @@ jobs:
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/tags/${TAG}" | jq -r '.id')
|
||||
|
||||
echo "Deleting existing latest release (ID: ${RELEASE_ID})..."
|
||||
echo "Deleting existing nightly release (ID: ${RELEASE_ID})..."
|
||||
curl -s -X DELETE \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}"
|
||||
@@ -81,7 +100,7 @@ jobs:
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/tags/${TAG}" || true
|
||||
|
||||
- name: Create latest release
|
||||
- name: Create nightly release
|
||||
working-directory: build-${{ github.run_id }}
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -89,12 +108,14 @@ jobs:
|
||||
REPO_OWNER="${{ github.repository_owner }}"
|
||||
REPO_NAME="${{ github.event.repository.name }}"
|
||||
GITEA_URL="${{ github.server_url }}"
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
||||
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases" \
|
||||
-d "$(jq -n --arg tag "latest" --arg name "Latest Build" --arg body "SRFPlay Jellyfin Plugin latest build from master." '{tag_name: $tag, name: $name, body: $body, target_commitish: "master", draft: false, prerelease: true}')")
|
||||
-d "$(jq -n --arg tag "latest" --arg name "Nightly Build ${VERSION}" --arg body "SRFPlay Jellyfin Plugin nightly build ${VERSION} from master (${SHORT_SHA})." '{tag_name: $tag, name: $name, body: $body, target_commitish: "master", draft: false, prerelease: true}')")
|
||||
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||
@@ -124,9 +145,9 @@ jobs:
|
||||
--data-binary "@build.yaml" \
|
||||
"${GITEA_URL}/api/v1/repos/${REPO_OWNER}/${REPO_NAME}/releases/${RELEASE_ID}/assets?name=build.yaml"
|
||||
|
||||
echo "Latest release updated successfully!"
|
||||
echo "Nightly release updated successfully!"
|
||||
|
||||
- name: Update manifest.json
|
||||
- name: Update manifest-nightly.json
|
||||
working-directory: build-${{ github.run_id }}
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -134,6 +155,7 @@ jobs:
|
||||
REPO_OWNER="${{ github.repository_owner }}"
|
||||
REPO_NAME="${{ github.event.repository.name }}"
|
||||
GITEA_URL="${{ github.server_url }}"
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
CHECKSUM="${{ steps.checksum.outputs.checksum }}"
|
||||
ARTIFACT_NAME="${{ steps.jprm.outputs.artifact_name }}"
|
||||
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
@@ -145,13 +167,10 @@ jobs:
|
||||
git fetch origin master
|
||||
git checkout master
|
||||
|
||||
# Remove existing "latest" entry if present, then prepend new one
|
||||
jq --arg url "$DOWNLOAD_URL" 'if .[0].versions[0].changelog == "Latest Build" then .[0].versions = .[0].versions[1:] else . end' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
|
||||
|
||||
NEW_VERSION=$(cat <<EOF
|
||||
{
|
||||
"version": "0.0.0.0",
|
||||
"changelog": "Latest Build",
|
||||
"version": "${VERSION}",
|
||||
"changelog": "Nightly build ${VERSION} (${SHORT_SHA})",
|
||||
"targetAbi": "10.9.0.0",
|
||||
"sourceUrl": "${DOWNLOAD_URL}",
|
||||
"checksum": "${CHECKSUM}",
|
||||
@@ -160,9 +179,13 @@ jobs:
|
||||
EOF
|
||||
)
|
||||
|
||||
jq --argjson newver "${NEW_VERSION}" '.[0].versions = [$newver] + .[0].versions' manifest.json > manifest.tmp && mv manifest.tmp manifest.json
|
||||
git add manifest.json
|
||||
git commit -m "Update manifest.json for latest build (${SHORT_SHA})" || echo "No changes to commit"
|
||||
# Prepend the new build and keep only the most recent 5 nightlies.
|
||||
jq --argjson newver "${NEW_VERSION}" \
|
||||
'.[0].versions = ([$newver] + .[0].versions)[0:5]' \
|
||||
manifest-nightly.json > manifest.tmp && mv manifest.tmp manifest-nightly.json
|
||||
|
||||
git add manifest-nightly.json
|
||||
git commit -m "Nightly: ${VERSION} (${SHORT_SHA})" || echo "No changes to commit"
|
||||
git push origin master
|
||||
|
||||
- name: Cleanup
|
||||
|
||||
Reference in New Issue
Block a user