add hw2
This commit is contained in:
		
							
								
								
									
										151
									
								
								node_modules/cytoscape/.github/workflows/scripts/merge_unstable_to_master.sh
									
									
									
										generated
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										151
									
								
								node_modules/cytoscape/.github/workflows/scripts/merge_unstable_to_master.sh
									
									
									
										generated
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,151 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Make script exit on first failure | ||||
| set -e | ||||
|  | ||||
| # Check if VERSION variable is set | ||||
| if [ -z "$VERSION" ]; then | ||||
|   echo "VERSION variable is not set." | ||||
|   exit 1 | ||||
| else | ||||
|   echo "VERSION is set to: $VERSION" | ||||
| fi | ||||
|  | ||||
| # Check if NEXT_VERSION variable is set | ||||
| if [ -z "$NEXT_VERSION" ]; then | ||||
|   echo "NEXT_VERSION variable is not set." | ||||
|   exit 1 | ||||
| else | ||||
|   echo "NEXT_VERSION is set to: $NEXT_VERSION" | ||||
| fi | ||||
|  | ||||
| # Check if NEXT_BACK_PORT_VERSION variable is set | ||||
| if [ -z "$NEXT_BACK_PORT_VERSION" ]; then | ||||
|   echo "NEXT_BACK_PORT_VERSION variable is not set." | ||||
|   exit 1 | ||||
| else | ||||
|   echo "NEXT_BACK_PORT_VERSION is set to: $NEXT_BACK_PORT_VERSION" | ||||
| fi | ||||
|  | ||||
| # See current branch | ||||
| echo "Current Branch: $(git branch --show-current)" | ||||
|  | ||||
| # See head of current branch | ||||
| echo "Current Head: " | ||||
| git log -n 1 | ||||
|  | ||||
| # See current origin | ||||
| echo "See remotes: " | ||||
| git remote -v | ||||
|  | ||||
| # Set git configs | ||||
| git config --global user.name "${GITHUB_ACTOR}" | ||||
| git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||||
|  | ||||
| # Create and push the new backport branch | ||||
| git checkout master | ||||
| git checkout -b "$NEXT_BACK_PORT_VERSION" | ||||
| git push origin "$NEXT_BACK_PORT_VERSION" | ||||
|  | ||||
| # Step 2: Make sure local unstable is up-to-date | ||||
| git checkout unstable | ||||
| git pull | ||||
|  | ||||
| # Check if current Git branch is named "unstable" | ||||
| current_branch=$(git symbolic-ref --short HEAD 2>/dev/null) | ||||
|  | ||||
| if [ "$current_branch" = "unstable" ]; then | ||||
|   echo "Current Git branch is unstable." | ||||
| else | ||||
|   echo "Current Git branch is not unstable." | ||||
|   exit 2 | ||||
| fi | ||||
|  | ||||
| echo "Updating documentation" | ||||
| jq --arg ver "$VERSION" '.versions += [$ver]' ./documentation/versions.json > /tmp/temp.json | ||||
| mv /tmp/temp.json ./documentation/versions.json | ||||
|  | ||||
| git add . | ||||
| git commit -m "Documentation $VERSION: Append $VERSION to versions.json" | ||||
| echo "Documentation committed" | ||||
|  | ||||
| # Step 3: Create a merge commit and push it | ||||
| git merge -s ours master -m "Merge master to unstable" | ||||
| echo "Master merged to unstable" | ||||
| git push origin unstable | ||||
| echo "Unstable pushed to remote" | ||||
|  | ||||
| # Step 4: Fast-forward master to the merge commit | ||||
| git checkout master | ||||
| git merge unstable | ||||
| echo "Unstable merged in master" | ||||
|  | ||||
| git push | ||||
| echo "Master pushed to remote" | ||||
|  | ||||
| # Update package.json | ||||
| jq --arg ver "$VERSION" '.version = $ver' package.json > /tmp/temp.json | ||||
| mv /tmp/temp.json package.json | ||||
|  | ||||
| # Update package-lock.json | ||||
| jq --arg ver "$VERSION" '.version = $ver' package-lock.json > /tmp/temp.json | ||||
| mv /tmp/temp.json package-lock.json | ||||
|  | ||||
| # Check if version is updated in package.json | ||||
| version_check_package=$(jq -r '.version' package.json) | ||||
| if [ "$version_check_package" != "$VERSION" ]; then | ||||
|   echo "Failed to update version in package.json" | ||||
|   exit 3 | ||||
| else | ||||
|   echo "Version updated in package.json" | ||||
| fi | ||||
|  | ||||
| # Check if version is updated in package-lock.json | ||||
| version_check_package_lock=$(jq -r '.version' package-lock.json) | ||||
| if [ "$version_check_package_lock" != "$VERSION" ]; then | ||||
|   echo "Failed to update version in package-lock.json" | ||||
|   exit 4 | ||||
| else | ||||
|   echo "Version updated in package-lock.json" | ||||
| fi | ||||
|  | ||||
| # Commit and push the updated version files | ||||
| git add package.json package-lock.json | ||||
| git commit -m "Update version to $VERSION" | ||||
| git push | ||||
|  | ||||
| # Update new version in unstable | ||||
| git checkout unstable | ||||
|  | ||||
| # Update package.json | ||||
| jq --arg ver "$NEXT_VERSION" '.version = $ver' package.json > /tmp/temp.json | ||||
| mv /tmp/temp.json package.json | ||||
|  | ||||
| # Update package-lock.json | ||||
| jq --arg ver "$NEXT_VERSION" '.version = $ver' package-lock.json > /tmp/temp.json | ||||
| mv /tmp/temp.json package-lock.json | ||||
|  | ||||
| # Check if version is updated in package.json for unstable | ||||
| version_check_package_unstable=$(jq -r '.version' package.json) | ||||
| if [ "$version_check_package_unstable" != "$NEXT_VERSION" ]; then | ||||
|   echo "Failed to update version in package.json for unstable" | ||||
|   exit 3 | ||||
| else | ||||
|   echo "Version updated in package.json for unstable" | ||||
| fi | ||||
|  | ||||
| # Check if version is updated in package-lock.json for unstable | ||||
| version_check_package_lock_unstable=$(jq -r '.version' package-lock.json) | ||||
| if [ "$version_check_package_lock_unstable" != "$NEXT_VERSION" ]; then | ||||
|   echo "Failed to update version in package-lock.json for unstable" | ||||
|   exit 4 | ||||
| else | ||||
|   echo "Version updated in package-lock.json for unstable" | ||||
| fi | ||||
|  | ||||
| # Commit and push the updated version files | ||||
| git add package.json package-lock.json | ||||
| git commit -m "Update version to $NEXT_VERSION" | ||||
| git push | ||||
|  | ||||
| git checkout master | ||||
							
								
								
									
										37
									
								
								node_modules/cytoscape/.github/workflows/scripts/new-feature-version.sh
									
									
									
										generated
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										37
									
								
								node_modules/cytoscape/.github/workflows/scripts/new-feature-version.sh
									
									
									
										generated
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Get the current version from package.json | ||||
| PREV_VERSION=$(jq -r '.version' package.json) | ||||
| echo "Prev Feature Version $PREV_VERSION" | ||||
|  | ||||
| # Extract the version number by removing the "-unstable" suffix | ||||
| VERSION="${PREV_VERSION%-unstable}" | ||||
| echo "New Master Version $VERSION" | ||||
|  | ||||
| # Split the version number into major, minor, and patch components | ||||
| IFS='.' read -ra VERSION_ARRAY <<< "$VERSION" | ||||
|  | ||||
| # Extract the minor and patch components | ||||
| MINOR_VERSION="${VERSION_ARRAY[1]}" | ||||
| PATCH_VERSION="${VERSION_ARRAY[2]}" | ||||
|  | ||||
| # Decrement the minor version for backport branch | ||||
| ((MINOR_VERSION--)) | ||||
|  | ||||
| # Increment patch for new backport branch | ||||
| NEXT_BACK_PORT_VERSION="${VERSION_ARRAY[0]}.${MINOR_VERSION}.x" | ||||
|  | ||||
| # Increment the minor component for the new unstable version | ||||
| ((MINOR_VERSION++)) | ||||
| ((MINOR_VERSION++)) | ||||
|  | ||||
| # Construct the new unstable version | ||||
| NEXT_VERSION="${VERSION_ARRAY[0]}.${MINOR_VERSION}.0-unstable" | ||||
|  | ||||
| echo "Next Unstable Version: $NEXT_VERSION" | ||||
| echo "Next Backport Version: $NEXT_BACK_PORT_VERSION" | ||||
|  | ||||
| # Export the versions to the GitHub Actions environment | ||||
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | ||||
| echo "NEXT_VERSION=$NEXT_VERSION" >> "$GITHUB_ENV" | ||||
| echo "NEXT_BACK_PORT_VERSION=$NEXT_BACK_PORT_VERSION" >> "$GITHUB_ENV" | ||||
							
								
								
									
										38
									
								
								node_modules/cytoscape/.github/workflows/scripts/new-patch-version.sh
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								node_modules/cytoscape/.github/workflows/scripts/new-patch-version.sh
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Get the current version from package.json | ||||
| PREV_VERSION=$(jq -r '.version' package.json) | ||||
| echo "Prev Patch Version $PREV_VERSION" | ||||
|  | ||||
| # Split the version number into major, minor, and patch components | ||||
| IFS='.' read -a VERSION_ARRAY <<< "$PREV_VERSION" | ||||
| echo "SPLITTING COMPLETED" | ||||
|  | ||||
| major="${VERSION_ARRAY[0]}" | ||||
| minor="${VERSION_ARRAY[1]}" | ||||
| patch="${VERSION_ARRAY[2]}" | ||||
| echo "CURRENT PATCH VERSION $patch" | ||||
|  | ||||
| # Increment the patch version | ||||
| patch=$((patch + 1)) | ||||
| echo "UPDATED PATCH VERSION $patch" | ||||
|  | ||||
| # Form the new version string | ||||
| VERSION="$major.$minor.$patch" | ||||
|  | ||||
| # Split the new version number into major, minor, and patch components to validate | ||||
| IFS='.' read -a VERSION_ARRAY_2 <<< "$VERSION" | ||||
| if [[ ${#VERSION_ARRAY_2[@]} -lt 3 ]]; then | ||||
|     echo "Error: Invalid new version format" | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| # Set the branch name if it's not the master branch | ||||
| if [ "$BRANCH" != "refs/heads/master" ]; then | ||||
|     BRANCH="${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}.x" | ||||
| fi | ||||
|  | ||||
| echo "Version $VERSION" | ||||
|  | ||||
| # Export the new version to the GitHub Actions environment | ||||
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | ||||
							
								
								
									
										85
									
								
								node_modules/cytoscape/.github/workflows/scripts/pre_release_test.sh
									
									
									
										generated
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										85
									
								
								node_modules/cytoscape/.github/workflows/scripts/pre_release_test.sh
									
									
									
										generated
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,85 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # Make script exit on first failure | ||||
| set -e | ||||
|  | ||||
| # Check if VERSION variable is set | ||||
| if [ -z "$VERSION" ]; then | ||||
|   echo "VERSION variable is not set." | ||||
|   exit 1 | ||||
| else | ||||
|   echo "VERSION is set to: $VERSION" | ||||
| fi | ||||
|  | ||||
| # Check if current Git branch is named "master" or the provided branch name | ||||
| current_branch=$(git symbolic-ref --short HEAD 2>/dev/null) | ||||
|  | ||||
| if [ "$current_branch" = "$1" ]; then | ||||
|   echo "Current Git branch is $1." | ||||
| else | ||||
|   echo "Current Git branch is not $1." | ||||
|   exit 2 | ||||
| fi | ||||
|  | ||||
| FILE=./documentation/versions.json | ||||
| if [ -f "$FILE" ]; then | ||||
|   echo "$FILE exists." | ||||
| else  | ||||
|   echo "$FILE doesn't exist. Exiting..." | ||||
|   exit 1 | ||||
| fi | ||||
|  | ||||
| npm install | ||||
| npm run release | ||||
|  | ||||
| if [ "$current_branch" = "unstable" ] || [ "$current_branch" = "master" ]; then  | ||||
|   echo "Starting to check changed files" | ||||
|  | ||||
|   # List the files to check | ||||
|   files_to_check=("documentation/index.html" "documentation/js/cytoscape.min.js" "dist/cytoscape.umd.js") | ||||
|  | ||||
|   echo "Files initialized" | ||||
|  | ||||
|   git status | ||||
|  | ||||
|   # Loop through the files | ||||
|   for file in "${files_to_check[@]}" | ||||
|   do | ||||
|       echo "Checking $file" | ||||
|  | ||||
|       # Check if the file exists in the local FS | ||||
|       if [ -e "$file" ]; then | ||||
|           echo "The file $file exists in the locally-built files." | ||||
|       else | ||||
|           echo "The file $file does not exist in the locally-built files." | ||||
|           exit 1 | ||||
|       fi | ||||
|  | ||||
|       # Check if the file has changed | ||||
|       output="$(git status -s $file)" | ||||
|  | ||||
|       echo "For $file, $output" | ||||
|  | ||||
|       # Check if the file has changed | ||||
|       if [ -z "$output" ]; then | ||||
|           echo "The file $file has not changed." | ||||
|           exit 1 | ||||
|       else | ||||
|           echo "The file $file has changed." | ||||
|       fi | ||||
|   done | ||||
| fi | ||||
|  | ||||
| git add . && git commit -m "Build $VERSION" | ||||
|  | ||||
| git log -n 1 | ||||
|  | ||||
| npm version "$VERSION" --allow-same-version | ||||
|  | ||||
| git push && git push --tags | ||||
|  | ||||
| git remote -v | ||||
|  | ||||
| git remote set-url origin git@github.com:cytoscape/cytoscape.js.git | ||||
|  | ||||
| exit 0 | ||||
		Reference in New Issue
	
	Block a user
	 nik
					nik