Create Release #9
This file contains hidden or 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: Create Release | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.extract_version.outputs.VERSION }} | |
| tag_exists: ${{ steps.check_tag.outputs.TAG_EXISTS }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GA_TOKEN }} | |
| - name: Extract version from Cargo.toml | |
| id: extract_version | |
| run: | | |
| VERSION=$(grep "^version" src/rust/fcb_core/Cargo.toml | head -1 | cut -d'"' -f2) | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Check if tag exists | |
| id: check_tag | |
| run: | | |
| if git ls-remote --tags origin | grep -q "refs/tags/v${{ steps.extract_version.outputs.VERSION }}"; then | |
| echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "TAG_EXISTS=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate release notes | |
| if: steps.check_tag.outputs.TAG_EXISTS == 'false' | |
| id: release_notes | |
| run: | | |
| # Get the latest tag | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| # Generate changelog | |
| echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT | |
| echo "## What's Changed" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "Initial release" >> $GITHUB_OUTPUT | |
| else | |
| # Get commit messages since last tag | |
| git log $LATEST_TAG..HEAD --pretty=format:"- %s" >> $GITHUB_OUTPUT | |
| fi | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "### Crate Version: ${{ steps.extract_version.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| # Check npm version | |
| NPM_VERSION=$(grep "\"version\"" src/ts/package.json | cut -d'"' -f4) | |
| echo "### NPM Version: $NPM_VERSION" >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LATEST_TAG}...v${{ steps.extract_version.outputs.VERSION }}" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create and push tag | |
| if: steps.check_tag.outputs.TAG_EXISTS == 'false' | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git tag -a "v${{ steps.extract_version.outputs.VERSION }}" -m "Release v${{ steps.extract_version.outputs.VERSION }}" | |
| git push origin "v${{ steps.extract_version.outputs.VERSION }}" | |
| - name: Create GitHub Release | |
| if: steps.check_tag.outputs.TAG_EXISTS == 'false' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GA_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.extract_version.outputs.VERSION }} | |
| release_name: v${{ steps.extract_version.outputs.VERSION }} | |
| body: ${{ steps.release_notes.outputs.RELEASE_NOTES }} | |
| draft: false | |
| prerelease: false | |
| build-cpp-bindings: | |
| name: Build C++ Bindings | |
| needs: create-release | |
| if: needs.create-release.outputs.tag_exists == 'false' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux | |
| artifact_name: fcb_cpp-linux-x86_64 | |
| cmake_generator: Unix Makefiles | |
| - os: macos-latest | |
| platform: macos | |
| artifact_name: fcb_cpp-macos-x86_64 | |
| cmake_generator: Unix Makefiles | |
| - os: windows-latest | |
| platform: windows | |
| artifact_name: fcb_cpp-windows-x86_64 | |
| cmake_generator: Visual Studio 17 2022 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| - name: Install CMake | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.26.x' | |
| - name: Install cxxbridge | |
| run: cargo install cxxbridge-cmd | |
| - name: Build Rust static library | |
| run: cargo build --release -p fcb_cpp --no-default-features | |
| working-directory: ./src/rust | |
| - name: Configure CMake | |
| run: cmake -B build -G "${{ matrix.cmake_generator }}" -DCMAKE_BUILD_TYPE=Release | |
| working-directory: ./src/cpp | |
| - name: Build C++ bindings | |
| shell: bash | |
| run: | | |
| if [[ "${{ runner.os }}" = "Windows" ]]; then | |
| cmake --build build --config Release | |
| else | |
| cmake --build build -- -j$(nproc) | |
| fi | |
| working-directory: ./src/cpp | |
| - name: Prepare release artifacts | |
| shell: bash | |
| run: | | |
| mkdir -p release-artifacts | |
| # Copy static library (Windows .lib renamed to .a for consistency) | |
| if [[ "${{ runner.os }}" = "Windows" ]]; then | |
| cp src/rust/target/release/fcb_cpp.lib release-artifacts/libfcb_cpp.a | |
| else | |
| cp src/rust/target/release/libfcb_cpp.a release-artifacts/ | |
| fi | |
| # Copy CXX bridge header | |
| cp src/cpp/build/generated/lib.rs.h release-artifacts/ | |
| # Copy include directory | |
| cp -r src/cpp/include/. release-artifacts/ | |
| # Create package | |
| if [[ "${{ runner.os }}" = "Windows" ]]; then | |
| 7z a -tzip ${{ matrix.artifact_name }}.zip ./release-artifacts/* | |
| else | |
| tar -czf ${{ matrix.artifact_name }}.tar.gz -C release-artifacts . | |
| fi | |
| - name: Upload release artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: ${{ matrix.artifact_name }}.* | |
| retention-days: 90 | |
| - name: Upload to GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: ${{ matrix.artifact_name }}.* | |
| generate_release_notes: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| build-docs: | |
| name: Build Documentation | |
| needs: build-cpp-bindings | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Doxygen | |
| run: sudo apt-get install -y doxygen graphviz | |
| - name: Generate API documentation | |
| run: doxygen Doxyfile | |
| working-directory: ./src/cpp | |
| - name: Upload documentation artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: fcb_cpp-docs | |
| path: src/cpp/docs/html | |
| retention-days: 90 | |
| - name: Upload documentation to release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: src/cpp/docs/html/* | |
| generate_release_notes: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |