Update build-release.yml

This commit is contained in:
Loan J 2024-02-22 12:06:20 -05:00 committed by GitHub
parent c89c27d351
commit a3eb7157f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,11 +13,18 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Get commit hash - name: Check for changes in package.json
id: get_hash
run: | run: |
HASH=$(git rev-parse --short "$GITHUB_SHA") git diff --cached --diff-filter=d package.json || {
echo "::set-output name=hash::$HASH" 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 - name: Create GitHub release
uses: actions/github-script@v5 uses: actions/github-script@v5
@ -27,8 +34,8 @@ jobs:
const release = await github.rest.repos.createRelease({ const release = await github.rest.repos.createRelease({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
tag_name: `v${{ steps.get_hash.outputs.hash }}`, tag_name: `v${{ steps.get_version.outputs.version }}`,
name: `v${{ steps.get_hash.outputs.hash }}`, name: `v${{ steps.get_version.outputs.version }}`,
body: 'Automatically created new release', body: 'Automatically created new release',
}) })
console.log(`Created release ${release.data.html_url}`) console.log(`Created release ${release.data.html_url}`)