diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7444d7b4..99e3e3b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,76 +1,117 @@ -name: Build and Release +name: build and release on: push: tags: - - 'v*.*.*' # Triggers on version tags - - 'v*.*.*-*' # Trigger for pre-release tags + - v[0-9]+.[0-9]+.[0-9]+* workflow_dispatch: # Allows manual triggering jobs: - build: - runs-on: ${{ matrix.os }} + macos: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - + os-version: ['12', '14'] + include: + - os-version: '12' + arch: x86_64 + - os-version: '14' + arch: aarch64 + runs-on: macos-${{ matrix.os-version }} steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Check out Git repository + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + DeskThingServer - - name: Set up Node.js - uses: actions/setup-node@v3 + - name: Install Node.js, NPM + uses: actions/setup-node@v4 with: - node-version: '20' + node-version: 20 - name: Install dependencies run: | - cd ./DeskThingServer + cd DeskThingServer npm ci - - name: Run type check - run: | - cd ./DeskThingServer - npm run typecheck - - - name: Build application - run: | - cd ./DeskThingServer - npm run build:${{ runner.os }} - - - name: Extract version from tag - id: get_version - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + - name: Build/release Electron app + uses: paneron/action-electron-builder@v1.8.1 + with: + github_token: ${{ secrets.github_token }} + package_manager: npm + package_root: ${{ github.workspace }}/DeskThingServer + release: ${{ startsWith(github.ref, 'refs/tags/v') }} - - name: Upload artifact - uses: actions/upload-artifact@v3 + - name: Upload binaries to artifacts + uses: actions/upload-artifact@v4 with: - name: DeskThing-${{ steps.get_version.outputs.VERSION }}-${{ runner.os }} - path: ./DeskThingServer/dist/*.* + name: deskthing-macos-${{ matrix.arch }} + path: ${{ github.workspace }}/DeskThingServer/dist/deskthing-*.dmg release: - needs: build - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + + name: Build ${{ matrix.os }} steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Check out Git repository + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + DeskThingServer - - name: Download artifacts - uses: actions/download-artifact@v3 + - name: Install Node.js, NPM + uses: actions/setup-node@v4 with: - path: ./dist + node-version: 20 - - name: Get the version - id: get_version - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + - name: Install dependencies + run: | + cd DeskThingServer + npm ci + + - name: Build/release Electron app + uses: paneron/action-electron-builder@v1.8.1 + with: + github_token: ${{ secrets.github_token }} + package_manager: npm + package_root: ${{ github.workspace }}/DeskThingServer + release: ${{ startsWith(github.ref, 'refs/tags/v') }} - - name: Update or create release - uses: softprops/action-gh-release@v1 + - name: Upload binaries to artifacts + uses: actions/upload-artifact@v4 with: - tag_name: ${{ steps.get_version.outputs.VERSION }} - files: ./dist/**/* - draft: true - prerelease: false - generate_release_notes: true + name: deskthing-${{matrix.os}} + path: ${{ github.workspace }}/DeskThingServer/dist/deskthing* + + publish: + needs: [release, macos] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Get Current Release + id: get_current_release + uses: joutvhu/get-release@v1 + with: + latest: true + pattern: '^v.*' + prerelease: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.get_current_release.outputs.tag_name }} + files: | + deskthing-macos-aarch64/* + deskthing-macos-x86_64/* + deskthing-ubuntu-latest/* + deskthing-windows-latest/* diff --git a/DeskThingServer/electron-builder.yml b/DeskThingServer/electron-builder.yml index 8b483391..930a8cb4 100644 --- a/DeskThingServer/electron-builder.yml +++ b/DeskThingServer/electron-builder.yml @@ -14,12 +14,12 @@ asarUnpack: - bin/** win: executableName: DeskThing - artifactName: ${name}-${version}-windows-setup.${ext} + artifactName: ${name}-${os}-${version}-setup.${ext} extraFiles: - - from: "adb_source/win" - to: "resources/win" + - from: 'adb_source/win' + to: 'resources/win' nsis: - artifactName: ${name}-${version}-setup.${ext} + artifactName: ${name}-${os}-${version}-setup.${ext} shortcutName: ${productName} uninstallDisplayName: ${productName} createDesktopShortcut: always @@ -32,10 +32,10 @@ mac: - NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder. notarize: false extraFiles: - - from: "adb_source/mac" - to: "resources/mac" + - from: 'adb_source/mac' + to: 'resources/mac' dmg: - artifactName: ${name}-${version}-mac-setup.${ext} + artifactName: ${name}-${os}-${arch}-${version}-setup.${ext} linux: target: - AppImage @@ -43,10 +43,10 @@ linux: maintainer: Riprod category: Utility extraFiles: - - from: "adb_source/linux" - to: "resources/linux" + - from: 'adb_source/linux' + to: 'resources/linux' appImage: - artifactName: ${name}-${version}-linux-setup.${ext} + artifactName: ${name}-${os}-${version}-setup.${ext} npmRebuild: false publish: provider: generic diff --git a/DeskThingServer/package.json b/DeskThingServer/package.json index 80f4a864..a9adaa8b 100644 --- a/DeskThingServer/package.json +++ b/DeskThingServer/package.json @@ -13,12 +13,9 @@ "typecheck": "npm run typecheck:node && npm run typecheck:web", "start": "electron-vite preview", "dev": "electron-vite dev", - "build": "npm run typecheck && electron-vite build", + "build": "npm run typecheck && electron-vite build && electron-builder", "postinstall": "electron-builder install-app-deps", - "build:unpack": "npm run build && electron-builder --dir", - "build:win": "npm run build && electron-builder --win", - "build:mac": "electron-vite build && electron-builder --mac", - "build:linux": "electron-vite build && electron-builder --linux" + "build:unpack": "npm run build && electron-builder --dir" }, "dependencies": { "@electron-toolkit/preload": "^3.0.0",