From 38e1dfa5b0746228bc7c911540fbda776178e70e Mon Sep 17 00:00:00 2001 From: Tharindu Jayawardhana Date: Sat, 15 Jun 2024 14:24:06 +0530 Subject: [PATCH] Update build.yml --- .github/workflows/build.yml | 50 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64f6c62..5325d5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,47 +1,61 @@ -name: Build -on: [push, pull_request] +name: Build and Release Electron App + +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: build_on_win: runs-on: windows-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@master + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 with: - node-version: 19 - - name: install dependencies + node-version: 14 # Adjust Node.js version as per your project + + - name: Install dependencies run: npm install - - name: build + + - name: Build Electron app for Windows run: npm run electron:package:win env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish Artifact uses: actions/upload-artifact@v2 with: name: Electron-app - path: | - dist/*.exe + path: dist/*.exe + - name: Create Release id: create_release uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} + tag_name: v1.0.0 # Replace with your desired tag name + release_name: Release v1.0.0 # Replace with your desired release name body: | Changes in this Release - First Change - Second Change draft: false prerelease: false + - name: Upload Release Asset - id: upload-release-asset + id: upload-release-asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./my-artifact.zip - asset_name: my-artifact.zip - asset_content_type: application/zip + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/*.exe # Path to the artifact + asset_name: electron-app-windows.exe # Name of the asset + asset_content_type: application/octet-stream