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