Skip to content

Nightly Build and Release #6

Nightly Build and Release

Nightly Build and Release #6

name: Nightly Build and Release
on:
schedule:
- cron: "0 0 * * *" # Runs every day at midnight UTC
workflow_dispatch: # Allows manual trigger
permissions:
contents: write
packages: write
security-events: write
jobs:
check-and-build:
runs-on: ubuntu-latest
outputs:
new_release: ${{ steps.set-output.outputs.new_release }}
latest_commit_hash: ${{ steps.set-output.outputs.latest_commit_hash }}
latest_server_tag: ${{ steps.set-output.outputs.latest_server_tag }}
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Step 3: Install dependencies
- name: Install dependencies
run: npm install
# Step 4: Fetch latest Stremio versions
- name: Fetch latest Stremio versions
run: node scripts/fetch-latest-stremio.js
# Step 5: Get the latest release description
- name: Get latest release
id: latest-release
uses: actions/github-script@v6
with:
script: |
try {
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
core.setOutput('description', latestRelease.data.body || '');
core.setOutput('found', true);
} catch (error) {
if (error.status === 404) {
console.log('No releases found. This is the initial run.');
core.setOutput('description', '');
core.setOutput('found', false);
} else {
throw error;
}
}
# Step 6: Compare fetched versions with release versions and set outputs
- name: Check for new versions and set outputs
id: set-output
run: |
if [ "${{ steps.latest-release.outputs.found }}" != "true" ]; then
echo "new_release=true" >> $GITHUB_OUTPUT
else
LATEST_DESCRIPTION="${{ steps.latest-release.outputs.description }}"
if [[ "$LATEST_DESCRIPTION" == *"Web version: ${{ env.LATEST_COMMIT_HASH }}"* && "$LATEST_DESCRIPTION" == *"Server version: ${{ env.LATEST_SERVER_TAG }}"* ]]; then
echo "new_release=false" >> $GITHUB_OUTPUT
else
echo "new_release=true" >> $GITHUB_OUTPUT
fi
fi
echo "latest_commit_hash=${{ env.LATEST_COMMIT_HASH }}" >> $GITHUB_OUTPUT
echo "latest_server_tag=${{ env.LATEST_SERVER_TAG }}" >> $GITHUB_OUTPUT
# Step 7: Upload stremio-web and stremio-server as artifacts
- name: Upload stremio-web and stremio-server
if: ${{ steps.set-output.outputs.new_release == 'true' }}
uses: actions/upload-artifact@v4
with:
name: stremio-artifacts
path: |
src/stremio-web
src/stremio-server
build:
needs: check-and-build
if: ${{ needs.check-and-build.outputs.new_release == 'true' }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Download stremio-artifacts
- name: Download stremio-artifacts
uses: actions/download-artifact@v4
with:
name: stremio-artifacts
path: src
# Step 3: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Step 4: Install dependencies
- name: Install dependencies
run: npm install
# Step 5: Build for platform and handle Windows ZIP and setup.exe
- name: Build for ${{ matrix.os }}
shell: bash
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "Building for Windows..."
npm run make -- --platform=win32
echo "Creating ZIP for Windows..."
mkdir -p out/windows/
# Compress with PowerShell, excluding start.exe
pwsh -Command "Compress-Archive -Path 'out/stremio-web-dekstop-win32-x64/*' -DestinationPath 'out/windows/stremio-web-dekstop-win32-x64.zip'"
# Find the setup.exe with random name and copy to out/windows/
setup_exe=$(find out/make/squirrel.windows/x64/ -type f -name "*.exe" | head -n 1)
cp "$setup_exe" out/windows/
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
echo "Building for macOS..."
npm run make -- --platform=darwin
elif [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
echo "Building for Linux..."
npm run make -- --platform=linux
fi
# Step 6: Upload build artifacts
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: stremio-${{ matrix.os }}
path: |
# Windows: Upload ZIP and setup.exe
out/windows/*.zip
out/windows/*.exe
# macOS: Upload DMG
out/make/**/*.dmg
# Ubuntu: Upload DEB and RPM
out/make/**/*.deb
out/make/**/*.rpm
release:
needs: build
if: ${{ needs.check-and-build.outputs.new_release == 'true' }}
runs-on: ubuntu-latest
steps:
# Step 1: Checkout repository
- name: Checkout repository
uses: actions/checkout@v3
# Step 2: Download all artifacts
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: stremio-windows-latest
path: out/windows
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: stremio-macos-latest
path: out/macos
- name: Download Ubuntu artifacts
uses: actions/download-artifact@v4
with:
name: stremio-ubuntu-latest
path: out/ubuntu
# Step 3: Create GitHub Release
- name: Create GitHub Release
uses: ncipollo/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ github.run_number }}
name: "Stremio Web Desktop v${{ github.run_number }}"
body: |
Web version: ${{ needs.check-and-build.outputs.latest_commit_hash }}
Server version: ${{ needs.check-and-build.outputs.latest_server_tag }}
files: |
# Windows: ZIP and setup.exe
out/windows/stremio-web-dekstop-win32-x64.zip
out/windows/*.exe
# macOS: DMG
out/macos/**/*.dmg
# Ubuntu: DEB and RPM
out/ubuntu/**/*.deb
out/ubuntu/**/*.rpm