diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..7975d844 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,22 @@ +changelog: + exclude: + labels: + - ignore-for-release + - github-actions + authors: + - octocat + - renovate[bot] + categories: + - title: Breaking Changes 🛠 + labels: + - breaking-change + - title: Exciting New Features 🎉 + labels: + - enhancement + - feature + - title: Bug fixes 🐛 + labels: + - bug + - title: Other Changes 🔄 + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..b2c368eb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,16 @@ +name: CI + +on: + push: + branches: ['*'] # Trigger on push events for all branches + tags-ignore: ['*'] # Ignore push events on all tags + pull_request: + branches: ['master'] # Trigger on pull requests to master + workflow_dispatch: # Allow manual triggering of workflow + +jobs: + build: + uses: ./.github/workflows/cmake.yml + with: + build_type: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') && '"Debug","Release"' || '"Debug"' }} + upload_artifacts: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' }} \ No newline at end of file diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f8d5dec2..28938db9 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -2,10 +2,22 @@ # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml name: CMake Build and Test -on: [push, workflow_dispatch] +on: + workflow_call: + inputs: + build_type: + description: 'Build type (e.g., "Debug", "Release", "RelWithDebInfo", "MinSizeRel")' + default: '"Debug"' + required: true + type: string + upload_artifacts: + description: 'Whether to upload artifacts (true/false)' + default: false + required: true + type: boolean jobs: - build: + cmake_build: runs-on: ${{ matrix.os }} strategy: @@ -20,7 +32,7 @@ jobs: # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - build_type: [Release] + build_type: ${{ fromJSON(format('[{0}]', inputs.build_type || '"Debug","Release"')) }} c_compiler: [gcc, clang, cl] include: - os: windows-latest @@ -80,24 +92,15 @@ jobs: run: ctest --build-config ${{ matrix.build_type }} --verbose --output-on-failure - name: Package Build Artifacts - if: ${{ success() }} + if: ${{ inputs.upload_artifacts && success() }} run: | mkdir -p ${{ steps.strings.outputs.build-output-dir }}/package # Adjust the path to your built library files cp ${{ steps.strings.outputs.build-output-dir }}/${{ matrix.build_type }}/*GameAnalytics.* ${{ steps.strings.outputs.build-output-dir }}/package/ cp -r ${{ github.workspace }}/include ${{ steps.strings.outputs.build-output-dir }}/package/ - - - name: Print Package Contents on Windows - if: matrix.os == 'windows-latest' - run: Get-ChildItem -Recurse "${{ steps.strings.outputs.build-output-dir }}\package" - shell: pwsh - - - name: Print Package Contents on non-Windows (Linux/macOS) - if: matrix.os != 'windows-latest' - run: ls -la ${{ steps.strings.outputs.build-output-dir }}/package - name: Upload Build Artifact - if: ${{ success() }} + if: ${{ inputs.upload_artifacts && success() }} uses: actions/upload-artifact@v4 with: name: ga-cpp-sdk-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }} diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml new file mode 100644 index 00000000..e5abe367 --- /dev/null +++ b/.github/workflows/create_release.yml @@ -0,0 +1,45 @@ +name: Create Release +run-name: C++ SDK Release ${{ inputs.tag_name }} + +on: + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name for the release (e.g., v1.0.0)' + required: true + type: string + +jobs: + build: + uses: ./.github/workflows/cmake.yml + with: + build_type: '"Release"' + upload_artifacts: true + + release: + name: Create GitHub Release + needs: build + runs-on: ubuntu-latest + + steps: + - name: Push tag ${{ inputs.tag_name }} + run: | + git tag ${{ inputs.tag_name }} + git push origin ${{ inputs.tag_name }} + + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: ./release-artifacts + + - name: Show downloaded artifacts + run: ls -l ./release-artifacts + + - name: Create release + uses: softprops/action-gh-release@v2.0.8 + with: + tag_name: ${{ inputs.tag_name }} + name: Release GA-CPP-SDK ${{ inputs.tag_name }} + generate_release_notes: true + make_latest: true + files: ./release-artifacts/* \ No newline at end of file diff --git a/gh_create_release.py b/gh_create_release.py new file mode 100644 index 00000000..48f3e4e7 --- /dev/null +++ b/gh_create_release.py @@ -0,0 +1,70 @@ +import subprocess +import sys +import re + +def run_command(command): + """Run the specified command and handle errors.""" + try: + result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True) + print(result.stdout) + return result.returncode + except subprocess.CalledProcessError as e: + print(f"Error occurred: {e.stderr}", file=sys.stderr) + return e.returncode + +def trigger_workflow(tag_name): + """Trigger the GitHub Actions workflow using GitHub CLI.""" + # Set repository and branch + repo = "GameAnalytics/GA-SDK-CPP-NEW" + branch = "main" + + # Construct the GitHub CLI command + command = f'gh workflow run "Create Release" --repo {repo} --ref {branch} -f tag_name={tag_name}' + print(f"Running command: {command}") + + # Execute the command + return_code = run_command(command) + + if return_code == 0: + print("Workflow triggered successfully.") + else: + print(f"Failed to trigger workflow. Return code: {return_code}") + +def check_gh_cli_installed(): + """Check if GitHub CLI (gh) is installed and available in the system path.""" + try: + subprocess.run(['gh', '--version'], capture_output=True, check=True) + return True + except FileNotFoundError: + return False + +def validate_tag_name(tag_name): + """Validate that the tag name matches the format 'v1.0.0'.""" + pattern = r"^v\d+\.\d+\.\d+$" + if re.match(pattern, tag_name): + return True + else: + return False + +def main(): + # Ensure GitHub CLI is installed + if not check_gh_cli_installed(): + print("GitHub CLI (gh) is not installed. Please install it and try again.") + sys.exit(1) + + # Validate tag name passed as an argument + if len(sys.argv) != 2: + print("Usage: python trigger_workflow.py ") + sys.exit(1) + + tag_name = sys.argv[1] + + if not validate_tag_name(tag_name): + print("Invalid tag name format. Please use the format 'v1.0.0'.") + sys.exit(1) + + # Trigger the workflow with validated tag name + trigger_workflow(tag_name) + +if __name__ == "__main__": + main() diff --git a/source/gameanalytics/GAValidator.cpp b/source/gameanalytics/GAValidator.cpp index 06f26085..e6d2b573 100644 --- a/source/gameanalytics/GAValidator.cpp +++ b/source/gameanalytics/GAValidator.cpp @@ -718,8 +718,6 @@ namespace gameanalytics { constexpr int64_t k_maxTs = 99999999999; - logging::GALogger::d("clientTs = %lld", clientTs); - if (clientTs < 0 || clientTs > k_maxTs) { return false;