EXPORT RELEASE TAG #20
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
name: CMake on multiple platforms | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
create_release: | |
runs-on: ubuntu-latest | |
outputs: | |
release_tag: ${{ steps.release_tag.outputs.release_tag }} # Expose release tag as output | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Release Tag to Current Date and Time | |
id: release_tag | |
run: | | |
RELEASE_TAG="v$(date +'%Y%m%d%H%M%S')" # Create a version tag based on the current date and time | |
echo "Release tag: $RELEASE_TAG" | |
echo "::set-output name=release_tag::$RELEASE_TAG" # Set the release tag as an output variable | |
- name: Create Release | |
id: create_release | |
run: | | |
RELEASE_TAG="${{ steps.release_tag.outputs.release_tag }}" # Fetch release tag from earlier step | |
echo "Creating release with tag $RELEASE_TAG" | |
gh release create $RELEASE_TAG --title "Release $RELEASE_TAG" --notes "Release created on $RELEASE_TAG" # Create the release with the tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build_and_upload: | |
needs: create_release # Ensure this job runs after `create_release` | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] # You can also add windows-latest if you want to support Windows | |
build_type: [Release] | |
c_compiler: [gcc, clang] # Now we have gcc and clang in the same matrix | |
include: | |
- os: ubuntu-latest | |
c_compiler: gcc | |
cpp_compiler: g++ | |
- os: ubuntu-latest | |
c_compiler: clang | |
cpp_compiler: clang++ | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Dependencies (Including gh) | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
libssl-dev \ | |
libluajit-5.1-dev \ | |
protobuf-c-compiler \ | |
libprotobuf-c-dev \ | |
libopus-dev \ | |
libsndfile1-dev \ | |
libuv1-dev \ | |
gh # Install GitHub CLI | |
- name: Set reusable strings | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
- name: Configure CMake | |
run: > | |
cmake -B ${{ steps.strings.outputs.build-output-dir }} | |
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | |
-S ${{ github.workspace }} | |
- name: Build | |
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | |
- name: Test | |
working-directory: ${{ steps.strings.outputs.build-output-dir }} | |
run: ctest --build-config ${{ matrix.build_type }} | |
- name: Zip GCC .so Files | |
if: matrix.c_compiler == 'gcc' | |
run: | | |
GCC_SO_FILES=$(find ${{ steps.strings.outputs.build-output-dir }} -name '*.so' -type f) | |
echo "Found GCC .so files: $GCC_SO_FILES" | |
ZIP_FILE="release-gcc.zip" | |
zip -r $ZIP_FILE $GCC_SO_FILES # Zip all GCC .so files | |
echo "Zipped GCC .so files into $ZIP_FILE" | |
working-directory: ${{ github.workspace }} | |
- name: Zip Clang .so Files | |
if: matrix.c_compiler == 'clang' | |
run: | | |
CLANG_SO_FILES=$(find ${{ steps.strings.outputs.build-output-dir }} -name '*.so' -type f) | |
echo "Found Clang .so files: $CLANG_SO_FILES" | |
ZIP_FILE="release-clang.zip" | |
zip -r $ZIP_FILE $CLANG_SO_FILES # Zip all Clang .so files | |
echo "Zipped Clang .so files into $ZIP_FILE" | |
working-directory: ${{ github.workspace }} | |
- name: Upload GCC .so Zip to Release | |
if: matrix.c_compiler == 'gcc' | |
run: | | |
RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" # Ensure that the release tag is available here | |
ZIP_FILE="release-gcc.zip" | |
if [ -f "$ZIP_FILE" ]; then # Check if the zip file was created | |
echo "Uploading $ZIP_FILE to release $RELEASE_TAG" | |
gh release upload $RELEASE_TAG $ZIP_FILE --clobber # Upload the zip file to the single release | |
else | |
echo "Error: $ZIP_FILE does not exist." | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Clang .so Zip to Release | |
if: matrix.c_compiler == 'clang' | |
run: | | |
RELEASE_TAG="${{ needs.create_release.outputs.release_tag }}" # Ensure that the release tag is available here | |
ZIP_FILE="release-clang.zip" | |
if [ -f "$ZIP_FILE" ]; then # Check if the zip file was created | |
echo "Uploading $ZIP_FILE to release $RELEASE_TAG" | |
gh release upload $RELEASE_TAG $ZIP_FILE --clobber # Upload the zip file to the single release | |
else | |
echo "Error: $ZIP_FILE does not exist." | |
exit 1 | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |