|
| 1 | +name: '🚀 Release Plugin' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout Repository |
| 17 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 18 | + with: |
| 19 | + persist-credentials: false |
| 20 | + |
| 21 | + - name: Setup .NET |
| 22 | + uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0 |
| 23 | + with: |
| 24 | + dotnet-version: "9.0.x" |
| 25 | + |
| 26 | + - name: Restore dependencies |
| 27 | + run: dotnet restore |
| 28 | + |
| 29 | + - name: Build Jellyfin Plugin |
| 30 | + uses: oddstr13/jellyfin-plugin-repository-manager@9497a0a499416cc572ed2e07a391d9f943a37b4d # v1.1.1 |
| 31 | + id: jprm |
| 32 | + with: |
| 33 | + dotnet-target: "net9.0" |
| 34 | + |
| 35 | + - name: Upload Artifact |
| 36 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 37 | + with: |
| 38 | + name: build-artifact |
| 39 | + path: ${{ steps.jprm.outputs.artifact }} |
| 40 | + |
| 41 | + release: |
| 42 | + needs: [build] |
| 43 | + runs-on: ubuntu-latest |
| 44 | + if: startsWith(github.ref, 'refs/tags/v') |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + steps: |
| 48 | + - name: Download Artifact |
| 49 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 |
| 50 | + with: |
| 51 | + name: build-artifact |
| 52 | + |
| 53 | + - name: Generate checksums |
| 54 | + run: | |
| 55 | + for file in ./*.zip; do |
| 56 | + md5sum "${file##./}" >> "${file%.zip}.md5" |
| 57 | + sha256sum "${file##./}" >> "${file%.zip}.sha256" |
| 58 | + done |
| 59 | +
|
| 60 | + - name: Create GitHub Release |
| 61 | + env: |
| 62 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + GH_REPO: ${{ github.repository }} |
| 64 | + TAG: ${{ github.ref_name }} |
| 65 | + run: | |
| 66 | + # Create release if it doesn't exist, or upload assets to existing one |
| 67 | + if gh release view "${TAG}" --repo "${GH_REPO}" > /dev/null 2>&1; then |
| 68 | + echo "Release ${TAG} already exists — uploading assets" |
| 69 | + gh release upload "${TAG}" ./* --repo "${GH_REPO}" --clobber |
| 70 | + else |
| 71 | + gh release create "${TAG}" ./* --generate-notes --repo "${GH_REPO}" |
| 72 | + fi |
| 73 | +
|
| 74 | + update-manifest: |
| 75 | + needs: [release] |
| 76 | + runs-on: ubuntu-latest |
| 77 | + if: startsWith(github.ref, 'refs/tags/v') |
| 78 | + permissions: |
| 79 | + contents: write |
| 80 | + steps: |
| 81 | + - name: Checkout Repository |
| 82 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 83 | + with: |
| 84 | + ref: main |
| 85 | + persist-credentials: false |
| 86 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 87 | + |
| 88 | + - name: Extract version from tag |
| 89 | + id: version |
| 90 | + env: |
| 91 | + TAG: ${{ github.ref_name }} |
| 92 | + run: | |
| 93 | + VERSION="${TAG#v}" |
| 94 | + # Convert semver (1.2.3) to 4-part (1.2.3.0) if needed |
| 95 | + if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 96 | + VERSION="${VERSION}.0" |
| 97 | + fi |
| 98 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 99 | + echo "tag=${TAG}" >> "$GITHUB_OUTPUT" |
| 100 | +
|
| 101 | + - name: Update manifest.json |
| 102 | + env: |
| 103 | + VERSION: ${{ steps.version.outputs.version }} |
| 104 | + TAG: ${{ steps.version.outputs.tag }} |
| 105 | + REPO: ${{ github.repository }} |
| 106 | + run: | |
| 107 | + TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
| 108 | + SOURCE_URL="https://github.com/${REPO}/releases/download/${TAG}/remote-auth_${VERSION}.zip" |
| 109 | + CHECKSUM=$(curl -sL "${SOURCE_URL}" | md5sum | cut -d' ' -f1) |
| 110 | +
|
| 111 | + # Use jq to update manifest.json — prepend new version entry |
| 112 | + jq --arg ver "$VERSION" \ |
| 113 | + --arg ts "$TIMESTAMP" \ |
| 114 | + --arg url "$SOURCE_URL" \ |
| 115 | + --arg cs "$CHECKSUM" \ |
| 116 | + --arg cl "Release ${TAG}" \ |
| 117 | + '.[0].versions = [ |
| 118 | + { |
| 119 | + "version": $ver, |
| 120 | + "changelog": $cl, |
| 121 | + "targetAbi": "10.11.0.0", |
| 122 | + "sourceUrl": $url, |
| 123 | + "checksum": $cs, |
| 124 | + "timestamp": $ts |
| 125 | + } |
| 126 | + ] + .[0].versions' manifest.json > manifest_new.json |
| 127 | + mv manifest_new.json manifest.json |
| 128 | +
|
| 129 | + - name: Commit manifest |
| 130 | + env: |
| 131 | + TAG: ${{ steps.version.outputs.tag }} |
| 132 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + REPO: ${{ github.repository }} |
| 134 | + run: | |
| 135 | + git config user.name "github-actions[bot]" |
| 136 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 137 | + git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git" |
| 138 | + git add manifest.json |
| 139 | + git commit -m "chore: update manifest.json for ${TAG}" || exit 0 |
| 140 | + git push |
0 commit comments