From a3eb7157f0144c90856821b748c8e541d30a3fa0 Mon Sep 17 00:00:00 2001 From: Loan J Date: Thu, 22 Feb 2024 12:06:20 -0500 Subject: [PATCH] Update build-release.yml --- .github/workflows/build-release.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index f4baf8944..fa3fa296d 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -13,11 +13,18 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Get commit hash - id: get_hash + - name: Check for changes in package.json run: | - HASH=$(git rev-parse --short "$GITHUB_SHA") - echo "::set-output name=hash::$HASH" + git diff --cached --diff-filter=d package.json || { + echo "No changes to package.json" + exit 1 + } + + - name: Get version number from package.json + id: get_version + run: | + VERSION=$(jq -r '.version' package.json) + echo "::set-output name=version::$VERSION" - name: Create GitHub release uses: actions/github-script@v5 @@ -27,8 +34,8 @@ jobs: const release = await github.rest.repos.createRelease({ owner: context.repo.owner, repo: context.repo.repo, - tag_name: `v${{ steps.get_hash.outputs.hash }}`, - name: `v${{ steps.get_hash.outputs.hash }}`, + tag_name: `v${{ steps.get_version.outputs.version }}`, + name: `v${{ steps.get_version.outputs.version }}`, body: 'Automatically created new release', }) console.log(`Created release ${release.data.html_url}`)