Merge pull request #7 from Hermesiss/develop #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | |
| on: | |
| push: | |
| branches: ["main", "develop", "feature/*"] | |
| jobs: | |
| build-windows: | |
| if: github.event_name == 'push' || (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'feature/')) | |
| 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: Upload Windows artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: windows-artifacts | |
| path: | | |
| dist/DevNullifier-Setup.exe | |
| dist/DevNullifier-win-unpacked.zip | |
| dist/latest.yml | |
| build-linux: | |
| if: github.event_name == 'push' || (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'feature/')) | |
| 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" -type f | head -1) | |
| DEB=$(find dist -name "*.deb" -type f | 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 | |
| dist/latest-linux.yml | |
| build-macos: | |
| if: github.event_name == 'push' || (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'feature/')) | |
| runs-on: macos-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:mac | |
| - name: Create ZIP archive from unpacked | |
| run: | | |
| cd dist | |
| zip -r DevNullifier-mac-unpacked.zip mac/ | |
| - name: Find installer files | |
| id: find-installer | |
| run: | | |
| DMG=$(find dist -name "*.dmg" | head -1) | |
| echo "dmg_path=$DMG" >> $GITHUB_OUTPUT | |
| - name: Upload macOS artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-artifacts | |
| path: | | |
| ${{ steps.find-installer.outputs.dmg_path }} | |
| dist/DevNullifier-mac-unpacked.zip | |
| dist/latest-mac.yml | |
| create-release: | |
| if: github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'main') | |
| runs-on: ubuntu-latest | |
| needs: [build-windows, build-linux, build-macos] | |
| 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: Download macOS artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: macos-artifacts | |
| path: artifacts/macos/ | |
| - 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' }} | |
| # Windows assets | |
| - 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: artifacts/windows/DevNullifier-Setup.exe | |
| asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-Setup-dev.exe' || 'DevNullifier-Setup.exe' }} | |
| asset_content_type: application/octet-stream | |
| - name: Upload latest.yml | |
| 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/latest.yml | |
| asset_name: latest.yml | |
| asset_content_type: text/yaml | |
| - 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 | |
| # Linux assets | |
| - name: Find Linux files | |
| id: find-linux-files | |
| run: | | |
| APPIMAGE=$(find artifacts/linux -name "*.AppImage" -type f | head -1) | |
| DEB=$(find artifacts/linux -name "*.deb" -type f | 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 | |
| - name: Upload latest-linux.yml | |
| 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/latest-linux.yml | |
| asset_name: latest-linux.yml | |
| asset_content_type: text/yaml | |
| # macOS assets | |
| - name: Upload macOS DMG | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: artifacts/macos/DevNullifier-mac-x64.dmg | |
| asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-mac-x64-dev.dmg' || 'DevNullifier-mac-x64.dmg' }} | |
| asset_content_type: application/octet-stream | |
| - name: Upload macOS 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/macos/DevNullifier-mac-unpacked.zip | |
| asset_name: ${{ github.ref_name == 'develop' && 'DevNullifier-mac-unpacked-dev.zip' || 'DevNullifier-mac-unpacked.zip' }} | |
| asset_content_type: application/zip | |
| - name: Upload latest-mac.yml | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: artifacts/macos/latest-mac.yml | |
| asset_name: latest-mac.yml | |
| asset_content_type: text/yaml |