Skip to content

Commit 8f3066a

Browse files
committed
Update CI, build and other files
1 parent 90841b6 commit 8f3066a

20 files changed

+195
-279
lines changed

.clang-format

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
---
2-
BasedOnStyle: Microsoft
2+
DisableFormat: true
33
---
44
Language: Cpp
5+
BasedOnStyle: Microsoft
56

67
AccessModifierOffset: -4
8+
AllowAllArgumentsOnNextLine: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
710
AlwaysBreakTemplateDeclarations: Yes
11+
BinPackArguments: false
12+
BinPackParameters: false
13+
BreakAfterAttributes: Always
814
BreakBeforeBraces: Allman
915
BreakConstructorInitializers: BeforeComma
1016
BreakInheritanceList: BeforeComma
17+
InsertNewlineAtEOF: true
1118
KeepEmptyLinesAtTheStartOfBlocks: false
1219
PointerAlignment: Left
1320
SpaceAfterTemplateKeyword: false
21+
22+
IntegerLiteralSeparator:
23+
Binary: 4
24+
BinaryMinDigits: 4

.editorconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ indent_style = space
77
insert_final_newline = true
88
trim_trailing_whitespace = true
99

10-
[*.{c,h,cpp,hpp}]
11-
indent_size = 4
12-
1310
[*.{md,yml}]
1411
indent_size = 2
1512

16-
[{CMakeLists.txt,*.cmake}]
13+
[{.clang-format,CMakeLists.txt,*.cmake}]
1714
indent_size = 2
15+
16+
[*.{cpp,hpp}]
17+
indent_size = 4

.github/workflows/clang-format.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/build.yml renamed to .github/workflows/cpp-build.yml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@ name: Build Workflow
33
on:
44
push:
55
branches: '**'
6+
paths:
7+
- .github/workflows/cpp-build.yml
8+
- cmake/**
9+
- deps/**
10+
11+
- '**.hpp'
12+
- '**.cpp'
13+
- '**/CMakeLists.txt'
614
pull_request:
15+
paths:
16+
- .github/workflows/cpp-build.yml
17+
- cmake/**
18+
- deps/**
19+
20+
- '**.hpp'
21+
- '**.cpp'
22+
- '**/CMakeLists.txt'
723

824
jobs:
925
build:
@@ -16,18 +32,20 @@ jobs:
1632

1733
steps:
1834
- name: Checkout
19-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
2036
with:
2137
fetch-depth: 0
2238
submodules: recursive
2339

24-
- name: Create environment variables
40+
- name: Set commit SHA environment variable
2541
run: |
26-
$sha = (git rev-parse --short $env:GITHUB_SHA)
27-
echo "RED3EXT_COMMIT_SHA=${sha}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append
42+
$sha = (git rev-parse --short ${env:GITHUB_SHA})
43+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_BUILD_COMMIT_SHA=${sha}"
2844
45+
- name: Set build configuration environment variable
46+
run: |
2947
$config = "${{ matrix.config }}".ToLower()
30-
echo "RED3EXT_PRETTY_CONFIG=${config}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append
48+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_BUILD_CONFIG=${config}"
3149
3250
- name: Create build directory
3351
run: mkdir build
@@ -57,7 +75,7 @@ jobs:
5775
--config ${{ matrix.config }}
5876
5977
- name: Upload artifacts
60-
uses: actions/upload-artifact@v3
78+
uses: actions/upload-artifact@v4
6179
with:
62-
name: red3ext-${{ env.RED3EXT_PRETTY_CONFIG }}-${{ env.RED3EXT_COMMIT_SHA }}
80+
name: red3ext-${{ env.RED3EXT_BUILD_CONFIG }}-${{ env.RED3EXT_BUILD_COMMIT_SHA }}
6381
path: build/install

