Skip to content

Commit

Permalink
ci: use npm version to bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
diegobrsign committed May 31, 2024
1 parent ee103e8 commit 0db2026
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ jobs:
- run: yarn --frozen-lockfile
- run: echo '@brightsign://npm.pkg.github.com/:_authToken=${{ steps.app-token.outputs.token }}' > ${{ github.workspace }}/.npmrc
- run: ./scripts/bump_version.sh
env:
GH_REF_VERSION: ${{ github.ref_name }}
- run: yarn workspaces run publish
16 changes: 1 addition & 15 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,7 @@ for dir in $workspace_dirs; do
# add package registry configuration from setup-node at the root of the repo
cp ../.npmrc .npmrc

PACKAGE_NAME=$(jq -r '.name' package.json)

# Run the GitHub API command to get the latest package version
response=$(gh api orgs/brightsign/packages/npm/$PACKAGE_NAME/versions 2>/dev/null)
if echo "$response" | jq -e '.message' >/dev/null; then
# If there is an error message in the response, use the default version
version_name="1.0.0"
echo "Using default version 1.0.0 for $PACKAGE_NAME"
else
# Extract version name, if possible, otherwise use default
version_name=$(echo "$response" | jq -r '.[0].name // "1.0.0"')
fi

# Update the package.json with the latest version
jq --indent 4 ".version = \"$version_name\"" package.json > temp.json && mv temp.json package.json
npm version $GH_REF_VERSION

popd
done

0 comments on commit 0db2026

Please sign in to comment.