Skip to content

Commit

Permalink
feat: refactor version update process in GitHub Actions workflow to i…
Browse files Browse the repository at this point in the history
…mprove package.json handling
  • Loading branch information
bucurdavid committed Feb 14, 2025
1 parent 002907e commit 435b51a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ jobs:
fs.writeFileSync('package.json', JSON.stringify(package, null, 2) + '\n');
"
- name: Commit version update
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add package.json
git commit -m "chore: update package.json version to ${{ steps.new_version.outputs.version }}"
git push
- name: Get Package Version
id: package_version
run: |
Expand All @@ -126,6 +117,24 @@ jobs:
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Update package.json with version
run: |
# Use node to update package.json to preserve formatting
node -e "
const fs = require('fs');
const package = JSON.parse(fs.readFileSync('package.json'));
package.version = '${{ steps.package_version.outputs.version }}';
fs.writeFileSync('package.json', JSON.stringify(package, null, 2) + '\n');
"
- name: Commit version update
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add package.json
git commit -m "chore: update package.json version to ${{ steps.package_version.outputs.version }}"
git push
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 435b51a

Please sign in to comment.