-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate testing and packaging in GitHub Actions
- Loading branch information
Showing
2 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ name: CMake Build | |
on: | ||
push: | ||
branches: [ "main", "dev" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
@@ -15,7 +13,7 @@ jobs: | |
|
||
matrix: | ||
os: [ ubuntu-24.04, macos-latest ] | ||
build_type: [ Debug, Release ] | ||
build_type: [ Debug ] #[ Debug, Release ] | ||
c_compiler: [ clang ] | ||
include: | ||
- os: macos-latest | ||
|
@@ -27,9 +25,12 @@ jobs: | |
cpp_compiler: clang++-18 | ||
|
||
# Don't include the following configurations in the matrix | ||
exclude: | ||
- os: macos-latest | ||
build_type: Debug | ||
# exclude: | ||
# - os: macos-latest | ||
# build_type: Debug | ||
# | ||
# - os: ubuntu-24.04 | ||
# build_type: Release | ||
|
||
steps: | ||
- name: Install Dependencies | ||
|
@@ -77,43 +78,7 @@ jobs: | |
if: matrix.os == 'macos-latest' | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -j 4 | ||
|
||
- name: Package | ||
if: matrix.os == 'macos-latest' && matrix.build_type == 'Release' | ||
# Run Tests | ||
- name: Test | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
run: | | ||
cpack | ||
- name: Package | ||
if: matrix.os == 'ubuntu-24.04' && matrix.build_type == 'Release' | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
run: | | ||
sudo cpack | ||
sudo chown -R $USER:$USER "${{ github.workspace }}/Packages" | ||
- name: Import GPG Key | ||
if: matrix.build_type == 'Release' | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} | ||
passphrase: ${{ secrets.GPG_PASS }} | ||
trust_level: 5 | ||
|
||
- name: Sign Package | ||
if: matrix.build_type == 'Release' | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
for file in Packages/*; do | ||
gpg --batch --status-file ~/gpg_log.txt --passphrase ${{ secrets.GPG_PASS }} --default-key [email protected] \ | ||
--pinentry-mode=loopback --detach-sign "$file" || (cat ~/gpg_log.txt && exit 1) | ||
done | ||
# Upload the built artifacts | ||
- name: Upload Artifacts | ||
if: matrix.build_type == 'Release' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "${{ matrix.os }}-${{ matrix.build_type }}" | ||
path: "${{ github.workspace }}/Packages" | ||
overwrite: true | ||
if-no-files-found: 'warn' | ||
|
||
run: ctest -j 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
name: CPack Multi-Platform | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build_then_package: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
matrix: | ||
os: [ ubuntu-24.04, macos-latest ] | ||
build_type: [ Release ] | ||
c_compiler: [ clang ] | ||
include: | ||
- os: macos-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++-18 | ||
|
||
- os: ubuntu-24.04 | ||
c_compiler: clang | ||
cpp_compiler: clang++-18 | ||
|
||
steps: | ||
- name: Install Dependencies | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=TRUE | ||
brew update | ||
brew install gcc readline ninja cmake git | ||
brew reinstall llvm | ||
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.bash_profile | ||
echo 'export PATH="/opt/homebrew/opt/gcc/bin:$PATH"' >> ~/.bash_profile | ||
echo 'export PATH="/opt/homebrew/opt/gcc/lib/gcc/14:$PATH"' >> ~/.bash_profile | ||
. ~/.bash_profile | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set reusable strings | ||
id: strings | ||
shell: bash | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
# Build the project | ||
- name: Build PrivacyShield | ||
if: matrix.os == 'ubuntu-24.04' | ||
run: | | ||
sudo ./scripts/build.sh | ||
- name: Install Blake3 | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
sudo ./scripts/install-blake3.sh ${{ matrix.c_compiler }} | ||
- name: Configure CMake | ||
if: matrix.os == 'macos-latest' | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ | ||
-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang | ||
-DCMAKE_CXX_FLAGS=" -stdlib=libstdc++ -stdlib++-isystem /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14 -cxx-isystem /opt/homebrew/Cellar/gcc/14.1.0_1/include/c++/14/aarch64-apple-darwin23 -L /opt/homebrew/Cellar/gcc/14.1.0_1/lib/gcc/14 -Wl,-rpath,/opt/homebrew/opt/gcc/lib/gcc/current" | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-S ${{ github.workspace }} -G Ninja | ||
- name: Build | ||
if: matrix.os == 'macos-latest' | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} -j 4 | ||
|
||
- name: Package | ||
if: matrix.os == 'macos-latest' && matrix.build_type == 'Release' | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
run: | | ||
cpack | ||
- name: Package | ||
if: matrix.os == 'ubuntu-24.04' && matrix.build_type == 'Release' | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
run: | | ||
sudo cpack | ||
sudo chown -R $USER:$USER "${{ github.workspace }}/Packages" | ||
- name: Import GPG Key | ||
if: matrix.build_type == 'Release' | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} | ||
passphrase: ${{ secrets.GPG_PASS }} | ||
trust_level: 5 | ||
|
||
- name: Sign Package | ||
if: matrix.build_type == 'Release' | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
for file in Packages/*; do | ||
gpg --batch --status-file ~/gpg_log.txt --passphrase ${{ secrets.GPG_PASS }} --default-key [email protected] \ | ||
--pinentry-mode=loopback --detach-sign "$file" || (cat ~/gpg_log.txt && exit 1) | ||
done | ||
# Upload the built artifacts | ||
- name: Upload Artifacts | ||
if: matrix.build_type == 'Release' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "${{ matrix.os }}-${{ matrix.build_type }}" | ||
path: "${{ github.workspace }}/Packages" | ||
overwrite: true | ||
if-no-files-found: 'warn' |