First commit.

Signed-off-by: Chen Xiao <abigwc@gmail.com>
This commit is contained in:
Chen Xiao
2026-05-08 14:43:16 +08:00
commit 0b64e2de94
10989 changed files with 2253791 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
name: Feature Release
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the action on'
required: true
default: 'unstable'
jobs:
feature-release:
runs-on: ubuntu-latest
environment: prod
steps:
- name: checkout unstable branch
uses: actions/checkout@v3
with:
ref: 'unstable'
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run tests
run : |
npm test
- name: Determine version for the release
id: get_new_patch_version
run: |
pwd
chmod 777 -R ./* ./.[!.]*
. ./.github/workflows/scripts/new-feature-version.sh
shell: bash
- name: See new master version and jq version
run: |
echo VERSION ${{ env.VERSION }}
jq --version
shell: bash
- name: Checkout Master Branch
uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0
- name: Update documentation and Merge unstable to master branch
run: |
. ./.github/workflows/scripts/merge_unstable_to_master.sh
- name: Build release and verify changes
id: release
run: |
. .github/workflows/scripts/pre_release_test.sh master
- name: Archive code coverage results
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.release.conclusion == 'failure' }}
with:
name: npm-release--failure-report
path: /home/runner/.npm/_logs/
- name: Publish Package to GitHub Releases
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MAIN_GH_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d '{"tag_name":"v${{ env.VERSION }}","target_commitish":"master","name":"v${{ env.VERSION }}","body":"Release version v${{ env.VERSION }}","draft":false,"prerelease":false,"generate_release_notes":false}'
- name: Deploy to Github Pages 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: documentation
- name: Create Issue
run: |
TITLE="Create a blog post for release v$VERSION"
echo "Issue title: $TITLE"
sed ':a;N;$!ba;s/\n/\\n/g' ./.github/workflows/md/blog-issue-template.md > output_file.txt
BODY="$(cat output_file.txt)"
echo "Body: $BODY"
curl -X POST \
-H "Authorization: token ${{ secrets.CYTOSCAPE_JS_BLOG_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/cytoscape/cytoscape.js-blog/issues" \
-d "{\"title\":\"$TITLE\",\"body\":\"$BODY\"}"
npm_publish:
needs: feature-release
permissions:
contents: read
id-token: write
uses: ./.github/workflows/npm-publish.yml
+82
View File
@@ -0,0 +1,82 @@
# Feature Release GitHub Action - README
## Introduction
This GitHub Action, named "Feature Release Test", automates the process of releasing new features for the [Cytoscape.js](https://github.com/cytoscape/cytoscape.js) repository. This action is triggered by a manual workflow_dispatch event, allowing you to specify the version of the new release. The action performs various tasks, including merging changes, running tests, publishing to npmjs and GitHub Releases, deploying to GitHub Pages, and creating a related issue on the repository's blog.
## Prerequisites
Before using this GitHub Action, ensure you have the following prerequisites in place:
1. Access to the [Cytoscape.js](https://github.com/cytoscape/cytoscape.js) repository.
2. Necessary access tokens and secrets stored as GitHub repository secrets:
- `NPM_TOKEN`: Token for npmjs package publishing. Ref: [How to create legacy token in npm](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-legacy-tokens-on-the-website)
- `MAIN_GH_TOKEN`: Token for accessing GitHub API to publish GitHub Releases on Cytoscape/Cytoscape.js repo. Ref: [Create fine-grained-personal-access-tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#fine-grained-personal-access-tokens)
- `CYTOSCAPE_JS_BLOG_TOKEN`: Token for creating issues on the repository's blog Cytoscape/Cytoscape.js-blog repo.
## Usage
1. Navigate to the [Cytoscape.js](https://github.com/cytoscape/cytoscape.js) repository.
2. Go to the [Actions](https://github.com/cytoscape/cytoscape.js/actions) tab.
3. Click on [Feature-Release](https://github.com/cytoscape/cytoscape.js/actions/workflows/feature-release-test.yml) workflow.
4. Click the "Run workflow" button.
5. DO NOT CHANGE BRANCH FROM `unstable` FOR RELEASE. Provide the desired version for the new release when prompted if you want to do a feature release for a specific version. **Note: This version will used as the version of release.** Otherwise, the github will automatically determine a new version based upon package.json version
## Workflow Steps
Below are the steps performed by the "Feature Release Test" GitHub Action:
1. **Checkout Patch Branch**:
- Action: Checks out the `unstable` branch.
- Uses: `actions/checkout@v3`.
2. **Setup Node.js Environment**:
- Action: Sets up Node.js environment.
- Uses: `actions/setup-node@v3`.
- Node Version: 18.
- Caches npm packages.
3. **Get New Version String**:
- Action: Determines the new version for the release.
- Script: Determines the new version based on user input or a script.
- Uses the `github.event.inputs.version` input for the version if provided.
4. **Checkout Master Branch**:
- Action: Checks out the `master` branch.
- Uses: `actions/checkout@v3`.
5. **Merge Unstable to Master Branch**:
- Action: Merges changes from `unstable` to `master` branch.
- Custom script: Fetches and merges changes from the `unstable` branch.
6. **Install Dependencies**:
- Action: Installs project dependencies.
- Command: `npm install`.
7. **Run Tests**:
- Action: Runs tests for the project.
- Command: `npm test`.
8. **Pre Release Tests**:
- Action: Runs pre-release tests.
- Custom script: Executes pre-release tests with the `master` branch.
9. **Archive Code Coverage Results**:
- Action: Archives code coverage results in case of test failure.
- Uses: `actions/upload-artifact@v3`.
10. **Publish Package to npmjs**:
- Action: Publishes the package to npmjs.
- Command: `npm publish`.
11. **Publish Package to GitHub Releases**:
- Action: Publishes the package to GitHub Releases.
- Uses GitHub API to create a release with provided information.
12. **Deploy to Github Pages**:
- Action: Deploys documentation to GitHub Pages.
- Uses: `JamesIves/github-pages-deploy-action@v4`.
13. **Create Issue**:
- Action: Creates an issue on the repository's blog.
- Creates an issue with a title and body based on a template.
+36
View File
@@ -0,0 +1,36 @@
## Release instructions
1. Add the upcoming release version in [version.json](https://github.com/cytoscape/cytoscape.js/blob/unstable/documentation/versions.json) file.
2. Ensure that [milestones](https://github.com/cytoscape/cytoscape.js/milestones) exist for the releases that you would like to make. Each milestone should contain its corresponding issues and pull requests.
1. For patch releases, do the back-port patch release before the corresponding current release. This ensures that npm lists the current version as the latest one.
1. `git checkout 1.1.x`, e.g. if the previous feature release is 1.1
1. Follow the remaining ordinary release steps (step 5 and onward).
1. Current releases are based on the `master` branch: `git checkout master`
1. If you are making a patch release, you can just release `master` with its new patches.
1. If you are making a feature release, you need to merge `unstable` onto `master`. Since there can be conflicts, it's easiest to use the 'ours' strategy which will allow you to use the state of `unstable` as-is (i.e. no conflict resolution necessary):
1. Make sure your local `master` is up-to-date: `git checkout master && git pull`
1. Make sure your local `unstable` is up-to-date: `git checkout unstable && git pull`
1. Create a merge commit that selects the state of `unstable` and push it: `git merge -s ours master && git push`
1. Fast-forward `master` to the merge commit: `git checkout master && git merge unstable && git push`
1. Update the version number in `package.json` and `package-lock.json` on `unstable` to some provisional new version number, and push it.
1. Update the `VERSION` environment variable for the release number you want to make, e.g. `export VERSION=1.2.3`
1. Confirm all the tests are passing:
1. `npm run test`
1. See also `test/index.html` for browser testing (optional)
1. Confirm all the tests are passing in IE9 (for feature releases):
1. `npm run watch:umd`
1. Open an [IE9 VM](https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/)
1. Open `http://yourip:8081/test/ie.html` in IE
1. Prepare a release: `npm run release`
1. Review the files that were just built in the previous step.
1. There should be a series of updated files in the `dist` directory and the `documentation` directory, identified with `git status`.
1. Try out the newly-built docs and demos in your browser.
1. Add the the release to git: `git add . && git commit -m "Build $VERSION"`
1. Update the package version and tag the release: `npm version $VERSION`
1. Push the release changes: `git push && git push --tags`
1. Publish the release to npm: `npm publish`
1. Run `npm run docs:push`
1. [Create a release](https://github.com/cytoscape/cytoscape.js/releases/new) for Zenodo from the latest tag. Make sure you wait at least 5 minutes since the last time that you made a release in order for Zenodo to work properly.
1. For feature releases: Create a release announcement on the [blog](https://github.com/cytoscape/cytoscape.js-blog). Share the announcement on mailing lists and social media.
@@ -0,0 +1,108 @@
# Patch/Backport Release GitHub Action - README
## Introduction
The "Patch Release Test" GitHub Action automates the process of creating a patch release for the [Cytoscape.js](https://github.com/cytoscape/cytoscape.js) repository. This action allows you to define the target branch for the patch release and performs various tasks, including version updating, testing, publishing to npmjs and GitHub Releases, deploying to GitHub Pages, and more.
## Prerequisites
Before using the "Patch Release Test" GitHub Action, ensure you have the following prerequisites:
1. Access to the [Cytoscape.js](https://github.com/cytoscape/cytoscape.js) repository.
2. Necessary access tokens and secrets stored as GitHub repository secrets:
- `NPM_TOKEN`: Token for npmjs package publishing. Ref: [How to create legacy token in npm](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-legacy-tokens-on-the-website)
- `MAIN_GH_TOKEN`: Token for accessing GitHub API to publish GitHub Releases on Cytoscape/Cytoscape.js repo. Ref: [Create fine-grained-personal-access-tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#fine-grained-personal-access-tokens)
## Usage
1. Navigate to the [Cytoscape.js](https://github.com/cytoscape/cytoscape.js) repository.
2. Go to the "Actions" tab.
3. Click on the "Patch Release Test" workflow.
4. Click the "Run workflow" button.
5. Provide the target branch name for the patch release when prompted.
6. For backport release: Make a corresponding patch release.
## Workflow Steps
The "Patch Release Test" GitHub Action comprises the following steps:
1. **Get Branch**:
- Action: Retrieves the target branch for the patch release.
- Script: Sets the `BRANCH` environment variable based on user input.
- Uses the `github.event.inputs.branch` input for branch selection.
2. **Checkout Patch Branch**:
- Action: Checks out the specified patch branch.
- Uses: `actions/checkout@v3`.
- Branch: The branch specified by the `BRANCH` environment variable.
3. **Setup Node.js Environment**:
- Action: Sets up Node.js environment for the workflow.
- Uses: `actions/setup-node@v3`.
- Node Version: 18.
- Caches npm packages.
4. **Get New Version String**:
- Action: Determines the new version for the patch release.
- Script: Retrieves the new version from a script.
- Uses a custom script to calculate the new version.
5. **See Patch Branch**:
- Action: Displays the selected branch for the patch release.
- Command: Outputs the branch stored in the `BRANCH` environment variable.
6. **See New Patch Version**:
- Action: Displays the calculated version for the patch release.
- Command: Outputs the calculated version using the `VERSION` environment variable.
7. **Checkout Master Branch**:
- Action: Checks out the `master` branch.
- Uses: `actions/checkout@v3`.
8. **Update Version on Master**:
- Action: Updates the `versions.json` file on the `master` branch.
- Script: Uses `jq` to add the new version to the `versions.json` file.
- Commits and pushes the updated `versions.json` file.
9. **Checkout Patch Branch Again**:
- Action: Checks out the specified patch branch.
- Uses: `actions/checkout@v3`.
- Branch: The branch specified by the `BRANCH` environment variable.
10. **Update Version on Unstable**:
- Action: Updates the `versions.json` file on the `unstable` branch.
- Script: Uses `jq` to add the new version to the `versions.json` file.
- Commits and pushes the updated `versions.json` file.
- Checks out the original patch branch again.
11. **Install Dependencies**:
- Action: Installs project dependencies.
- Command: `npm install`.
12. **Run Tests**:
- Action: Executes tests for the project.
- Command: `npm test`.
13. **Set Git Config**:
- Action: Configures Git with user information.
- Sets the user name and email based on the GitHub actor.
14. **Pre Release Tests**:
- Action: Executes pre-release tests.
- Uses a custom script to run pre-release tests on the specified branch.
15. **Archive Code Coverage Results**:
- Action: Archives code coverage results in case of test failure.
- Uses: `actions/upload-artifact@v3`.
16. **Publish Package to npmjs**:
- Action: Publishes the package to npmjs.
- Command: `npm publish`.
17. **Publish Package to GitHub Releases**:
- Action: Publishes the package to GitHub Releases.
- Uses GitHub API to create a release with provided information.
18. **Deploy to Github Pages**:
- Action: Deploys documentation to GitHub Pages.
- Uses: `JamesIves/github-pages-deploy-action@v4`.
@@ -0,0 +1,27 @@
## Create Issue for new release
- Create a file with name <i>YYYY-MM-DD-VERSION-release.md</i> in the [_posts](https://github.com/cytoscape/cytoscape.js-blog/tree/gh-pages/_posts) directory.
- Include these main points in the posts
- layout
- title
- subtitle
- tags
- New important features and who contributed to them.
- Full list of changes.
- Sample blog post:
```
---
layout: post
title: Cytoscape.js $VERSION released
subtitle: An overview of what's new in Cytoscape.js $VERSION
tags:
- news
---
Cytoscape.js $VERSION has been released. This version brings with it a [new right-slanting rhomboid shape](https://github.com/cytoscape/cytoscape.js/issues/3123) by [@somaniv](https://github.com/somaniv) and [trusted-types support](https://github.com/cytoscape/cytoscape.js/pull/3118) by [Jakub Vrána](https://github.com/vrana).
The full list of changes can be found in the [3.25.0 milestone on GitHub](https://github.com/cytoscape/cytoscape.js/milestone/236?closed=1).
```
+18
View File
@@ -0,0 +1,18 @@
## Instructions to setup repository for automated releases
### Tokens
- `NPM_TOKEN`: Token for npmjs package publishing. The token should a automation token with no expiration. Ref: [How to create legacy token in npm](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-legacy-tokens-on-the-website)
- `MAIN_GH_TOKEN`: Token for accessing GitHub API to publish GitHub Releases on Cytoscape/Cytoscape.js repo. The token can be set to expire at 1 year (maximum limit of github PAT is 1 year). Ref: [Create fine-grained-personal-access-tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#fine-grained-personal-access-tokens)
- Permissions Required:
- Actions: Read and Write
- Contents: Read and Write
- `CYTOSCAPE_JS_BLOG_TOKEN`: Token for creating issues on the repository's blog Cytoscape/Cytoscape.js-blog repo.
- Permissions Required:
- Issues: Read and Write
### Repository Setup
- Provide Github Actions permissions to read and write. Ref: [Managing Github Actions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository)
+25
View File
@@ -0,0 +1,25 @@
name: npm publish
on:
workflow_call:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
with:
ref: master
- uses: actions/setup-node@v3
with:
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Publish Package To npmjs
run: npm publish --provenance
+118
View File
@@ -0,0 +1,118 @@
name: Patch Release
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to run the action on'
required: true
default: 'master'
jobs:
patch-release:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Extract branch name
shell: bash
id: extract_branch
run: |
echo "BRANCH=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "Branch: " $BRANCH
- name: checkout patch branch
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH }}
- uses: actions/setup-node@v3
with:
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run tests
run : |
npm test
- name: Get new version string
id: get_new_patch_version
run: |
chmod +rx ./.github/workflows/scripts/new-patch-version.sh
. ./.github/workflows/scripts/new-patch-version.sh
shell: bash
- name: See patch branch
run: echo branch ${{ env.BRANCH }}
shell: bash
- name: See new patch version
run: echo "# version:" ${{ env.VERSION }}
shell: bash
- name: checkout master branch
uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0
- name: Set Git Config
run : |
# Set git configs
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Update Version on master
id: update_backport_version_master
run: |
jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
mv /tmp/temp.json ./documentation/versions.json
git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"
git push
- name: checkout unstable branch
uses: actions/checkout@v3
with:
ref: unstable
fetch-depth: 0
- name: Update Version on unstable
id: update_backport_version_unstable
run: |
jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
mv /tmp/temp.json ./documentation/versions.json
git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"
git push
git checkout ${{ env.BRANCH }}
- name: Set Git Config
run : |
# Set git configs
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Make Release
id: release
run: |
chmod +rx .github/workflows/scripts/pre_release_test.sh
. .github/workflows/scripts/pre_release_test.sh ${{ env.BRANCH }}
- name: Archive action failure results
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.release.conclusion == 'failure' }}
with:
name: npm-release--failure-report
path: /home/runner/.npm/_logs/
- name: Publish Package to GitHub Releases
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.MAIN_GH_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases \
-d '{"tag_name":"v${{ env.VERSION }}","target_commitish":"master","name":"v${{ env.VERSION }}","body":"Release version v${{ env.VERSION }}","draft":false,"prerelease":false,"generate_release_notes":false}'
- name: Deploy to Github Pages 🚀
if: ${{ env.BRANCH == 'master' }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: documentation
npm_publish:
needs: patch-release
permissions:
contents: read
id-token: write
uses: ./.github/workflows/npm-publish.yml
@@ -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
@@ -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"
@@ -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"
@@ -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
+18
View File
@@ -0,0 +1,18 @@
name: Automated tests
on: [push, pull_request]
permissions:
contents: read
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run tests
run: npm test