added Linux chmod permissions #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Builds and Releasing | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| id-token: write | |
| packages: write | |
| jobs: | |
| build-unix: | |
| name: Build for UNIX | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Clang | |
| run: sudo apt-get update && sudo apt-get install -y clang | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Create dist/gha directory | |
| run: mkdir -p dist/gha | |
| - name: Compile GHA Launcher (UNIX) | |
| run: clang ./src/gha/gha.c -o ./dist/gha/gha | |
| - name: Run GHA Launcher (UNIX Build & Package) | |
| run: | | |
| chmod +x ./build.sh | |
| ./dist/gha/gha | |
| - name: Upload UNIX Binary Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tread-bin-UNIX | |
| path: ./tread-bin-UNIX.zip | |
| build-windows: | |
| name: Build for Windows | |
| runs-on: windows-latest | |
| steps: | |
| - name: Install MSYS2 via Chocolatey | |
| # MSYS2 provides a Unix-like environment on Windows and its own package manager (pacman) | |
| # which we'll use to install the MinGW-w64 compatible Clang toolchain. | |
| run: choco install msys2 --no-progress --limit-output | |
| shell: powershell | |
| - name: Add MSYS2 bin to PATH | |
| # Add the MSYS2's bin directory to PATH so pacman can be executed | |
| run: | | |
| $msys2Path = "C:\tools\msys64\usr\bin" # Default installation path for Chocolatey's msys2 | |
| Add-Content -Path $env:GITHUB_PATH -Value $msys2Path | |
| echo "Added $msys2Path to GITHUB_PATH" | |
| shell: powershell | |
| - name: Install MinGW-w64 Clang via Pacman | |
| # Use MSYS2's pacman to install the Clang toolchain that targets MinGW-w64. | |
| # This ensures it uses the GNU C Runtime (CRT) instead of MSVC's UCRT. | |
| # Run in bash shell provided by MSYS2 for pacman commands. | |
| run: | | |
| C:/tools/msys64/usr/bin/bash.exe -lc "pacman --noconfirm -S mingw-w64-x86_64-clang" | |
| shell: powershell | |
| - name: Add MinGW-w64 Clang to PATH | |
| run: | | |
| $mingwClangPath = "C:\tools\msys64\mingw64\bin" | |
| Add-Content -Path $env:GITHUB_PATH -Value $mingwClangPath | |
| echo "Added $mingwClangPath to GITHUB_PATH" | |
| shell: powershell | |
| - name: Verify Clang installation and target | |
| run: clang --version | |
| shell: powershell | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Create dist\gha directory | |
| run: mkdir -p dist\gha | |
| shell: powershell | |
| - name: Compile GHA Launcher (Windows) | |
| run: clang ./src/gha/gha.c -o ./dist/gha/gha.exe | |
| shell: powershell | |
| - name: Run GHA Launcher (Windows Build & Package) | |
| run: .\dist\gha\gha.exe | |
| shell: powershell | |
| - name: Upload Windows Binary Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tread-bin-WIN | |
| path: ./tread-bin-WIN.zip | |
| create-release: | |
| name: Create Combined Draft Release | |
| runs-on: ubuntu-latest | |
| # This job depends on both build jobs completing successfully | |
| needs: [build-unix, build-windows] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Download UNIX Binary Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tread-bin-UNIX | |
| path: ./. | |
| - name: Download Windows Binary Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: tread-bin-WIN | |
| path: ./. | |
| - name: Extract short SHA | |
| id: extract_sha | |
| shell: bash | |
| run: | | |
| full_sha="${{ github.sha }}" | |
| short_sha="${full_sha:0:7}" | |
| echo "short_sha=$short_sha" >> "$GITHUB_OUTPUT" | |
| - name: Extract commit description | |
| id: extract_desc | |
| shell: bash | |
| run: | | |
| # Use github.event.head_commit.message to get the full commit message. | |
| # tail -n +3 attempts to remove the first two lines (subject line and empty line), | |
| # assuming a conventional commit message structure. Adjust if your messages vary. | |
| desc=$(echo "${{ github.event.head_commit.message }}" | tail -n +3) | |
| echo "commit_description<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$desc" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Create Draft GitHub Release with Both Assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v | |
| name: v | ${{ steps.extract_sha.outputs.short_sha }} | |
| draft: true | |
| prerelease: true | |
| body: | | |
| v | ${{ steps.extract_sha.outputs.short_sha }} | |
| **Triggered by committer:** @${{ github.actor }} | |
| --- | |
| # What's changed? | |
| ${{ steps.extract_desc.outputs.commit_description }} | |
| files: | | |
| ./tread-bin-UNIX.zip | |
| ./tread-bin-WIN.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for release creation |