.github/workflows/cpp-format.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Format Workflow (C++)
2+
3+
on:
4+
push:
5+
branches: '**'
6+
paths:
7+
- .github/workflows/cpp-format.yml
8+
9+
- '**.hpp'
10+
- '**.cpp'
11+
- .clang-format
12+
13+
pull_request:
14+
paths:
15+
- .github/workflows/cpp-format.yml
16+
17+
- '**.hpp'
18+
- '**.cpp'
19+
- .clang-format
20+
21+
env:
22+
LLVM_VERSION: 18
23+
24+
jobs:
25+
format:
26+
name: Check the formatting
27+
runs-on: windows-latest
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Pin to a specific version
36+
run: |
37+
$latestChocoVersion = (Resolve-ChocoPackageVersion -TargetVersion ${env:LLVM_VERSION} -PackageName 'llvm')
38+
Install-ChocoPackage -PackageName llvm -ArgumentList '--allow-downgrade', '--version', ${latestChocoVersion}
39+
40+
- name: Determine BASE commit (push)
41+
if: github.event_name == 'push'
42+
env:
43+
GIT_COMMIT_SHA: ${{ github.event.before }}
44+
GIT_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
45+
run: |
46+
$commitSha = ${env:GIT_COMMIT_SHA}
47+
if (${commitSha} -match "^0+$") {
48+
Write-Host "'before' is all zeros. This is likely a new branch. Finding a common ancestor with the default branch."
49+
50+
$defaultBranch = ${env:GIT_DEFAULT_BRANCH}
51+
$commitSha = (git merge-base --fork-point "remotes/origin/${defaultBranch}")
52+
53+
if ([string]::IsNullOrEmpty(${commitSha})) {
54+
Write-Host "No common ancestor found, using the first commit in the repository."
55+
$commitSha = (git rev-list --max-parents=0 --reverse HEAD | Select-Object -First 1)
56+
}
57+
}
58+
59+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_COMMIT_BEFORE=${commitSha}"
60+
exit 0
61+
62+
- name: Determine BASE commit (pull request)
63+
if: github.event_name == 'pull_request'
64+
env:
65+
GIT_COMMIT_SHA: ${{ github.event.pull_request.base.sha }}
66+
run: |
67+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_COMMIT_BEFORE=${env:GIT_COMMIT_SHA}"
68+
69+
- name: Determine HEAD commit
70+
env:
71+
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
72+
run: |
73+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_COMMIT_AFTER=${env:GIT_COMMIT_SHA}"
74+
75+
- name: Run clang-format
76+
run: |
77+
git `
78+
-c core.autocrlf=false `
79+
-c core.eol=lf `
80+
-c color.ui=always `
81+
clang-format `
82+
--style file `
83+
--diff ${env:RED3EXT_COMMIT_BEFORE} ${env:RED3EXT_COMMIT_AFTER}

.github/workflows/release.yml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Release Workflow
22

33
on:
4-
push:
5-
tags: '*'
4+
release:
5+
types: [published]
66

77
env:
8-
RED3EXT_CONFIG: Release
98
RED3EXT_VERSION: ${{ github.ref_name }}
10-
RED3EXT_HASH_ALGORITHM: SHA256
9+
RED3EXT_BUILD_CONFIG: Release
10+
RED3EXT_CHECKSUM_ALGORITHM: SHA256
1111

1212
jobs:
1313
release:
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020
with:
2121
submodules: recursive
2222

