Skip to content

Commit 1ba94e2

Browse files
committed
use gradle/libs.versions.toml
Signed-off-by: xil <fridalu66@gmail.com>
1 parent c020c78 commit 1ba94e2

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

.github/workflows/convert-proto.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
with:
6565
github-token: ${{ secrets.GITHUB_TOKEN }}
6666
script: |
67+
const toml = require('toml');
68+
6769
// Check if version was provided as input
6870
const inputVersion = "${{ inputs.opensearch_version }}";
6971
if (inputVersion && inputVersion.trim() !== "") {
@@ -72,35 +74,32 @@ jobs:
7274
return;
7375
}
7476
75-
// Otherwise fetch version from buildSrc/version.properties on main branch
77+
// Otherwise fetch version from gradle/libs.versions.toml on main branch
7678
try {
7779
const response = await github.request(
7880
'GET /repos/{owner}/{repo}/contents/{path}',
7981
{
8082
owner: 'opensearch-project',
8183
repo: 'OpenSearch',
82-
path: 'buildSrc/version.properties',
84+
path: 'gradle/libs.versions.toml',
8385
ref: 'main'
8486
}
8587
);
8688
87-
// Decode the file content
8889
const content = Buffer.from(response.data.content, 'base64').toString('utf-8');
8990
90-
// Extract opensearch version (e.g., "opensearch = 3.4.0")
91-
const match = content.match(/opensearch\s*=\s*([^\s]+)/);
91+
// Parse TOML and extract opensearch version
92+
const parsed = toml.parse(content);
93+
const version = parsed.versions.opensearch;
9294
93-
if (match && match[1]) {
94-
const version = match[1].trim();
95+
if (version) {
9596
core.setOutput("version", version);
96-
console.log("Fetched OpenSearch version from source: " + version);
97+
console.log("Fetched OpenSearch version from gradle/libs.versions.toml: " + version);
9798
} else {
98-
console.log("Warning: Could not parse version from buildSrc/version.properties");
99-
core.setOutput("version", "unknown");
99+
core.setFailed("Could not find opensearch version in gradle/libs.versions.toml");
100100
}
101101
} catch (error) {
102-
console.log("Warning: Could not fetch OpenSearch version: " + error.message);
103-
core.setOutput("version", "unknown");
102+
core.setFailed("Could not fetch OpenSearch version: " + error.message);
104103
}
105104
106105
- name: Run Proto Conversion

0 commit comments

Comments
 (0)