diff --git a/.github/ISSUE_TEMPLATE/backport.md b/.github/ISSUE_TEMPLATE/backport.md deleted file mode 100644 index 30619ff965..0000000000 --- a/.github/ISSUE_TEMPLATE/backport.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: Back-port -about: Create a back-port issue for a patch that is applied to a previous version -title: 'Back-port: Copy-paste the title of the corresponding issue here' -labels: bug -assignees: '' - ---- - -This issue is for the back-porting of the following issue to a previous feature release: - -- [ ] Original issue: -- [ ] Tag this issue with the corresponding milestone. diff --git a/.github/workflows/feature-release.yml b/.github/workflows/feature-release.yml index 74af5fe982..4d422635e5 100644 --- a/.github/workflows/feature-release.yml +++ b/.github/workflows/feature-release.yml @@ -2,6 +2,11 @@ name: Feature Release on: workflow_dispatch: + inputs: + branch: + description: 'Branch to run the action on' + required: true + default: 'unstable' jobs: feature-release: diff --git a/.github/workflows/patch-release.yml b/.github/workflows/patch-release.yml index 0ac936af00..fd792e3bdd 100644 --- a/.github/workflows/patch-release.yml +++ b/.github/workflows/patch-release.yml @@ -2,6 +2,11 @@ name: Patch Release on: workflow_dispatch: + inputs: + branch: + description: 'Branch to run the action on' + required: true + default: 'master' jobs: patch-release: @@ -12,7 +17,7 @@ jobs: shell: bash id: extract_branch run: | - echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV + echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV echo "Branch: " $BRANCH - name: checkout patch branch uses: actions/checkout@v3 diff --git a/.github/workflows/scripts/merge_unstable_to_master.sh b/.github/workflows/scripts/merge_unstable_to_master.sh index 48ad8740d6..03b4e9460c 100755 --- a/.github/workflows/scripts/merge_unstable_to_master.sh +++ b/.github/workflows/scripts/merge_unstable_to_master.sh @@ -6,7 +6,7 @@ set -e # Check if VERSION variable is set if [ -z "$VERSION" ]; then echo "VERSION variable is not set." - return 1; + exit 1 else echo "VERSION is set to: $VERSION" fi @@ -14,44 +14,38 @@ fi # Check if NEXT_VERSION variable is set if [ -z "$NEXT_VERSION" ]; then echo "NEXT_VERSION variable is not set." - return 1; + exit 1 else - echo "NEXT_VERSION is set to: $VERSION" + 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." - return 1; + 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)" +echo "Current Branch: $(git branch --show-current)" # See head of current branch -echo "# Current Head: " +echo "Current Head: " git log -n 1 # See current origin -echo "# See remotes: " +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" -# Check if the branch exists -if git rev-parse --verify "$branch_name" >/dev/null 2>&1; then - exit 1 -else - echo "Branch '$branch_name' does not exist." -fi - -git checkout -b $NEXT_BACK_PORT_VERSION -git push -f origin $NEXT_BACK_PORT_VERSION +# 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 @@ -64,11 +58,11 @@ if [ "$current_branch" = "unstable" ]; then echo "Current Git branch is unstable." else echo "Current Git branch is not unstable." - return 2; + exit 2 fi echo "Updating documentation" -jq --arg ver "$VERSION" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json +jq --arg ver "$VERSION" '.versions += [$ver]' ./documentation/versions.json > /tmp/temp.json mv /tmp/temp.json ./documentation/versions.json git add . @@ -77,44 +71,42 @@ 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" +echo "Master merged to unstable" git push origin unstable -echo "# Unstable pushed to remote" - +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" +echo "Unstable merged in master" git push -echo "# Unstable pushed to remote" +echo "Master pushed to remote" # Update package.json -jq --arg ver "$VERSION" '.version = $ver' package.json >> /tmp/temp.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 +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 [ -z "$version_check_package" ]; then - echo "# Failed to update version in package.json" - return 3 +if [ "$version_check_package" != "$VERSION" ]; then + echo "Failed to update version in package.json" + exit 3 else - echo "# Version updated in package.json" + 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 [ -z "$version_check_package_lock" ]; then - echo "# Failed to update version in package-lock.json" - return 4 +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" + echo "Version updated in package-lock.json" fi # Commit and push the updated version files @@ -122,35 +114,33 @@ git add package.json package-lock.json git commit -m "Update version to $VERSION" git push - -# Update new to new version in unstable +# Update new version in unstable git checkout unstable # Update package.json -jq --arg ver "$NEXT_VERSION" '.version = $ver' package.json >> /tmp/temp.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 +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 +# Check if version is updated in package.json for unstable version_check_package_unstable=$(jq -r '.version' package.json) -if [ -z "$version_check_package_unstable" ]; then - echo "# Failed to update version in package.json for unstable" - return 3 +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" + echo "Version updated in package.json for unstable" fi -# Check if version is updated in package-lock.json +# Check if version is updated in package-lock.json for unstable version_check_package_lock_unstable=$(jq -r '.version' package-lock.json) -if [ -z "$version_check_package_lock_unstable" ]; then - echo "# Failed to update version in package-lock.json for unstable" - return 4 +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" + echo "Version updated in package-lock.json for unstable" fi # Commit and push the updated version files @@ -158,4 +148,4 @@ git add package.json package-lock.json git commit -m "Update version to $NEXT_VERSION" git push -git checkout master +git checkout master \ No newline at end of file diff --git a/.github/workflows/scripts/new-feature-version.sh b/.github/workflows/scripts/new-feature-version.sh index d6653d3d1f..220d6e8691 100755 --- a/.github/workflows/scripts/new-feature-version.sh +++ b/.github/workflows/scripts/new-feature-version.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Get the current version from package.json PREV_VERSION=$(jq -r '.version' package.json) echo "Prev Feature Version $PREV_VERSION" @@ -10,23 +11,27 @@ 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++)) -# Increment the minor component and construct the new 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" -echo "VERSION=$VERSION" >> $GITHUB_ENV -echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV -echo "NEXT_BACK_PORT_VERSION=$NEXT_BACK_PORT_VERSION" >> $GITHUB_ENV +# 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" \ No newline at end of file diff --git a/.github/workflows/scripts/new-patch-version.sh b/.github/workflows/scripts/new-patch-version.sh index 1b08ed14cf..bc41b84f3d 100644 --- a/.github/workflows/scripts/new-patch-version.sh +++ b/.github/workflows/scripts/new-patch-version.sh @@ -1,5 +1,6 @@ #!/bin/bash +# Get the current version from package.json PREV_VERSION=$(jq -r '.version' package.json) echo "Prev Patch Version $PREV_VERSION" @@ -7,27 +8,31 @@ echo "Prev Patch Version $PREV_VERSION" 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 +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 +echo "UPDATED PATCH VERSION $patch" +# Form the new version string VERSION="$major.$minor.$patch" -# Split the version number into major, minor, and patch components +# 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 -if [ $BRANCH != "refs/heads/master" ]; then +# 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" -echo "VERSION=$VERSION" >> $GITHUB_ENV +# Export the new version to the GitHub Actions environment +echo "VERSION=$VERSION" >> "$GITHUB_ENV" \ No newline at end of file diff --git a/.github/workflows/scripts/pre_release_test.sh b/.github/workflows/scripts/pre_release_test.sh index a6f45f9809..c3ca7f147b 100755 --- a/.github/workflows/scripts/pre_release_test.sh +++ b/.github/workflows/scripts/pre_release_test.sh @@ -1,43 +1,43 @@ #!/bin/bash # Make script exit on first failure -# set -e +set -e # Check if VERSION variable is set if [ -z "$VERSION" ]; then echo "VERSION variable is not set." - exit 1; + exit 1 else echo "VERSION is set to: $VERSION" fi -# Check if current Git branch is named "master" +# 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." - return 2; + exit 2 fi FILE=./documentation/versions.json if [ -f "$FILE" ]; then - echo "$FILE exists." + echo "$FILE exists." else - echo "$FILE doesn't exists. Exiting..." + echo "$FILE doesn't exist. Exiting..." exit 1 fi - + npm run release -if [ "$current_branch" = "unstable"] || ["$current_branch" = "master"]; then +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" "documentation/versions.json") + # List the files to check + files_to_check=("documentation/index.html" "documentation/js/cytoscape.min.js" "dist/cytoscape.umd.js") - echo "files initialised" + echo "Files initialized" git status @@ -46,13 +46,20 @@ if [ "$current_branch" = "unstable"] || ["$current_branch" = "master"]; then do echo "Checking $file" - git status -s $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 @@ -66,7 +73,7 @@ git add . && git commit -m "Build $VERSION" git log -n 1 -npm version $VERSION --allow-same-version +npm version "$VERSION" --allow-same-version git push && git push --tags @@ -74,4 +81,4 @@ git remote -v git remote set-url origin git@github.com:cytoscape/cytoscape.js.git -exit 0 +exit 0 \ No newline at end of file diff --git a/README.md b/README.md index 30b38623ea..c8b7fc8d43 100644 --- a/README.md +++ b/README.md @@ -136,14 +136,37 @@ The default test scripts run directly against the source code. Tests can altern ## Release instructions -- [Manual Release](.github/workflows/md/Manual_Release.md) -- [Feature Release](.github/workflows/md/Feature_Release.md) -- [Backport/Patch Release](.github/workflows/md/Patch_Backport_Release.md) +### Background -**IMP: The releases should be made atleast 5 min apart for the zenodo to pick the new release.** -**IMP: Amend Github Action in all branches for consistent results across branches** +- Ensure that a milestone exists for the release you want to make, with all the issues for that release assigned in the milestone. +- Bug fixes should be applied to both the `master` and `unstable` branches. PRs can go on either branch, with the patch applied to the other branch after merging. +- When a patch release is made concurrently with a feature release, the patch release should be made first. Wait 5 minutes after the patch release completes before starting the feature release -- otherwise Zenodo doesn't pick up releases properly. -- Repository Setup for Github Actions: [Repository Setup](.github/workflows/md/repo-setup.md) +### Patch version + +1. Go to [Actions > Feature release](https://github.com/cytoscape/cytoscape.js/actions/workflows/patch-release.yml) +1. Go to the 'Run workflow' dropdown +1. [Optional] The 'master' branch should be preselected for you +1. Press the green 'Run workflow' button +1. Close the milestone for the release + + + +### Feature version + +1. Go to [Actions > Feature release](https://github.com/cytoscape/cytoscape.js/actions/workflows/feature-release.yml) +1. Go to the 'Run workflow' dropdown +1. [Optional] The 'unstable' branch should be preselected for you +1. Press the green 'Run workflow' button +1. Close the milestone for the release +1. Make the release announcement [on the blog](https://github.com/cytoscape/cytoscape.js-blog) + + + +### Notes on GitHub Actions UI + +- 'Use workflow from' in the GitHub UI selects the branch from which the workflow YML file is selected. Since the workflow files should usually be the same on the master and unstable branches, it shouldn't matter what's selected. +- 'Branch to run the action on' in the GitHub UI is preselected for you. You don't need to change it. ## Tests diff --git a/documentation/img/preview-feature.png b/documentation/img/preview-feature.png new file mode 100644 index 0000000000..f27f2710e2 Binary files /dev/null and b/documentation/img/preview-feature.png differ diff --git a/documentation/img/preview-patch.png b/documentation/img/preview-patch.png new file mode 100644 index 0000000000..99c85a15ec Binary files /dev/null and b/documentation/img/preview-patch.png differ diff --git a/documentation/md/getting-started.md b/documentation/md/getting-started.md index 38770dcfdb..1e03f25fdc 100644 --- a/documentation/md/getting-started.md +++ b/documentation/md/getting-started.md @@ -31,9 +31,9 @@ The available files are available under [`cytoscape/dist/`](https://github.com/c | --- | --- | --- | --- | | `cytoscape.min.js` | yes | [UMD] (Universal Module Definition) | For use with globals or `require()`. | | `cytoscape.umd.js` | no | [UMD] | For debugging with globals or `require()`. | -| `cytoscape.esm.min.js` | yes | [ESM] (ECMAScript, uses `import` / `export`) | For use with modern `import`/`export`, i.e. `import cytoscape from 'cytoscape'`. | +| `cytoscape.esm.min.mjs` | yes | [ESM] (ECMAScript, uses `import` / `export`) | For use with modern `import`/`export`, i.e. `import cytoscape from 'cytoscape'`. | | `cytoscape.cjs.js` | no | [CJS] (CommonJS, used by [Node.js]) | Intended to be consumed automatically by [Node.js] or a bundler like [Webpack] via `require('cytoscape')`. | -| `cytoscape.esm.js` | no | [ESM] | Intended to be consumed automatically by [Node.js] or a bundler like [Webpack] via `import cytoscape from 'cytoscape'`. This file may alternatively be used for manually debugging ESM builds or pages that use ESM. | +| `cytoscape.esm.mjs` | no | [ESM] | Intended to be consumed automatically by [Node.js] or a bundler like [Webpack] via `import cytoscape from 'cytoscape'`. This file may alternatively be used for manually debugging ESM builds or pages that use ESM. | Note that Cytoscape.js uses the dimensions of your HTML DOM element container for layouts and rendering at initialisation. Thus, it is very important to place your CSS stylesheets in the `` before any Cytoscape.js-related code. Otherwise, dimensions may be sporadically reported incorrectly, resulting in undesired behaviour. diff --git a/package.json b/package.json index 6455d445e7..043f6f86d2 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "build:min": "cross-env FILE=min rollup -c", "clean": "rimraf build/*", "copyright": "node -r esm license-update", - "dist:copy": "cpy build/cytoscape.umd.js build/cytoscape.min.js build/cytoscape.cjs.js build/cytoscape.esm.mjs build/cytoscape.esm.min.mjs dist", + "dist:copy": "cpy --flat build/cytoscape.umd.js build/cytoscape.min.js build/cytoscape.cjs.js build/cytoscape.esm.mjs build/cytoscape.esm.min.mjs dist", "dist": "cross-env NODE_ENV=production run-s build dist:*", "release": "run-s copyright dist docs", "watch": "run-s watch:fast", @@ -83,7 +83,7 @@ "test:modules:debug": "mocha inspect -r esm test/modules", "travis": "run-s build test:build test:modules lint", "docs": "run-s docs:build docs:js", - "docs:js": "cpy build/cytoscape.min.js documentation/js", + "docs:js": "cpy --flat build/cytoscape.min.js documentation/js", "docs:build": "node documentation/docmaker.js", "docs:push": "gh-pages -d documentation", "benchmark": "run-s benchmark:all",