Update from beta #38
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" -type f | 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 | |
| # Delete previous latest-dev tag and release if on develop branch | |
| - name: Delete previous latest-dev tag and release | |
| if: github.ref_name == 'develop' | |
| run: | | |
| # Delete previous release | |
| RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/tags/latest-dev" | \ | |
| jq -r '.id') | |
| if [ "$RELEASE_ID" != "null" ]; then | |
| curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID" | |
| fi | |
| # Delete previous tag | |
| git push --delete origin latest-dev || true | |
| continue-on-error: true | |
| - 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' }} | |
| # Create latest-dev tag and release for develop branch | |
| - name: Create latest-dev tag and release | |
| if: github.ref_name == 'develop' | |
| run: | | |
| # Create and push latest-dev tag | |
| git tag -f latest-dev | |
| git push -f origin latest-dev | |
| # Create latest-dev release | |
| UPLOAD_URL=$(curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| -d '{ | |
| "tag_name": "latest-dev", | |
| "name": "DevNullifier [Latest Development Build]", | |
| "draft": false, | |
| "prerelease": true | |
| }' \ | |
| "https://api.github.com/repos/${{ github.repository }}/releases" | \ | |
| jq -r '.upload_url' | sed 's/{.*}//') | |
| echo "LATEST_DEV_UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV | |
| # 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: 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: Find macOS files | |
| id: find-macos-files | |
| run: | | |
| DMG=$(find artifacts/macos -name "*.dmg" -type f | head -1) | |
| echo "dmg_path=$DMG" >> $GITHUB_OUTPUT | |
| - 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: ${{ steps.find-macos-files.outputs.dmg_path }} | |
| 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 | |
| # Upload to latest-dev release if on develop branch | |
| - name: Upload assets to latest-dev release | |
| if: github.ref_name == 'develop' | |
| run: | | |
| # Function to upload asset | |
| upload_asset() { | |
| local file="$1" | |
| local name="$2" | |
| local type="$3" | |
| curl -X POST \ | |
| -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Content-Type: $type" \ | |
| --data-binary "@$file" \ | |
| "${{ env.LATEST_DEV_UPLOAD_URL }}?name=$name" | |
| } | |
| # Upload Windows assets | |
| upload_asset "artifacts/windows/DevNullifier-Setup.exe" "DevNullifier-Setup.exe" "application/octet-stream" | |
| upload_asset "artifacts/windows/latest.yml" "latest.yml" "text/yaml" | |
| upload_asset "artifacts/windows/DevNullifier-win-unpacked.zip" "DevNullifier-win-unpacked.zip" "application/zip" | |
| # Upload Linux assets | |
| APPIMAGE=$(find artifacts/linux -name "*.AppImage" -type f | head -1) | |
| DEB=$(find artifacts/linux -name "*.deb" -type f | head -1) | |
| upload_asset "$APPIMAGE" "DevNullifier-linux-x64.AppImage" "application/octet-stream" | |
| upload_asset "$DEB" "DevNullifier-linux-x64.deb" "application/octet-stream" | |
| upload_asset "artifacts/linux/DevNullifier-linux-unpacked.zip" "DevNullifier-linux-unpacked.zip" "application/zip" | |
| upload_asset "artifacts/linux/latest-linux.yml" "latest-linux.yml" "text/yaml" | |
| # Upload macOS assets | |
| DMG=$(find artifacts/macos -name "*.dmg" -type f | head -1) | |
| upload_asset "$DMG" "DevNullifier-mac-x64.dmg" "application/octet-stream" | |
| upload_asset "artifacts/macos/DevNullifier-mac-unpacked.zip" "DevNullifier-mac-unpacked.zip" "application/zip" | |
| upload_asset "artifacts/macos/latest-mac.yml" "latest-mac.yml" "text/yaml" |