Skip to content

Check Dependency Updates #44

Check Dependency Updates

Check Dependency Updates #44

name: Check Dependency Updates
on:
schedule:
- cron: '0 6 * * *' # Daily at 6 AM UTC
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
needs_update: ${{ steps.compare.outputs.NEEDS_UPDATE }}
new_streamlink: ${{ steps.compare.outputs.NEW_STREAMLINK }}
new_ttvlol: ${{ steps.compare.outputs.NEW_TTVLOL }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get latest StreamNook release info
id: current
run: |
# Get latest release components.json
release=$(gh release view --json tagName,assets)
tag=$(echo $release | jq -r '.tagName')
echo "CURRENT_TAG=$tag" >> $GITHUB_OUTPUT
echo "Current release: $tag"
# Try to download components.json
if gh release download $tag -p "components.json" -D ./current 2>/dev/null; then
current_streamlink=$(jq -r '.components.streamlink.version' ./current/components.json)
current_ttvlol=$(jq -r '.components.ttvlol.version' ./current/components.json)
echo "CURRENT_STREAMLINK=$current_streamlink" >> $GITHUB_OUTPUT
echo "CURRENT_TTVLOL=$current_ttvlol" >> $GITHUB_OUTPUT
echo "Current Streamlink: $current_streamlink"
echo "Current TTV LOL: $current_ttvlol"
else
echo "No components.json found in current release"
echo "CURRENT_STREAMLINK=" >> $GITHUB_OUTPUT
echo "CURRENT_TTVLOL=" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest Streamlink version
id: streamlink
run: |
release=$(curl -s https://api.github.com/repos/streamlink/windows-builds/releases/latest)
version=$(echo $release | jq -r '.tag_name')
echo "STREAMLINK_VERSION=$version" >> $GITHUB_OUTPUT
echo "Latest Streamlink: $version"
- name: Get latest TTV LOL version
id: ttvlol
run: |
release=$(curl -s https://api.github.com/repos/2bc4/streamlink-ttvlol/releases/latest)
version=$(echo $release | jq -r '.tag_name')
echo "TTVLOL_VERSION=$version" >> $GITHUB_OUTPUT
echo "Latest TTV LOL: $version"
- name: Compare versions
id: compare
run: |
current_streamlink="${{ steps.current.outputs.CURRENT_STREAMLINK }}"
current_ttvlol="${{ steps.current.outputs.CURRENT_TTVLOL }}"
latest_streamlink="${{ steps.streamlink.outputs.STREAMLINK_VERSION }}"
latest_ttvlol="${{ steps.ttvlol.outputs.TTVLOL_VERSION }}"
needs_update="false"
new_streamlink=""
new_ttvlol=""
if [ -n "$current_streamlink" ] && [ "$current_streamlink" != "$latest_streamlink" ]; then
echo "Streamlink update available: $current_streamlink → $latest_streamlink"
needs_update="true"
new_streamlink="$current_streamlink → $latest_streamlink"
fi
if [ -n "$current_ttvlol" ] && [ "$current_ttvlol" != "$latest_ttvlol" ]; then
echo "TTV LOL update available: $current_ttvlol → $latest_ttvlol"
needs_update="true"
new_ttvlol="$current_ttvlol → $latest_ttvlol"
fi
echo "NEEDS_UPDATE=$needs_update" >> $GITHUB_OUTPUT
echo "NEW_STREAMLINK=$new_streamlink" >> $GITHUB_OUTPUT
echo "NEW_TTVLOL=$new_ttvlol" >> $GITHUB_OUTPUT
if [ "$needs_update" = "true" ]; then
echo "::notice::Dependency updates available!"
else
echo "All dependencies up to date"
fi
build-update:
needs: check
if: needs.check.outputs.needs_update == 'true'
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get current version
id: version
shell: pwsh
run: |
$cargo = Get-Content src-tauri/Cargo.toml -Raw
if ($cargo -match 'version\s*=\s*"([^"]+)"') {
$version = $matches[1]
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "Current StreamNook version: $version"
}
- name: Determine new version tag
id: new_version
shell: pwsh
run: |
$version = "${{ steps.version.outputs.VERSION }}"
# Check for existing dependency update releases
$releases = gh release list --limit 50 --json tagName | ConvertFrom-Json
$depReleases = $releases | Where-Object { $_.tagName -like "v$version-dep.*" }
if ($depReleases) {
# Find the highest dep number
$maxDep = 0
foreach ($r in $depReleases) {
if ($r.tagName -match "v$version-dep\.(\d+)") {
$num = [int]$matches[1]
if ($num -gt $maxDep) { $maxDep = $num }
}
}
$newDep = $maxDep + 1
} else {
$newDep = 1
}
$newTag = "v$version-dep.$newDep"
echo "NEW_TAG=$newTag" >> $env:GITHUB_OUTPUT
echo "New release tag: $newTag"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download StreamNook.exe from previous release
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path ./bundle
# Get the latest release
$releases = gh release list --limit 10 --json tagName | ConvertFrom-Json
$latestTag = $releases[0].tagName
echo "Downloading from release: $latestTag"
# Download the bundle
gh release download $latestTag -p "StreamNook.7z" -D ./previous-release
# Extract StreamNook.exe
$bundle = Get-ChildItem ./previous-release -Filter "StreamNook.7z" | Select-Object -First 1
7z x $bundle.FullName -o"./previous-release/extracted" StreamNook.exe
Copy-Item ./previous-release/extracted/StreamNook.exe ./bundle/
echo "StreamNook.exe extracted from previous release"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest Streamlink portable
id: streamlink
shell: pwsh
run: |
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/streamlink/windows-builds/releases/latest"
$version = $release.tag_name
echo "STREAMLINK_VERSION=$version" >> $env:GITHUB_OUTPUT
$asset = $release.assets | Where-Object { $_.name -like "*portable*.zip" -and $_.name -like "*py312*" } | Select-Object -First 1
if (-not $asset) {
$asset = $release.assets | Where-Object { $_.name -like "*portable*.zip" } | Select-Object -First 1
}
echo "STREAMLINK_URL=$($asset.browser_download_url)" >> $env:GITHUB_OUTPUT
- name: Get latest TTV LOL plugin
id: ttvlol
shell: pwsh
run: |
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/2bc4/streamlink-ttvlol/releases/latest"
$version = $release.tag_name
echo "TTVLOL_VERSION=$version" >> $env:GITHUB_OUTPUT
$asset = $release.assets | Where-Object { $_.name -eq "twitch.py" }
echo "TTVLOL_URL=$($asset.browser_download_url)" >> $env:GITHUB_OUTPUT
- name: Download and extract Streamlink
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path ./bundle/streamlink
$url = "${{ steps.streamlink.outputs.STREAMLINK_URL }}"
Invoke-WebRequest -Uri $url -OutFile ./streamlink.zip
Expand-Archive -Path ./streamlink.zip -DestinationPath ./bundle/streamlink-temp -Force
$extracted = Get-ChildItem ./bundle/streamlink-temp -Directory | Select-Object -First 1
if ($extracted) {
Move-Item "$($extracted.FullName)/*" ./bundle/streamlink/ -Force
} else {
Move-Item ./bundle/streamlink-temp/* ./bundle/streamlink/ -Force
}
Remove-Item ./bundle/streamlink-temp -Recurse -Force
Remove-Item ./streamlink.zip -Force
New-Item -ItemType Directory -Force -Path ./bundle/streamlink/plugins
- name: Download TTV LOL plugin
shell: pwsh
run: |
$url = "${{ steps.ttvlol.outputs.TTVLOL_URL }}"
Invoke-WebRequest -Uri $url -OutFile ./bundle/streamlink/plugins/twitch.py
- name: Copy CHANGELOG.md
shell: pwsh
run: Copy-Item CHANGELOG.md ./bundle/
- name: Generate components.json
shell: pwsh
run: |
$version = "${{ steps.version.outputs.VERSION }}"
$streamlinkVersion = "${{ steps.streamlink.outputs.STREAMLINK_VERSION }}"
$ttvlolVersion = "${{ steps.ttvlol.outputs.TTVLOL_VERSION }}"
$buildDate = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$components = @{
schema_version = 1
streamnook = @{
version = $version
build_date = $buildDate
}
components = @{
streamlink = @{
version = $streamlinkVersion
source_url = "https://github.com/streamlink/windows-builds/releases"
}
ttvlol = @{
version = $ttvlolVersion
source_url = "https://github.com/2bc4/streamlink-ttvlol/releases"
}
}
}
$json = $components | ConvertTo-Json -Depth 10
$json | Out-File -FilePath ./bundle/components.json -Encoding utf8
- name: Create 7z bundle
id: bundle
shell: pwsh
run: |
$bundleName = "StreamNook.7z"
cd bundle
7z a -t7z -mx=9 "../$bundleName" *
cd ..
echo "BUNDLE_NAME=$bundleName" >> $env:GITHUB_OUTPUT
$size = (Get-Item $bundleName).Length / 1MB
echo "Bundle size: $([math]::Round($size, 2)) MB"
- name: Generate checksums
shell: pwsh
run: |
$bundleName = "${{ steps.bundle.outputs.BUNDLE_NAME }}"
$hash = (Get-FileHash $bundleName -Algorithm SHA256).Hash
"$hash $bundleName" | Out-File -FilePath checksums.txt -Encoding utf8
- name: Create GitHub Release
shell: pwsh
run: |
$newTag = "${{ steps.new_version.outputs.NEW_TAG }}"
$bundleName = "${{ steps.bundle.outputs.BUNDLE_NAME }}"
$version = "${{ steps.version.outputs.VERSION }}"
$streamlinkVersion = "${{ steps.streamlink.outputs.STREAMLINK_VERSION }}"
$ttvlolVersion = "${{ steps.ttvlol.outputs.TTVLOL_VERSION }}"
$newStreamlink = "${{ needs.check.outputs.new_streamlink }}"
$newTtvlol = "${{ needs.check.outputs.new_ttvlol }}"
# Build update notes
$updates = @()
if ($newStreamlink) { $updates += "- **Streamlink**: $newStreamlink" }
if ($newTtvlol) { $updates += "- **TTV LOL Plugin**: $newTtvlol" }
$updateList = $updates -join "`n"
$notes = @"
## Dependency Update
This release updates bundled dependencies. No changes to StreamNook itself.
### Updated Components
$updateList
### Current Versions
- **StreamNook**: v$version
- **Streamlink**: $streamlinkVersion
- **TTV LOL Plugin**: $ttvlolVersion
### Download
Download ``$bundleName`` and extract to your desired location.
"@
gh release create "$newTag" `
--title "StreamNook $newTag (Dependency Update)" `
--notes "$notes" `
"$bundleName" `
"bundle/components.json" `
"checksums.txt"
echo "Release $newTag created!"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}