|
| 1 | +name: Build and Release Electron App |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: # Allow manual trigger |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build for ${{ matrix.os }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: macos-latest |
| 17 | + platform: mac |
| 18 | + arch: x64,arm64 |
| 19 | + - os: windows-latest |
| 20 | + platform: win |
| 21 | + arch: x64 |
| 22 | + - os: ubuntu-latest |
| 23 | + platform: linux |
| 24 | + arch: x64 |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: 20.16.0 # Project's Node version |
| 36 | + cache: pnpm |
| 37 | + |
| 38 | + - name: Setup pnpm |
| 39 | + uses: pnpm/action-setup@v4 |
| 40 | + with: |
| 41 | + version: latest |
| 42 | + |
| 43 | + - name: Install dependencies |
| 44 | + run: pnpm install |
| 45 | + |
| 46 | + - name: Rebuild native dependencies |
| 47 | + run: pnpm run rebuild |
| 48 | + |
| 49 | + - name: Build application |
| 50 | + run: pnpm run build:${{ matrix.platform }} |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Upload artifacts |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: masscode-${{ matrix.platform }}-${{ github.ref_name }} |
| 58 | + path: | |
| 59 | + dist/*.dmg |
| 60 | + dist/*.pkg |
| 61 | + dist/*.exe |
| 62 | + dist/*.msi |
| 63 | + dist/*.AppImage |
| 64 | + dist/*.snap |
| 65 | + if-no-files-found: warn |
| 66 | + retention-days: 30 |
| 67 | + |
| 68 | + release: |
| 69 | + name: Create Release |
| 70 | + needs: build |
| 71 | + runs-on: ubuntu-latest |
| 72 | + if: startsWith(github.ref, 'refs/tags/v') |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Checkout code |
| 76 | + uses: actions/checkout@v4 |
| 77 | + |
| 78 | + - name: Download all artifacts |
| 79 | + uses: actions/download-artifact@v4 |
| 80 | + with: |
| 81 | + path: artifacts |
| 82 | + |
| 83 | + - name: Display structure of downloaded files |
| 84 | + run: ls -la artifacts/ |
| 85 | + |
| 86 | + - name: Get package version |
| 87 | + id: package-version |
| 88 | + run: | |
| 89 | + echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT |
| 90 | +
|
| 91 | + - name: Create Release |
| 92 | + id: create_release |
| 93 | + uses: softprops/action-gh-release@v2 |
| 94 | + with: |
| 95 | + files: | |
| 96 | + artifacts/masscode-*/* |
| 97 | + draft: true |
| 98 | + generate_release_notes: true |
| 99 | + append_body: true |
| 100 | + env: |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments