Skip to content

Commit

Permalink
Update CI, build and other files
Browse files Browse the repository at this point in the history
  • Loading branch information
wopss committed Jan 6, 2025
1 parent 90841b6 commit 8f3066a
Show file tree
Hide file tree
Showing 20 changed files with 195 additions and 279 deletions.
13 changes: 12 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
---
BasedOnStyle: Microsoft
DisableFormat: true
---
Language: Cpp
BasedOnStyle: Microsoft

AccessModifierOffset: -4
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakAfterAttributes: Always
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
PointerAlignment: Left
SpaceAfterTemplateKeyword: false

IntegerLiteralSeparator:
Binary: 4
BinaryMinDigits: 4
8 changes: 4 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{c,h,cpp,hpp}]
indent_size = 4

[*.{md,yml}]
indent_size = 2

[{CMakeLists.txt,*.cmake}]
[{.clang-format,CMakeLists.txt,*.cmake}]
indent_size = 2

[*.{cpp,hpp}]
indent_size = 4
44 changes: 0 additions & 44 deletions .github/workflows/clang-format.yml

This file was deleted.

32 changes: 25 additions & 7 deletions .github/workflows/build.yml → .github/workflows/cpp-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,23 @@ name: Build Workflow
on:
push:
branches: '**'
paths:
- .github/workflows/cpp-build.yml
- cmake/**
- deps/**

- '**.hpp'
- '**.cpp'
- '**/CMakeLists.txt'
pull_request:
paths:
- .github/workflows/cpp-build.yml
- cmake/**
- deps/**

- '**.hpp'
- '**.cpp'
- '**/CMakeLists.txt'

jobs:
build:
Expand All @@ -16,18 +32,20 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Create environment variables
- name: Set commit SHA environment variable
run: |
$sha = (git rev-parse --short $env:GITHUB_SHA)
echo "RED3EXT_COMMIT_SHA=${sha}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append
$sha = (git rev-parse --short ${env:GITHUB_SHA})
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_BUILD_COMMIT_SHA=${sha}"
- name: Set build configuration environment variable
run: |
$config = "${{ matrix.config }}".ToLower()
echo "RED3EXT_PRETTY_CONFIG=${config}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_BUILD_CONFIG=${config}"
- name: Create build directory
run: mkdir build
Expand Down Expand Up @@ -57,7 +75,7 @@ jobs:
--config ${{ matrix.config }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: red3ext-${{ env.RED3EXT_PRETTY_CONFIG }}-${{ env.RED3EXT_COMMIT_SHA }}
name: red3ext-${{ env.RED3EXT_BUILD_CONFIG }}-${{ env.RED3EXT_BUILD_COMMIT_SHA }}
path: build/install
83 changes: 83 additions & 0 deletions .github/workflows/cpp-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Format Workflow (C++)

on:
push:
branches: '**'
paths:
- .github/workflows/cpp-format.yml

- '**.hpp'
- '**.cpp'
- .clang-format

pull_request:
paths:
- .github/workflows/cpp-format.yml

- '**.hpp'
- '**.cpp'
- .clang-format

env:
LLVM_VERSION: 18

jobs:
format:
name: Check the formatting
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Pin to a specific version
run: |
$latestChocoVersion = (Resolve-ChocoPackageVersion -TargetVersion ${env:LLVM_VERSION} -PackageName 'llvm')
Install-ChocoPackage -PackageName llvm -ArgumentList '--allow-downgrade', '--version', ${latestChocoVersion}
- name: Determine BASE commit (push)
if: github.event_name == 'push'
env:
GIT_COMMIT_SHA: ${{ github.event.before }}
GIT_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
$commitSha = ${env:GIT_COMMIT_SHA}
if (${commitSha} -match "^0+$") {
Write-Host "'before' is all zeros. This is likely a new branch. Finding a common ancestor with the default branch."
$defaultBranch = ${env:GIT_DEFAULT_BRANCH}
$commitSha = (git merge-base --fork-point "remotes/origin/${defaultBranch}")
if ([string]::IsNullOrEmpty(${commitSha})) {
Write-Host "No common ancestor found, using the first commit in the repository."
$commitSha = (git rev-list --max-parents=0 --reverse HEAD | Select-Object -First 1)
}
}
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_COMMIT_BEFORE=${commitSha}"
exit 0
- name: Determine BASE commit (pull request)
if: github.event_name == 'pull_request'
env:
GIT_COMMIT_SHA: ${{ github.event.pull_request.base.sha }}
run: |
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_COMMIT_BEFORE=${env:GIT_COMMIT_SHA}"
- name: Determine HEAD commit
env:
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_COMMIT_AFTER=${env:GIT_COMMIT_SHA}"
- name: Run clang-format
run: |
git `
-c core.autocrlf=false `
-c core.eol=lf `
-c color.ui=always `
clang-format `
--style file `
--diff ${env:RED3EXT_COMMIT_BEFORE} ${env:RED3EXT_COMMIT_AFTER}
50 changes: 22 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Release Workflow

on:
push:
tags: '*'
release:
types: [published]

env:
RED3EXT_CONFIG: Release
RED3EXT_VERSION: ${{ github.ref_name }}
RED3EXT_HASH_ALGORITHM: SHA256
RED3EXT_BUILD_CONFIG: Release
RED3EXT_CHECKSUM_ALGORITHM: SHA256

jobs:
release:
Expand All @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -38,60 +38,54 @@ jobs:
run: |
cmake `
--build . `
--config ${env:RED3EXT_CONFIG}
--config ${env:RED3EXT_BUILD_CONFIG}
- name: Install
working-directory: build
run: |
cmake `
--install . `
--prefix "${{ github.workspace }}/build/install" `
--config ${env:RED3EXT_CONFIG}
- name: Copy license files
working-directory: build/install
run: |
Copy-Item -Path ../../LICENSE.md -Destination ./red3ext/LICENSE.txt
Copy-Item -Path ../../THIRD_PARTY_LICENSES.md -Destination ./red3ext/THIRD_PARTY_LICENSES.txt
--config ${env:RED3EXT_BUILD_CONFIG}
- name: Create ZIP
- name: Create release package
working-directory: build/install
run: 7z a -r red3ext-${env:RED3EXT_VERSION}.zip *.dll *.txt

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

- name: Compute ZIP's checksum
- name: Compute package checksum
working-directory: build/install
run: |
$Hash = Get-FileHash -Algorithm ${env:RED3EXT_HASH_ALGORITHM} -Path red3ext-${env:RED3EXT_VERSION}.zip
$Hash | Format-List
$fileHash = Get-FileHash -Algorithm ${env:RED3EXT_CHECKSUM_ALGORITHM} -Path red3ext-${env:RED3EXT_VERSION}.zip
$fileHash | Format-List
$Checksum = $Hash | ForEach-Object { $_.Hash }
echo "RED3EXT_ZIP_SHA256=${Checksum}" | Out-File -FilePath ${env:GITHUB_ENV} -Encoding UTF8 -Append
$checksum = $fileHash.Hash
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_CHECKSUM_PACKAGE=${checksum}"
- name: Compute symbols ZIP's checksum
- name: Compute debug symbols checksum
working-directory: build/install
run: |
$Hash = Get-FileHash -Algorithm ${env:RED3EXT_HASH_ALGORITHM} -Path red3ext-symbols-${env:RED3EXT_VERSION}.zip
$Hash | Format-List
$fileHash = Get-FileHash -Algorithm ${env:RED3EXT_CHECKSUM_ALGORITHM} -Path red3ext-symbols-${env:RED3EXT_VERSION}.zip
$fileHash | Format-List
$Checksum = $Hash | ForEach-Object { $_.Hash }
echo "RED3EXT_SYMBOLS_SHA256=${Checksum}" | Out-File -FilePath ${env:GITHUB_ENV} -Encoding UTF8 -Append
$checksum = $fileHash.Hash
Add-Content -LiteralPath ${env:GITHUB_ENV} -Encoding UTF8 -Value "RED3EXT_CHECKSUM_SYMBOLS=${checksum}"
- name: Upload assets
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
append_body: true
body: |
## Checksums
- red3ext-${{ env.RED3EXT_VERSION }}.zip
- **${{ env.RED3EXT_HASH_ALGORITHM }}**: ${{ env.RED3EXT_ZIP_SHA256 }}
- **${{ env.RED3EXT_CHECKSUM_ALGORITHM }}**: ${{ env.RED3EXT_CHECKSUM_PACKAGE }}
- red3ext-symbols-${{ env.RED3EXT_VERSION }}.zip
- **${{ env.RED3EXT_HASH_ALGORITHM }}**: ${{ env.RED3EXT_SYMBOLS_SHA256 }}
- **${{ env.RED3EXT_CHECKSUM_ALGORITHM }}**: ${{ env.RED3EXT_CHECKSUM_SYMBOLS }}
files: |
build/install/red3ext-${{ env.RED3EXT_VERSION }}.zip
build/install/red3ext-symbols-${{ env.RED3EXT_VERSION }}.zip
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
build/

src/ported/Version.hpp
Loading

0 comments on commit 8f3066a

Please sign in to comment.