From 788f6a81bd49a8d50cf0580be7d13173d9d8b20b Mon Sep 17 00:00:00 2001 From: Satyamisme Date: Thu, 20 Feb 2025 17:18:04 +0300 Subject: [PATCH 1/4] Create workflow main.yml added option to build via workflow --- .github/workflows/main.yml | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8c3d2fe --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,64 @@ +name: Build and Release balong-usbdload # Name of your workflow - will be displayed in GitHub Actions + +on: + push: + branches: [ "main" ] # Trigger workflow on code push to the 'main' branch + pull_request: + branches: [ "main" ] # Trigger workflow on pull requests against the 'main' branch + workflow_dispatch: # Enable manual triggering of the workflow from GitHub UI + +jobs: # Define the jobs that will run in this workflow + build: # Define a job named 'build' + runs-on: ubuntu-latest # Specify that this job will run on an Ubuntu Linux runner + + steps: # Define the steps to be executed within the 'build' job + - name: Checkout code # Step 1: Checkout your repository code + uses: actions/checkout@v4 # Uses the official 'checkout' action to get your code onto the runner + + - name: Build using Make # Step 2: Compile your C programs using 'make' + run: make all # Executes the command 'make all' in the runner's shell. This uses your Makefile. + + - name: Zip Binaries for Release # Step 3: Create a ZIP archive of the compiled binaries + run: | # 'run: |' allows multi-line shell commands + zip -r compiled-binaries.zip balong-usbdload ptable-injector loader-patch ptable-list + # This command creates a ZIP file named 'compiled-binaries.zip' + # and adds the compiled executables (balong-usbdload, etc.) to it. + # IMPORTANT: This step MUST come BEFORE uploading the release asset! + + - name: Upload binaries as artifacts # Step 4: (Optional but Recommended) Upload binaries as workflow artifacts + uses: actions/upload-artifact@v4 # Uses the official 'upload-artifact' action + with: + name: compiled-binaries # Name of the artifact (can be anything) + path: | # Files to include in the artifact + balong-usbdload + ptable-injector + loader-patch + ptable-list + # Artifacts are useful for storing build outputs temporarily and can be downloaded from the workflow run summary. + # This is separate from creating a release, but good practice for CI/CD. + + - name: Create Release # Step 5: Create a GitHub Release + id: create_release # Give this step an ID so we can refer to its output later + uses: actions/create-release@v1 # Uses the 'create-release' action + env: # Environment variables for this step + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass the GitHub token for authentication + with: # Configuration for the 'create-release' action + tag_name: v${{ github.run_number }} # Tag name for the release (e.g., v1, v2, based on workflow run number) + release_name: Release v${{ github.run_number }} # Display name for the release + body: | # Description for the release + Automated release of compiled binaries from workflow run #${{ github.run_number }}. + See workflow run logs for details. + draft: false # Set to 'false' to publish the release immediately (not as a draft) + prerelease: false # Set to 'false' to make it a stable release (not a pre-release) + + - name: Upload Release Asset # Step 6: Upload the ZIP file as a Release Asset + uses: actions/upload-release-asset@v1 # Uses the 'upload-release-asset' action + env: # Environment variables for this step + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass the GitHub token for authentication + with: # Configuration for the 'upload-release-asset' action + upload_url: ${{ steps.create_release.outputs.upload_url }} # Get the upload URL from the 'Create Release' step (using its ID) + asset_path: compiled-binaries.zip # Path to the ZIP file we created in Step 3 + asset_name: compiled-binaries.zip # Filename for the asset in the release (how it will be downloaded) + asset_content_type: application/zip # MIME type of the asset (ZIP file) + +# END OF WORKFLOW DEFINITION From 79a1c7062ec58f585f7983e7790bf11a50a344f0 Mon Sep 17 00:00:00 2001 From: Satyamisme Date: Thu, 20 Feb 2025 17:47:53 +0300 Subject: [PATCH 2/4] Update main.yml --- .github/workflows/main.yml | 140 ++++++++++++++++++++++++------------- 1 file changed, 93 insertions(+), 47 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8c3d2fe..1dd3ae6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,64 +1,110 @@ -name: Build and Release balong-usbdload # Name of your workflow - will be displayed in GitHub Actions +name: Build and Release balong_flash (Linux & Windows) on: push: - branches: [ "main" ] # Trigger workflow on code push to the 'main' branch + branches: [ "main" ] pull_request: - branches: [ "main" ] # Trigger workflow on pull requests against the 'main' branch - workflow_dispatch: # Enable manual triggering of the workflow from GitHub UI + branches: [ "main" ] + workflow_dispatch: -jobs: # Define the jobs that will run in this workflow - build: # Define a job named 'build' - runs-on: ubuntu-latest # Specify that this job will run on an Ubuntu Linux runner +jobs: + build-linux: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 - steps: # Define the steps to be executed within the 'build' job - - name: Checkout code # Step 1: Checkout your repository code - uses: actions/checkout@v4 # Uses the official 'checkout' action to get your code onto the runner + - name: Build using Make (Linux) + run: make all - - name: Build using Make # Step 2: Compile your C programs using 'make' - run: make all # Executes the command 'make all' in the runner's shell. This uses your Makefile. + - name: Zip Binary for Release (Linux) + run: zip balong_flash-linux.zip balong_flash balong-usbdload ptable-injector loader-patch ptable-list # Zip all binaries - - name: Zip Binaries for Release # Step 3: Create a ZIP archive of the compiled binaries - run: | # 'run: |' allows multi-line shell commands - zip -r compiled-binaries.zip balong-usbdload ptable-injector loader-patch ptable-list - # This command creates a ZIP file named 'compiled-binaries.zip' - # and adds the compiled executables (balong-usbdload, etc.) to it. - # IMPORTANT: This step MUST come BEFORE uploading the release asset! - - - name: Upload binaries as artifacts # Step 4: (Optional but Recommended) Upload binaries as workflow artifacts - uses: actions/upload-artifact@v4 # Uses the official 'upload-artifact' action + - name: Upload binaries as artifacts (Linux) + uses: actions/upload-artifact@v4 with: - name: compiled-binaries # Name of the artifact (can be anything) - path: | # Files to include in the artifact + name: balong_flash-binaries-linux + path: | + balong_flash balong-usbdload ptable-injector loader-patch ptable-list - # Artifacts are useful for storing build outputs temporarily and can be downloaded from the workflow run summary. - # This is separate from creating a release, but good practice for CI/CD. - - name: Create Release # Step 5: Create a GitHub Release - id: create_release # Give this step an ID so we can refer to its output later - uses: actions/create-release@v1 # Uses the 'create-release' action - env: # Environment variables for this step - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass the GitHub token for authentication - with: # Configuration for the 'create-release' action - tag_name: v${{ github.run_number }} # Tag name for the release (e.g., v1, v2, based on workflow run number) - release_name: Release v${{ github.run_number }} # Display name for the release - body: | # Description for the release - Automated release of compiled binaries from workflow run #${{ github.run_number }}. + - name: Create Release (Linux) + id: create_release_linux + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ github.run_number }} + release_name: Release v${{ github.run_number }} + body: | + Automated release of compiled binaries (Linux) from workflow run #${{ github.run_number }}. See workflow run logs for details. - draft: false # Set to 'false' to publish the release immediately (not as a draft) - prerelease: false # Set to 'false' to make it a stable release (not a pre-release) + draft: false + prerelease: false + + - name: Upload Release Asset (Linux) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release_linux.outputs.upload_url }} + asset_path: balong_flash-linux.zip + asset_name: balong_flash-linux.zip + asset_content_type: application/zip + + build-windows: + runs-on: windows-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up MSYS2 (MinGW) + uses: msys2/setup-msys2@v2 + with: + msys2-packages: mingw-w64-x86_64-gcc mingw-w64-x86_64-make zlib # Install GCC, Make, zlib for MinGW + update: true + + - name: Build using Make (Windows MinGW) + shell: bash # Important: Use bash shell provided by MSYS2 + run: make all + + - name: Zip Binary for Release (Windows) + run: Compress-Archive -Path balong_flash,balong-usbdload,ptable-injector,loader-patch,ptable-list -DestinationPath balong_flash-windows.zip # PowerShell for zipping - - name: Upload Release Asset # Step 6: Upload the ZIP file as a Release Asset - uses: actions/upload-release-asset@v1 # Uses the 'upload-release-asset' action - env: # Environment variables for this step - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass the GitHub token for authentication - with: # Configuration for the 'upload-release-asset' action - upload_url: ${{ steps.create_release.outputs.upload_url }} # Get the upload URL from the 'Create Release' step (using its ID) - asset_path: compiled-binaries.zip # Path to the ZIP file we created in Step 3 - asset_name: compiled-binaries.zip # Filename for the asset in the release (how it will be downloaded) - asset_content_type: application/zip # MIME type of the asset (ZIP file) + - name: Upload binaries as artifacts (Windows) + uses: actions/upload-artifact@v4 + with: + name: balong_flash-binaries-windows + path: | + balong_flash + balong-usbdload + ptable-injector + loader-patch + ptable-list -# END OF WORKFLOW DEFINITION + - name: Create Release (Windows) + id: create_release_windows # Use different ID to avoid conflicts + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ github.run_number }} + release_name: Release v${{ github.run_number }} + body: | + Automated release of compiled binaries (Windows) from workflow run #${{ github.run_number }}. + See workflow run logs for details. + draft: false + prerelease: false + + - name: Upload Release Asset (Windows) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release_windows.outputs.upload_url }} # Use ID for Windows release step + asset_path: balong_flash-windows.zip + asset_name: balong_flash-windows.zip + asset_content_type: application/zip From ea35abe6c8efdc1abad49638e520762d0cda98b6 Mon Sep 17 00:00:00 2001 From: Satyamisme Date: Thu, 20 Feb 2025 17:52:26 +0300 Subject: [PATCH 3/4] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1dd3ae6..393358f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,9 +67,9 @@ jobs: msys2-packages: mingw-w64-x86_64-gcc mingw-w64-x86_64-make zlib # Install GCC, Make, zlib for MinGW update: true - - name: Build using Make (Windows MinGW) + - name: Build using Make (Windows MinGW) - Add include path shell: bash # Important: Use bash shell provided by MSYS2 - run: make all + run: make CFLAGS="-I/mingw64/include $CFLAGS" all # Add MinGW include path to CFLAGS - name: Zip Binary for Release (Windows) run: Compress-Archive -Path balong_flash,balong-usbdload,ptable-injector,loader-patch,ptable-list -DestinationPath balong_flash-windows.zip # PowerShell for zipping From bdb4a83e729f4a725a54c220235fcb0525bae169 Mon Sep 17 00:00:00 2001 From: Satyamisme Date: Thu, 20 Feb 2025 17:57:12 +0300 Subject: [PATCH 4/4] Update main.yml --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 393358f..593113d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,9 +67,11 @@ jobs: msys2-packages: mingw-w64-x86_64-gcc mingw-w64-x86_64-make zlib # Install GCC, Make, zlib for MinGW update: true - - name: Build using Make (Windows MinGW) - Add include path + - name: Build using Make (Windows MinGW) - Set PATH and include path shell: bash # Important: Use bash shell provided by MSYS2 - run: make CFLAGS="-I/mingw64/include $CFLAGS" all # Add MinGW include path to CFLAGS + run: | + PATH="/c/msys64/mingw64/bin:$PATH" # Prepend MSYS2 MinGW bin to PATH + make CFLAGS="-I/mingw64/include $CFLAGS" all - name: Zip Binary for Release (Windows) run: Compress-Archive -Path balong_flash,balong-usbdload,ptable-injector,loader-patch,ptable-list -DestinationPath balong_flash-windows.zip # PowerShell for zipping