|
| 1 | +name: Build Tizen Release Asset |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [build-release] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + source_repo: |
| 9 | + description: Shared source repository, owner/name |
| 10 | + required: true |
| 11 | + tag: |
| 12 | + description: Release tag to build |
| 13 | + required: true |
| 14 | + rebuild_tizen: |
| 15 | + description: Rebuild hosted Tizen asset instead of reusing the previous release asset |
| 16 | + required: false |
| 17 | + default: "false" |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-wgt: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + env: |
| 25 | + SOURCE_REPO: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.source_repo || inputs.source_repo }} |
| 26 | + SOURCE_TAG: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag || inputs.tag }} |
| 27 | + REBUILD_TIZEN: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.rebuild_tizen || inputs.rebuild_tizen || 'false' }} |
| 28 | + steps: |
| 29 | + - name: Check out hosted Tizen wrapper repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Resolve effective build mode |
| 33 | + id: mode |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ secrets.MAIN_REPO_RELEASE_TOKEN }} |
| 36 | + run: | |
| 37 | + if [ "$REBUILD_TIZEN" = "true" ]; then |
| 38 | + echo "rebuild=true" >> "$GITHUB_OUTPUT" |
| 39 | + exit 0 |
| 40 | + fi |
| 41 | +
|
| 42 | + PREVIOUS_TAG=$(gh release list --repo "$SOURCE_REPO" --exclude-drafts --exclude-pre-releases --limit 20 --json tagName | node -e "const fs=require('fs');const releases=JSON.parse(fs.readFileSync(0,'utf8'));const current=process.env.SOURCE_TAG;const match=releases.find((release)=>release.tagName!==current);if(!match){process.exit(1)}process.stdout.write(match.tagName);" 2>/dev/null || true) |
| 43 | + if [ -n "$PREVIOUS_TAG" ] && gh release download "$PREVIOUS_TAG" --repo "$SOURCE_REPO" --pattern "NuvioTV-Tizen-*.wgt" --dir .; then |
| 44 | + echo "rebuild=false" >> "$GITHUB_OUTPUT" |
| 45 | + else |
| 46 | + echo "No previous reusable Tizen WGT found; rebuilding wrapper" |
| 47 | + echo "rebuild=true" >> "$GITHUB_OUTPUT" |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Set up Node.js |
| 51 | + if: ${{ steps.mode.outputs.rebuild == 'true' }} |
| 52 | + uses: actions/setup-node@v4 |
| 53 | + with: |
| 54 | + node-version: 20 |
| 55 | + cache: npm |
| 56 | + |
| 57 | + - name: Install dependencies |
| 58 | + if: ${{ steps.mode.outputs.rebuild == 'true' }} |
| 59 | + run: npm ci |
| 60 | + |
| 61 | + - name: Package hosted Tizen WGT |
| 62 | + if: ${{ steps.mode.outputs.rebuild == 'true' }} |
| 63 | + run: npm run package |
| 64 | + |
| 65 | + - name: Normalize WGT asset name |
| 66 | + run: | |
| 67 | + PACKAGE_FILE=$(ls NuvioTV-Tizen-*.wgt | head -n 1) |
| 68 | + TARGET_FILE="NuvioTV-Tizen-${SOURCE_TAG}.wgt" |
| 69 | + if [ ! -f "$PACKAGE_FILE" ]; then |
| 70 | + echo "No WGT found to normalize: $PACKAGE_FILE" |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | + rm -f "$TARGET_FILE" |
| 74 | + mv "$PACKAGE_FILE" "$TARGET_FILE" |
| 75 | +
|
| 76 | + - name: Upload WGT to shared release |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.MAIN_REPO_RELEASE_TOKEN }} |
| 79 | + run: | |
| 80 | + gh release upload "$SOURCE_TAG" "NuvioTV-Tizen-${SOURCE_TAG}.wgt" --repo "$SOURCE_REPO" --clobber |
0 commit comments