name: build-packages on: workflow_dispatch: inputs: publish_release: description: "Publish GitHub Release after build" type: boolean default: false push: tags: - "v*" jobs: build: name: build-${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] env: VITE_SYNC_GITHUB_CLIENT_ID: ${{ secrets.VITE_SYNC_GITHUB_CLIENT_ID }} VITE_SYNC_GOOGLE_CLIENT_ID: ${{ secrets.VITE_SYNC_GOOGLE_CLIENT_ID }} VITE_SYNC_GOOGLE_CLIENT_SECRET: ${{ secrets.VITE_SYNC_GOOGLE_CLIENT_SECRET }} VITE_SYNC_ONEDRIVE_CLIENT_ID: ${{ secrets.VITE_SYNC_ONEDRIVE_CLIENT_ID }} steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install deps run: npm ci - name: Set version shell: bash run: | if [[ "$GITHUB_REF" == refs/tags/v* ]]; then # Tag release: use version from tag VERSION="${GITHUB_REF_NAME#v}" else # workflow_dispatch: use short commit ID VERSION="${GITHUB_SHA:0:7}" fi echo "Setting version to ${VERSION}" npm pkg set version="${VERSION}" - name: Build package (macOS) if: matrix.os == 'macos-latest' env: CSC_IDENTITY_AUTO_DISCOVERY: "false" ELECTRON_BUILDER_PUBLISH: "never" run: npm run pack:mac - name: Build package (Windows) if: matrix.os == 'windows-latest' env: ELECTRON_BUILDER_PUBLISH: "never" run: npm run pack:win - name: Build package (Linux) if: matrix.os == 'ubuntu-latest' env: ELECTRON_BUILDER_PUBLISH: "never" run: npm run pack:linux - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: netcatty-${{ matrix.os }} path: | release/*.dmg release/*.exe release/*.msi release/*.AppImage release/*.deb release/*.rpm release/*.tar.gz if-no-files-found: ignore release: name: release runs-on: ubuntu-latest needs: build if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.publish_release) permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 - name: Download artifacts uses: actions/download-artifact@v4 with: path: artifacts merge-multiple: true - name: List artifacts run: ls -la artifacts/ - name: Generate Release Body run: node .github/scripts/generate-release-note.js env: GITHUB_REF_NAME: ${{ github.ref_name }} GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_SHA: ${{ github.sha }} - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: body_path: release_notes.md files: | artifacts/*.dmg artifacts/*.exe artifacts/*.AppImage artifacts/*.deb artifacts/*.rpm generate_release_notes: true fail_on_unmatched_files: false token: ${{ secrets.RELEASE_TOKEN }}