-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick to 3.25.x: Add support for automated releases via GitHub …
…Actions from Akash's GSOC project. Merge pr/AkMo3/3153 into unstable Ref: Github Action for Automated Release #3153
- Loading branch information
Showing
17 changed files
with
1,142 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Feature Release | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
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: 18 | ||
cache: 'npm' | ||
registry-url: 'https://registry.npmjs.org' | ||
- 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: Install dependencies | ||
run: npm install | ||
- name: Run tests | ||
run : | | ||
npm test | ||
- 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@v3 | ||
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 🚀 | ||
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\"}" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Oops, something went wrong.