完成世界书、骰子、apiconfig页面处理

This commit is contained in:
2026-04-30 01:35:10 +08:00
parent a3e3711b2b
commit ba9b925c32
4602 changed files with 785225 additions and 23 deletions

View File

@@ -0,0 +1,29 @@
**Cross-references to related issues.** If there is no existing issue that describes your bug or feature request, then [create an issue](https://github.com/cytoscape/cytoscape.js/issues/new/choose) before making your pull request.
Associated issues:
- #X
- #Y
- #Z
**Notes re. the content of the pull request.** Give context to reviewers or serve as a general record of the changes made. Add a screenshot or video to demonstrate your new feature, if possible.
- This PR adds this.
- This PR does that.
- This PR allows us to do some other thing.
**Checklist**
Author:
- [ ] The proper base branch has been selected. New features go on `unstable`. Bug-fix patches can go on either `unstable` or `master`.
- [ ] Automated tests have been included in this pull request, if possible, for the new feature(s) or bug fix. Check this box if tests are not pragmatically possible (e.g. rendering features could include screenshots or videos instead of automated tests).
- [ ] The associated GitHub issues are included (above).
- [ ] Notes have been included (above).
- [ ] For new or updated API, the `index.d.ts` Typescript definition file has been appropriately updated.
Reviewers:
- [ ] All automated checks are passing (green check next to latest commit).
- [ ] At least one reviewer has signed off on the pull request.
- [ ] For bug fixes: Just after this pull request is merged, it should be applied to both the `master` branch and the `unstable` branch. Normally, this just requires cherry-picking the corresponding merge commit from `master` to `unstable` -- or vice versa.

View File

@@ -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`.

View File

@@ -0,0 +1,115 @@
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 npmjs
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- 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