From 648cb46ee9d74d96714f653b655b55ec75ae9326 Mon Sep 17 00:00:00 2001 From: Ronelle Caguioa Date: Thu, 4 Dec 2025 10:36:21 -0800 Subject: [PATCH] chore PiperOrigin-RevId: 840305796 --- .github/actions/get-proto-version/action.yml | 60 ++++++++++++++++ .github/actions/version-check/action.yml | 39 +++++----- .github/workflows/ci.yml | 33 ++++++++- .github/workflows/proto-publish.yml | 76 +++----------------- .github/workflows/publish.yml | 14 ++++ CHANGELOG.md | 7 +- README.md | 2 +- meridian/version.py | 2 +- 8 files changed, 147 insertions(+), 86 deletions(-) create mode 100644 .github/actions/get-proto-version/action.yml diff --git a/.github/actions/get-proto-version/action.yml b/.github/actions/get-proto-version/action.yml new file mode 100644 index 000000000..2852fe8a1 --- /dev/null +++ b/.github/actions/get-proto-version/action.yml @@ -0,0 +1,60 @@ +inputs: + python_version: + description: The Python version of the build toolchain to use. + required: true + +outputs: + value: + description: The current version of mmm-proto-schema + value: ${{ steps.get_version.outputs.value }} + +env: + PROTO_DIR: "proto" + +runs: + using: composite + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Important: fetch all tags for comparison + fetch-tags: true + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.USE_PYTHON_VERSION }} + + - name: Install semver + shell: bash + run: pip install semver + + - name: Get version + id: get_version + shell: bash + run: | + VERSION=$(python -c """ + import sys + import tomllib + + try: + filepath = '${{ env.PROTO_DIR }}/pyproject.toml' + with open(filepath, 'rb') as f: + data = tomllib.load(f) + + version = data.get('project', {}).get('version', '') + if version: + print(version) + else: + print(f'Error: Version not found in {filepath} under [project.version]', file=sys.stderr) + sys.exit(1) + except FileNotFoundError: + print(f'Error: File {filepath} not found', file=sys.stderr) + sys.exit(1) + """ ) + + if [ $? -ne 0 ]; then + echo "Failed to get version from ${{ env.PROTO_DIR}}/pyproject.toml" + exit 1 + fi + echo "value=$VERSION" >> $GITHUB_OUTPUT diff --git a/.github/actions/version-check/action.yml b/.github/actions/version-check/action.yml index d73d78f12..5962d5cba 100644 --- a/.github/actions/version-check/action.yml +++ b/.github/actions/version-check/action.yml @@ -5,7 +5,12 @@ inputs: python_version: description: The Python version of the build toolchain to use. required: true - default: 3.11 + semver_prefix: + description: The prefix of the package version. + required: true + current_version: + description: The current package version. + required: true outputs: new_version: @@ -19,18 +24,27 @@ runs: with: fetch-depth: 0 # Important: fetch all tags for comparison fetch-tags: true - - uses: ./.github/actions/install-meridian - with: - python_version: ${{ inputs.python_version }} - extras: '' - shell: bash run: pip install semver - id: version_check name: Check Version shell: bash - # This relies on the git repository having "v{major}.{minor}.{patch}" named tags. + # This relies on the git repository having "{prefix}{major}.{minor}.{patch}" named tags. run: | - CURRENT_VERSION=$(python3 -c "import meridian; print(meridian.__version__)") + CURRENT_VERSION=${{ inputs.current_version }} + PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match '${{ inputs.semver_prefix }}*' || { echo "Error: No matching previous tag found." >&2; exit 1; }) + PREVIOUS_VERSION=$(echo "$PREVIOUS_TAG" | sed 's/^${{ inputs.semver_prefix }}//') + + echo "CURRENT_VERSION: $CURRENT_VERSION" + echo "PREVIOUS_TAG: $PREVIOUS_TAG" + echo "PREVIOUS_VERSION: $PREVIOUS_VERSION" + + # Check if first version + if [ -z "$PREVIOUS_TAG" ]; then + echo "Warning: No matching previous tag found with pattern '${{ inputs.semver_prefix }}*'. Assuming first version." + echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + exit 0 + fi # Validate CURRENT_VERSION using semver check if ! python3 -m semver check "$CURRENT_VERSION"; then @@ -38,17 +52,10 @@ runs: exit 1 # Fail fast fi - PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match 'v*' || { echo "Error: No matching previous tag found." >&2; exit 1; }) - PREVIOUS_VERSION=$(echo "$PREVIOUS_TAG" | sed 's/^v//') - - echo "CURRENT_VERSION: $CURRENT_VERSION" - echo "PREVIOUS_TAG: $PREVIOUS_TAG" - echo "PREVIOUS_VERSION: $PREVIOUS_VERSION" - if [[ $(python3 -m semver compare "$CURRENT_VERSION" "$PREVIOUS_VERSION") -eq 1 ]]; then echo "New version detected: $CURRENT_VERSION" - NEW_VERSION=$CURRENT_VERSION + echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT else echo "No version increment detected." + echo "new_version=" >> $GITHUB_OUTPUT fi - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cebad05d6..5bece59c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: env: USE_PYTHON_VERSION: "3.11" + PROTO_DIR: "proto" jobs: # Build meridian "core" and "mmm-proto-schema" distributions. @@ -36,10 +37,40 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v4 - - id: version_check + + # Check meridian version + - uses: ./.github/actions/install-meridian + with: + python_version: ${{ inputs.python_version }} + extras: '' + + - name: Get meridian version + id: get_meridian_version + shell: bash + run: | + VERSION=$(python -c "import meridian; print(meridian.__version__)") + echo "value=$VERSION" >> $GITHUB_OUTPUT + + - name: Check meridian version + id: meridian_version_check + uses: ./.github/actions/version-check + with: + python_version: ${{ env.USE_PYTHON_VERSION }} + semver_prefix: v + current_version: ${{ steps.get_meridian_version.outputs.value}} + + # Check mmm-proto-schema version + - name: Get mmm-proto-schema version + id: get_proto_version + uses: ./.github/actions/get-proto-version + with: + python_version: ${{ env.USE_PYTHON_VERSION }} + - name: Check mmm-proto-schema version uses: ./.github/actions/version-check with: python_version: ${{ env.USE_PYTHON_VERSION }} + semver_prefix: proto-v + current_version: ${{ steps.get_proto_version.outputs.value}} pytest: runs-on: ubuntu-latest diff --git a/.github/workflows/proto-publish.yml b/.github/workflows/proto-publish.yml index bcde919f9..236455aea 100644 --- a/.github/workflows/proto-publish.yml +++ b/.github/workflows/proto-publish.yml @@ -48,76 +48,20 @@ jobs: outputs: new_version: ${{ steps.compare_versions.outputs.new_version }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Important: fetch all tags for comparison - fetch-tags: true - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - name: Get mmm-proto-schema version + id: get_proto_version + uses: ./.github/actions/get-proto-version with: - python-version: ${{ env.USE_PYTHON_VERSION }} - - - name: Install semver - shell: bash - run: pip install semver - - - name: Get version - id: get_version - shell: bash - run: | - VERSION=$(python -c """ - import sys - import tomllib - - try: - filepath = '${{ env.PROTO_DIR }}/pyproject.toml' - with open(filepath, 'rb') as f: - data = tomllib.load(f) - - version = data.get('project', {}).get('version', '') - if version: - print(version) - else: - print(f'Error: Version not found in {filepath} under [project.version]', file=sys.stderr) - sys.exit(1) - except FileNotFoundError: - print(f'Error: File {filepath} not found', file=sys.stderr) - sys.exit(1) - """ ) - - if [ $? -ne 0 ]; then - echo "Failed to get version from ${{ env.PROTO_DIR}}/pyproject.toml" - exit 1 - fi - echo "value=$VERSION" >> $GITHUB_OUTPUT + python_version: ${{ env.USE_PYTHON_VERSION }} - name: Compare versions id: compare_versions - run: | - CURRENT_VERSION="${{ steps.get_version.outputs.value }}" - PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match 'proto-v*' || echo "") - - if [ -z "$PREVIOUS_TAG" ]; then - echo "Warning: No matching previous tag found with pattern 'proto-v*'. Assuming first version." - echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - exit 0 - fi - - PREVIOUS_VERSION=$(echo "$PREVIOUS_TAG" | sed 's/^proto-v//') - - echo "CURRENT_VERSION: $CURRENT_VERSION" - echo "PREVIOUS_TAG: $PREVIOUS_TAG" - echo "PREVIOUS_VERSION: $PREVIOUS_VERSION" - - if [[ $(python3 -m semver compare "$CURRENT_VERSION" "$PREVIOUS_VERSION") -eq 1 ]]; then - echo "New version detected: $CURRENT_VERSION" - NEW_VERSION=$CURRENT_VERSION - else - echo "No version increment detected." - fi - echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + uses: ./.github/actions/version-check + with: + python_version: ${{ env.USE_PYTHON_VERSION }} + semver_prefix: proto-v + current_version: ${{ steps.get_proto_version.outputs.value }} create-proto-tag: needs: check-proto-version diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 05c04d8de..ebc8478d2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -44,10 +44,24 @@ jobs: new_version: ${{ steps.version_check.outputs.new_version }} steps: - uses: actions/checkout@v4 + + - uses: ./.github/actions/install-meridian + with: + python_version: ${{ inputs.python_version }} + extras: '' + + - id: get_version + shell: bash + run: | + VERSION=$(python -c "import meridian; print(meridian.__version__)") + echo "value=$VERSION" >> $GITHUB_OUTPUT + - id: version_check uses: ./.github/actions/version-check with: python_version: ${{ env.USE_PYTHON_VERSION }} + semver_prefix: v + current_version: ${{ steps.get_version.outputs.value }} create-tag: needs: check-version diff --git a/CHANGELOG.md b/CHANGELOG.md index 7526b317d..aac782e52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,10 @@ To release a new version (e.g. from `1.0.0` -> `2.0.0`): ## [Unreleased] +## [1.3.3] - 2025-12-04 + +* Update github actions + ## [1.3.2] - 2025-11-26 * Fixed an out-of-bounds bug in EDA's VIF check. @@ -419,4 +423,5 @@ To release a new version (e.g. from `1.0.0` -> `2.0.0`): [1.3.0]: https://github.com/google/meridian/releases/tag/v1.3.0 [1.3.1]: https://github.com/google/meridian/releases/tag/v1.3.1 [1.3.2]: https://github.com/google/meridian/releases/tag/v1.3.2 -[Unreleased]: https://github.com/google/meridian/compare/v1.3.2...HEAD +[1.3.3]: https://github.com/google/meridian/releases/tag/v1.3.3 +[Unreleased]: https://github.com/google/meridian/compare/v1.3.3...HEAD diff --git a/README.md b/README.md index a36de6797..02c9bd091 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ To cite this repository: author = {Google Meridian Marketing Mix Modeling Team}, title = {Meridian: Marketing Mix Modeling}, url = {https://github.com/google/meridian}, - version = {1.3.2}, + version = {1.3.3}, year = {2025}, } ``` diff --git a/meridian/version.py b/meridian/version.py index 1b51ff07a..31a8022c3 100644 --- a/meridian/version.py +++ b/meridian/version.py @@ -14,4 +14,4 @@ """Module for Meridian version.""" -__version__ = "1.3.2" +__version__ = "1.3.3"