Skip to content

Fix CI

Fix CI #10

name: Build and Release
on:
push:
branches: ["main", "develop"]
jobs:
build-windows:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: windows-latest
outputs:
version: ${{ steps.package-version.outputs.version }}
prerelease: ${{ steps.package-version.outputs.prerelease }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build:win
- name: Create ZIP archive from unpacked
run: |
Compress-Archive -Path "dist/win-unpacked/*" -DestinationPath "dist/DevNullifier-win-unpacked.zip"
shell: powershell
- name: Get version from package.json
id: package-version
run: |
$version = (Get-Content package.json | ConvertFrom-Json).version
$shortHash = git rev-parse --short HEAD
$branch = "${{ github.ref_name }}"
if ($branch -eq "develop") {
$finalVersion = "v$version-dev-$shortHash"
echo "version=$finalVersion" >> $env:GITHUB_OUTPUT
echo "prerelease=true" >> $env:GITHUB_OUTPUT
} else {
echo "version=v$version" >> $env:GITHUB_OUTPUT
echo "prerelease=false" >> $env:GITHUB_OUTPUT
}
shell: powershell
- name: Find installer file
id: find-installer
run: |
$installer = Get-ChildItem -Path "dist" -Filter "DevNullifier Setup*.exe" | Select-Object -First 1
echo "installer_path=dist/$($installer.Name)" >> $env:GITHUB_OUTPUT
shell: powershell
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: windows-artifacts
path: |
${{ steps.find-installer.outputs.installer_path }}
dist/DevNullifier-win-unpacked.zip
build-linux:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build:linux
- name: Create ZIP archive from unpacked
run: |
cd dist
zip -r DevNullifier-linux-unpacked.zip linux-unpacked/
- name: Find installer files
id: find-installer
run: |
APPIMAGE=$(find dist -name "*.AppImage" | head -1)
DEB=$(find dist -name "*.deb" | head -1)
echo "appimage_path=$APPIMAGE" >> $GITHUB_OUTPUT
echo "deb_path=$DEB" >> $GITHUB_OUTPUT
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: linux-artifacts
path: |
${{ steps.find-installer.outputs.appimage_path }}
${{ steps.find-installer.outputs.deb_path }}
dist/DevNullifier-linux-unpacked.zip
create-release:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
needs: [build-windows, build-linux]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: windows-artifacts
path: artifacts/windows/
- name: Download Linux artifacts
uses: actions/download-artifact@v4
with:
name: linux-artifacts
path: artifacts/linux/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build-windows.outputs.version }}
release_name: ${{ github.ref_name == 'develop' && 'DevNullifier [Pre-release]' || 'DevNullifier' }} ${{ needs.build-windows.outputs.version }}
draft: false
prerelease: ${{ needs.build-windows.outputs.prerelease == 'true' }}
- name: Find Windows installer
id: find-windows-installer
run: |
installer=$(find artifacts/windows -name "DevNullifier Setup*.exe" | head -1)
echo "installer_path=$installer" >> $GITHUB_OUTPUT
- name: Upload Windows Installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.find-windows-installer.outputs.installer_path }}
asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-Setup-dev.exe' || 'DevNullifier-Setup.exe' }}
asset_content_type: application/octet-stream
- name: Upload Windows ZIP Archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/windows/DevNullifier-win-unpacked.zip
asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-win-unpacked-dev.zip' || 'DevNullifier-win-unpacked.zip' }}
asset_content_type: application/zip
- name: Find Linux files
id: find-linux-files
run: |
appimage=$(find artifacts/linux -name "*.AppImage" | head -1)
deb=$(find artifacts/linux -name "*.deb" | head -1)
echo "appimage_path=$appimage" >> $GITHUB_OUTPUT
echo "deb_path=$deb" >> $GITHUB_OUTPUT
- name: Upload Linux AppImage
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.find-linux-files.outputs.appimage_path }}
asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-linux-x64-dev.AppImage' || 'DevNullifier-linux-x64.AppImage' }}
asset_content_type: application/octet-stream
- name: Upload Linux DEB
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.find-linux-files.outputs.deb_path }}
asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-linux-x64-dev.deb' || 'DevNullifier-linux-x64.deb' }}
asset_content_type: application/octet-stream
- name: Upload Linux ZIP Archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/linux/DevNullifier-linux-unpacked.zip
asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-linux-unpacked-dev.zip' || 'DevNullifier-linux-unpacked.zip' }}
asset_content_type: application/zip