@@ -38,60 +38,54 @@ jobs:
3838
run: |
3939
cmake `
4040
--build . `
41-
--config ${env:RED3EXT_CONFIG}
41+
--config ${env:RED3EXT_BUILD_CONFIG}
4242
4343
- name: Install
4444
working-directory: build
4545
run: |
4646
cmake `
4747
--install . `
4848
--prefix "${{ github.workspace }}/build/install" `
49-
--config ${env:RED3EXT_CONFIG}
50-
51-
- name: Copy license files
52-
working-directory: build/install
53-
run: |
54-
Copy-Item -Path ../../LICENSE.md -Destination ./red3ext/LICENSE.txt
55-
Copy-Item -Path ../../THIRD_PARTY_LICENSES.md -Destination ./red3ext/THIRD_PARTY_LICENSES.txt
49+
--config ${env:RED3EXT_BUILD_CONFIG}
5650
57-
- name: Create ZIP
51+
- name: Create release package
5852
working-directory: build/install
5953
run: 7z a -r red3ext-${env:RED3EXT_VERSION}.zip *.dll *.txt
6054

61-
- name: Create symbols ZIP
55+
- name: Create debug symbols package
6256
working-directory: build/install
6357
run: 7z a -r red3ext-symbols-${env:RED3EXT_VERSION}.zip *.pdb
6458

65-
- name: Compute ZIP's checksum
59+
- name: Compute package checksum
6660
working-directory: build/install
6761
run: |
68-
$Hash = Get-FileHash -Algorithm ${env:RED3EXT_HASH_ALGORITHM} -Path red3ext-${env:RED3EXT_VERSION}.zip
69-
$Hash | Format-List
62+
$fileHash = Get-FileHash -Algorithm ${env:RED3EXT_CHECKSUM_ALGORITHM} -Path red3ext-${env:RED3EXT_VERSION}.zip
63+
$fileHash | Format-List
7064
71-
$Checksum = $Hash | ForEach-Object { $_.Hash }
72-
echo "RED3EXT_ZIP_SHA256=${Checksum}" | Out-File -FilePath ${env:GITHUB_ENV} -Encoding UTF8 -Append
65+
$checksum = $fileHash.Hash
66+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_CHECKSUM_PACKAGE=${checksum}"
7367
74-
- name: Compute symbols ZIP's checksum
68+
- name: Compute debug symbols checksum
7569
working-directory: build/install
7670
run: |
77-
$Hash = Get-FileHash -Algorithm ${env:RED3EXT_HASH_ALGORITHM} -Path red3ext-symbols-${env:RED3EXT_VERSION}.zip
78-
$Hash | Format-List
71+
$fileHash = Get-FileHash -Algorithm ${env:RED3EXT_CHECKSUM_ALGORITHM} -Path red3ext-symbols-${env:RED3EXT_VERSION}.zip
72+
$fileHash | Format-List
7973
80-
$Checksum = $Hash | ForEach-Object { $_.Hash }
81-
echo "RED3EXT_SYMBOLS_SHA256=${Checksum}" | Out-File -FilePath ${env:GITHUB_ENV} -Encoding UTF8 -Append
74+
$checksum = $fileHash.Hash
75+
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_CHECKSUM_SYMBOLS=${checksum}"
8276
8377
- name: Upload assets
84-
uses: softprops/action-gh-release@v1
78+
uses: softprops/action-gh-release@v2
8579
with:
8680
append_body: true
8781
body: |
8882
8983
## Checksums
9084
9185
- red3ext-${{ env.RED3EXT_VERSION }}.zip
92-
- **${{ env.RED3EXT_HASH_ALGORITHM }}**: ${{ env.RED3EXT_ZIP_SHA256 }}
86+
- **${{ env.RED3EXT_CHECKSUM_ALGORITHM }}**: ${{ env.RED3EXT_CHECKSUM_PACKAGE }}
9387
- red3ext-symbols-${{ env.RED3EXT_VERSION }}.zip
94-
- **${{ env.RED3EXT_HASH_ALGORITHM }}**: ${{ env.RED3EXT_SYMBOLS_SHA256 }}
88+
- **${{ env.RED3EXT_CHECKSUM_ALGORITHM }}**: ${{ env.RED3EXT_CHECKSUM_SYMBOLS }}
9589
files: |
9690
build/install/red3ext-${{ env.RED3EXT_VERSION }}.zip
9791
build/install/red3ext-symbols-${{ env.RED3EXT_VERSION }}.zip

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
build/
2-
3-
src/ported/Version.hpp

0 commit comments

Comments
 (0)