|
| 1 | +name: Build |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read # Default to secure |
| 5 | + |
| 6 | +on: |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + paths: |
| 11 | + - 'Src/**' |
| 12 | + - 'Localization/**' |
| 13 | + - '.github/workflows/build.yml' |
| 14 | + |
| 15 | + workflow_dispatch: # allows manual trigger for main/master |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: windows-2022 |
| 20 | + outputs: |
| 21 | + new_version: ${{ steps.versioning.outputs.NEW_VERSION }} |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v6 |
| 25 | + with: |
| 26 | + fetch-depth: 0 # Essential to see all tags |
| 27 | + |
| 28 | + - name: Prepare version |
| 29 | + id: versioning |
| 30 | + shell: pwsh |
| 31 | + run: | |
| 32 | + # Fetch latest tag |
| 33 | + $latestTag = git describe --tags --abbrev=0 2>$null |
| 34 | +
|
| 35 | + if ($latestTag -notmatch '^v\d+\.\d+\.\d+$') { |
| 36 | + Write-Error "Error: Could not find a valid vX.Y.Z tag in history. Found: '$latestTag'" |
| 37 | + exit 1 |
| 38 | + } |
| 39 | + |
| 40 | + # Parse and Increment |
| 41 | + $version = [version]$latestTag.Substring(1) |
| 42 | + $baseVersion = "$($version.Major).$($version.Minor).$($version.Build + 1)" |
| 43 | +
|
| 44 | + # Handle PR Suffix |
| 45 | + if ("${{ github.event_name }}" -eq "pull_request") { |
| 46 | + $shortSha = "${{ github.event.pull_request.head.sha }}".Substring(0, 7) |
| 47 | + $finalVersion = "$baseVersion-pr-$shortSha" |
| 48 | + } else { |
| 49 | + $finalVersion = $baseVersion |
| 50 | + } |
| 51 | + |
| 52 | + # Export |
| 53 | + "NEW_VERSION=$finalVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 54 | + Write-Host "Building version: $finalVersion" |
| 55 | +
|
| 56 | + - name: Build |
| 57 | + shell: cmd |
| 58 | + env: |
| 59 | + APPVEYOR_BUILD_VERSION: ${{ steps.versioning.outputs.NEW_VERSION }} |
| 60 | + run: Src\Setup\__MakeFinal.bat |
| 61 | + |
| 62 | + - name: Upload artifacts |
| 63 | + uses: actions/upload-artifact@v7 |
| 64 | + with: |
| 65 | + name: OpenShell |
| 66 | + path: | |
| 67 | + Src/Setup/Final/ |
| 68 | + !Src/Setup/Final/OpenShellLoc.zip |
| 69 | +
|
| 70 | + release: |
| 71 | + if: github.event_name == 'workflow_dispatch' # Only manual master builds |
| 72 | + needs: build |
| 73 | + runs-on: ubuntu-latest # Cheaper/faster than windows for just uploading |
| 74 | + permissions: |
| 75 | + contents: write # Elevate permissions ONLY for this job |
| 76 | + steps: |
| 77 | + - name: Download artifacts |
| 78 | + uses: actions/download-artifact@v8 |
| 79 | + with: |
| 80 | + name: OpenShell |
| 81 | + |
| 82 | + - name: Create GitHub Release |
| 83 | + uses: softprops/action-gh-release@v3 |
| 84 | + with: |
| 85 | + tag_name: v${{ needs.build.outputs.new_version }} |
| 86 | + name: ${{ needs.build.outputs.new_version }} |
| 87 | + generate_release_notes: true |
| 88 | + prerelease: true |
| 89 | + files: | |
| 90 | + OpenShellSetup*.exe |
| 91 | + OpenShellSymbols_*.7z |
| 92 | + Utility.exe |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments