Skip to content

Commit

Permalink
Added github action to verify package.json version number changed
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Uvi <[email protected]>
  • Loading branch information
Josh-Uvi committed Dec 18, 2024
1 parent ecd46e4 commit b747a5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Node.js Package
on:
push:
branches: ["main"]
paths: ["src/**", "test/**", "!.github/workflows/**", "!README.md"]

jobs:
build:
Expand All @@ -15,15 +14,25 @@ jobs:
node-version: 20
- run: npm ci
- run: npm test
- name: Check if version has been updated
id: check
uses: EndBug/version-check@v2
- name: Log when changed
if: steps.check.outputs.changed == 'true'
run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'
- name: Log when unchanged
if: steps.check.outputs.changed == 'false'
run: 'echo "No version change :/"'

release:
if: ${{ ! startsWith(github.ref, 'refs/tags/')}}
if: ${{ steps.check.outputs.changed == 'true' }}
name: Release pushed tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create release
if: ${{ ! startsWith(github.ref, 'refs/tags/')}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
Expand All @@ -34,7 +43,7 @@ jobs:
--generate-notes
publish-gpr:
needs: build
if: ${{ steps.check.outputs.changed == 'true' }}
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"publishConfig": {
"@josh-uvi:registry": "https://npm.pkg.github.com"
},
"description": "",
"description": "NewsAPI Client is a TypeScript-based client for interacting with the NewsAPI service. It simplifies fetching news articles, top headlines, and news sources while handling API errors gracefully.",
"dependencies": {
"axios": "^1.7.7"
},
Expand Down

0 comments on commit b747a5a

Please sign in to comment.