From ffd7d9f105446462152bf2c916cee8bef675a408 Mon Sep 17 00:00:00 2001 From: Shakar <5h4k4r.b4kr@gmail.com> Date: Sun, 17 Sep 2023 14:24:56 +0300 Subject: [PATCH] Add file path as input Signed-off-by: Shakar <5h4k4r.b4kr@gmail.com> --- .github/workflows/main.yaml | 2 ++ index.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d539160..e5db041 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -28,6 +28,8 @@ jobs: id: hello with: label: minor + filePath: /package.json + # ${{ github.event.label.name }} - name: Get the output time run: | diff --git a/index.js b/index.js index d3a5c4e..fe12a4b 100644 --- a/index.js +++ b/index.js @@ -4,11 +4,21 @@ const fs = require('fs') const xml2js = require('xml2js') try { const label = core.getInput('label'); + const filePath = core.getInput('filePath'); + console.log(`Label: ${label}`) + console.log(`File path: ${filePath}`) core.setOutput("label", label); - const version = require('./package.json').version; + // if (project == 'dotnetcore') + // filePath = `${filePath}/.csproj`; + // else if (project == 'nodejs') + // filePath = `${filePath}/package.json`; + + const version = require(filePath).version; + + // the version is in semantic format, so we can split it by dot const versionParts = version.split('.'); if (label === 'major') {