Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix package publishing script #2741

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .vsts/common/publish-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

set -e

package_name=$1
branch=$1
if [ -z $1 ]; then
echo "Failed to publish package: No branch name supplied"
exit 1
fi

package_name=$2
if [ -z $package_name ]; then
echo "Failed to publish package: No package name supplied"
exit 1
Expand All @@ -11,11 +17,15 @@ fi
ver=$(npm pkg get version | sed 's/"//g')
package_version=$(echo "$ver-$DIST_TAG.$BUILD_BUILDNUMBER" | sed 's/_//g')

echo "Publishing package $package_name@$package_version"
echo "=================================="
echo "Working dir: $PWD"
echo "Branch: $branch"
echo "=================================="

# Publish only from the main branch for now so that we don't have to worry
# about version bumping after releases from different branches.
if [ $(git symbolic-ref -q --short HEAD) = 'main' ]; then
echo "Publishing package $package_name@$package_version"

if [ "$branch" = "refs/heads/main" ]; then
npm version --no-git-tag-version $package_version
npm publish --tag $DIST_TAG
else
Expand Down
4 changes: 3 additions & 1 deletion .vsts/linux/publish-npm-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ parameters:
packageName: ''

steps:
- bash: $(Build.SourcesDirectory)/.vsts/common/publish-packages.sh ${{parameters.packageName}}
- script: |
set -e
$(Build.SourcesDirectory)/.vsts/common/publish-packages.sh $(Build.SourceBranch) ${{parameters.packageName}}
displayName: "Publish package: ${{parameters.packageName}}"
workingDirectory: ${{parameters.packagePath}}