Skip to content

Commit f651f6d

Browse files
committed
Github build workflow
1 parent 91078b2 commit f651f6d

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build and Version
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 tag --sort=-v:refname | Select-Object -First 1
34+
#$latestTag = git describe --tags --abbrev=0 | Select-Object -First 1
35+
36+
if ($latestTag -notmatch '^v\d+\.\d+\.\d+$') {
37+
Write-Error "Error: Could not find a valid vX.Y.Z tag in history. Found: '$latestTag'"
38+
exit 1
39+
}
40+
41+
# Parse and Increment
42+
$version = [version]$latestTag.Substring(1)
43+
$baseVersion = "$($version.Major).$($version.Minor).$($version.Build + 1)"
44+
45+
# Handle PR Suffix
46+
if ("${{ github.event_name }}" -eq "pull_request") {
47+
$shortSha = "${{ github.event.pull_request.head.sha }}".Substring(0, 7)
48+
$finalVersion = "$baseVersion-pr-$shortSha"
49+
} else {
50+
$finalVersion = $baseVersion
51+
}
52+
53+
# Export
54+
"NEW_VERSION=$finalVersion" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
55+
Write-Host "Building version: $finalVersion"
56+
57+
- name: Build
58+
shell: cmd
59+
env:
60+
APPVEYOR_BUILD_VERSION: ${{ steps.versioning.outputs.NEW_VERSION }}
61+
run: Src\Setup\__MakeFinal.bat
62+
63+
- name: Upload artifacts
64+
uses: actions/upload-artifact@v7
65+
with:
66+
name: OpenShellArtifacts
67+
path: |
68+
Src/Setup/Final/OpenShellSetup*.exe
69+
Src/Setup/Final/OpenShellSymbols_*.7z
70+
build/bin/Release/Utility.exe
71+
72+
release:
73+
needs: build
74+
runs-on: ubuntu-latest # Cheaper/faster than windows for just uploading
75+
steps:
76+
- name: Download artifacts
77+
uses: actions/download-artifact@v8
78+
with:
79+
name: OpenShellArtifacts
80+
81+
- name: Display structure of downloaded files
82+
run: ls -R

0 commit comments

Comments
 (0)