Skip to content

Commit 7ef1dc1

Browse files
ronellecaguioaThe Meridian Authors
authored andcommitted
fix
PiperOrigin-RevId: 831471160
1 parent 5832630 commit 7ef1dc1

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

.github/workflows/proto-publish.yml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,52 @@ jobs:
4141
steps:
4242
- name: Checkout repository
4343
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0 # Important: fetch all tags for comparison
46+
fetch-tags: true
4447

45-
- name: Read package version from pyproject.toml
46-
uses: SebRollen/toml-action@v1.2.0
47-
id: read_toml
48+
- name: Set up Python
49+
uses: actions/setup-python@v5
4850
with:
49-
file: pyproject.toml
50-
field: 'project.version'
51+
python-version: ${{ env.USE_PYTHON_VERSION }}
52+
53+
- name: Install semver
54+
shell: bash
55+
run: pip install semver
56+
57+
- name: Get version
58+
id: get_version
59+
shell: bash
60+
run: |
61+
VERSION=$(python -c """
62+
import sys
63+
import tomllib
64+
65+
try:
66+
filepath = '${{ env.PROTO_DIR }}/pyproject.toml'
67+
with open(filepath, 'rb') as f:
68+
data = tomllib.load(f)
69+
70+
version = data.get('project', {}).get('version', '')
71+
if version:
72+
print(version)
73+
else:
74+
print(f"Error: Version not found in {filepath} under [project.version]")
75+
sys.exit(1)
76+
except FileNotFoundError:
77+
print(f"Error: File {filepath} not found", file=sys.stderr)
78+
sys.exit(1)
79+
"""
80+
if [ $? -ne 0 ]; then
81+
echo "Failed to get version from ${{ env.PROTO_DIR}}/pyproject.toml"
82+
exit 1
83+
fi
84+
echo "value=$VERSION" >> $GITHUB_OUTPUT
5185
5286
- name: Compare versions
5387
id: compare_versions
5488
run: |
55-
CURRENT_VERSION = "${{ steps.read_toml.outputs.value }}"
89+
CURRENT_VERSION="${{ steps.get_version.outputs.value }}"
5690
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match 'v*' || { echo "Error: No matching previous tag found." >&2; exit 1; })
5791
PREVIOUS_VERSION=$(echo "$PREVIOUS_TAG" | sed 's/^v//')
5892

0 commit comments

Comments
 (0)