# Gitea Actions workflow — generic build template using the composite action. # Copy this file to: .gitea/workflows/build.yml in your repository. # # Adapt the two fields below to your project: # build-command : the command to run inside the ephemeral VM # artifact-source : the directory inside the VM where outputs are placed # # Runner label selects the guest OS automatically: # windows-build -> WinBuild2025 (WinRM/HTTPS transport) # linux-build -> LinuxBuild2404 (SSH transport) # # The composite action (Simone/local-ci-cd-system/.gitea/actions/local-ci-build) # handles the full VM lifecycle: clone template -> start -> build -> # collect artifacts -> upload to Gitea -> destroy VM. # No orchestration logic needed in each repo's workflow. name: Build (Local CI) on: push: branches: - main - develop - 'release/**' pull_request: branches: - main - develop workflow_dispatch: jobs: build: # Change to linux-build for Ubuntu 24.04 guest runs-on: windows-build timeout-minutes: 90 steps: # ── Invoke the full VM lifecycle via composite action ─────────────────── - uses: https://gitea.emulab.it/Simone/local-ci-cd-system/.gitea/actions/local-ci-build@main with: # --- adapt these two per-repository ----------------------------------- build-command: 'python build.py --dist-dir dist' # command run in VM artifact-source: 'dist' # output dir in VM # ---------------------------------------------------------------------- # Uncomment to clone repo with submodules inside the VM: # submodules: 'true' # Uncomment to clone via SSH alias instead of HTTPS (faster for large repos): # repo-url: 'ssh://gitea-ci/${{ github.repository }}.git' # use-git-clone: 'true' # Uncomment to inject secrets as env vars in the VM (never logged): # extra-guest-env-json: >- # {"SIGN_PASS":"${{ secrets.SIGN_PASS }}", # "GPG_KEY_ID":"${{ secrets.GPG_KEY_ID }}"} # Artifact name defaults to build-{run_id}-{sha}. # Uncomment to use a custom name (e.g. include ref_name for tag builds): # artifact-name: 'myproject-${{ github.ref_name }}' if-no-files-found: error # Step 4: Upload artifacts even on failure (for diagnostics) - name: Upload diagnostic logs on failure if: failure() uses: actions/upload-artifact@v3 with: name: build-logs-${{ github.sha }} path: F:\CI\Artifacts\${{ github.run_id }}-${{ github.run_attempt }}\*.log retention-days: 3 if-no-files-found: ignore --- # PARALLEL BUILD VARIANT (using matrix strategy) # Uncomment and adapt if you need to build multiple configurations in parallel. # # jobs: # build: # runs-on: windows-build # strategy: # matrix: # include: # - config: Release # vm_ip: "192.168.11.101" # - config: Debug # vm_ip: "192.168.11.102" # fail-fast: false # # steps: # - uses: actions/checkout@v4 # - name: Build (${{ matrix.config }}) # shell: pwsh # run: | # & scripts\Invoke-CIJob.ps1 ` # -JobId "${{ github.run_id }}-${{ matrix.config }}" ` # -RepoUrl "${{ github.server_url }}/${{ github.repository }}.git" ` # -Branch "${{ github.ref_name }}" ` # -Configuration "${{ matrix.config }}" ` # -VMIPAddress "${{ matrix.vm_ip }}" --- # CROSS-PLATFORM MATRIX BUILD (Windows + Linux VMs) # Runs the same build on both Windows and Linux ephemeral VMs in parallel. # Requires: # - runner/config.yaml labels include "windows-build:host" and "linux-build:host" # - Linux template provisioned: F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx # - SSH key at F:\CI\keys\ci_linux (ed25519, no passphrase), user ci_build # # jobs: # build: # strategy: # matrix: # target: [windows, linux] # fail-fast: false # # runs-on: ${{ matrix.target }}-build # # steps: # - uses: actions/checkout@v4 # # - name: Build on ${{ matrix.target }} # shell: pwsh # run: | # $ErrorActionPreference = 'Stop' # $ciScriptsDir = Join-Path $env:GITHUB_WORKSPACE 'scripts' # # $templatePath = if ('${{ matrix.target }}' -eq 'linux') { # $env:GITEA_CI_LINUX_TEMPLATE_PATH # F:\CI\Templates\LinuxBuild2404\LinuxBuild2404.vmx # } else { # $env:GITEA_CI_TEMPLATE_PATH # F:\CI\Templates\WinBuild2025\WinBuild2025.vmx # } # # & "$ciScriptsDir\Invoke-CIJob.ps1" ` # -JobId "${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.target }}" ` # -RepoUrl "${{ github.server_url }}/${{ github.repository }}.git" ` # -Branch "${{ github.ref_name }}" ` # -Commit "${{ github.sha }}" ` # -TemplatePath $templatePath ` # -BuildCommand 'make all' # # - name: Upload artifacts (${{ matrix.target }}) # if: success() # uses: actions/upload-artifact@v3 # with: # name: build-${{ matrix.target }}-${{ github.sha }} # path: F:\CI\Artifacts\${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.target }}\ # retention-days: 14 # if-no-files-found: error --- # COMPOSITE ACTION VARIANT (recommended for new repositories) # Uses the reusable composite action stored in the CI system repository. # This variant replaces the verbose inline shell block with a single `uses:` step. # The composite action handles: Invoke-CIJob.ps1 call + artifact upload + log upload. # # Reference: gitea/actions/local-ci-build/action.yml in this repository. # Deployed path in Gitea: Simone/local-ci-cd-system / .gitea/actions/local-ci-build/action.yml # # Minimum example (Windows build, Python project with submodules): # # name: Build (Composite) # # on: # push: # tags: # - 'v*' # workflow_dispatch: # # jobs: # build: # runs-on: windows-build # steps: # - uses: actions/checkout@v4 # - uses: https://gitea.emulab.it/Simone/local-ci-cd-system/.gitea/actions/local-ci-build@main # with: # build-command: 'python build_plugin.py --final --dist-dir dist' # artifact-source: 'dist' # submodules: 'true' # # Cross-platform matrix variant using the composite action: # # jobs: # build: # strategy: # matrix: # target: [windows, linux] # fail-fast: false # runs-on: ${{ matrix.target }}-build # steps: # - uses: actions/checkout@v4 # - uses: https://gitea.emulab.it/Simone/local-ci-cd-system/.gitea/actions/local-ci-build@main # with: # build-command: 'python build_plugin.py --final --dist-dir dist' # artifact-source: 'dist' # submodules: 'true' # guest-os: 'Auto' # artifact-name: 'build-${{ matrix.target }}-${{ github.sha }}'