mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Update release process to create versioned docs (#8817)
* Update release process to create versioned docs * Remove test, separate tag
This commit is contained in:
parent
77cdadb1dc
commit
c6d43bbbc5
@ -1,7 +1,4 @@
|
|||||||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
name: Release
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
|
||||||
|
|
||||||
name: Node.js Package
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
@ -18,19 +15,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TAG: ${{ github.event.release.tag_name }}
|
TAG: ${{ github.event.release.tag_name }}
|
||||||
|
|
||||||
test:
|
release:
|
||||||
runs-on: ubuntu-latest
|
needs: setup
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Use Node.js
|
|
||||||
uses: actions/setup-node@v1
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
npm ci
|
|
||||||
xvfb-run --auto-servernum npm test
|
|
||||||
|
|
||||||
publish-npm:
|
|
||||||
needs: [test, setup]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -45,7 +31,7 @@ jobs:
|
|||||||
json -I -f package.json -e "this.version=\"$VERSION\""
|
json -I -f package.json -e "this.version=\"$VERSION\""
|
||||||
json -I -f package-lock.json -e "this.version=\"$VERSION\""
|
json -I -f package-lock.json -e "this.version=\"$VERSION\""
|
||||||
npm run build
|
npm run build
|
||||||
./scripts/docs-config.sh "${VERSION}"
|
./scripts/docs-config.sh "$VERSION" release
|
||||||
npm run docs
|
npm run docs
|
||||||
npm pack
|
npm pack
|
||||||
env:
|
env:
|
||||||
@ -56,7 +42,7 @@ jobs:
|
|||||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||||
VERSION: ${{ needs.setup.outputs.version }}
|
VERSION: ${{ needs.setup.outputs.version }}
|
||||||
- name: Deploy Docs
|
- name: Deploy Docs
|
||||||
run: ./scripts/deploy-docs.sh "$VERSION"
|
run: ./scripts/deploy-docs.sh "$VERSION" release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
|
||||||
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
|
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
|
||||||
@ -72,3 +58,30 @@ jobs:
|
|||||||
asset_path: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
|
asset_path: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
|
||||||
asset_name: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
|
asset_name: ${{ format('chart.js-{0}.tgz', needs.setup.outputs.version) }}
|
||||||
asset_content_type: application/gzip
|
asset_content_type: application/gzip
|
||||||
|
release-tag:
|
||||||
|
needs: [setup,release]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: "!github.event.release.prerelease"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: '14.x'
|
||||||
|
registry-url: https://registry.npmjs.org/
|
||||||
|
- name: Setup and build
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm install -g json
|
||||||
|
json -I -f package.json -e "this.version=\"$VERSION\""
|
||||||
|
json -I -f package-lock.json -e "this.version=\"$VERSION\""
|
||||||
|
npm run build
|
||||||
|
./scripts/docs-config.sh "$VERSION"
|
||||||
|
npm run docs
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.setup.outputs.version }}
|
||||||
|
- name: Deploy Docs
|
||||||
|
run: ./scripts/deploy-docs.sh "$VERSION"
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
|
||||||
|
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
|
||||||
|
VERSION: ${{ needs.setup.outputs.version }}
|
||||||
@ -2,11 +2,15 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
source utils.sh
|
||||||
|
|
||||||
TARGET_DIR='gh-pages'
|
TARGET_DIR='gh-pages'
|
||||||
TARGET_BRANCH='master'
|
TARGET_BRANCH='master'
|
||||||
TARGET_REPO_URL="https://$GITHUB_TOKEN@github.com/chartjs/chartjs.github.io.git"
|
TARGET_REPO_URL="https://$GITHUB_TOKEN@github.com/chartjs/chartjs.github.io.git"
|
||||||
|
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
|
MODE=$2
|
||||||
|
TAG=$(tag_from_version "$VERSION" "$MODE")
|
||||||
|
|
||||||
function move_sample_redirect {
|
function move_sample_redirect {
|
||||||
local tag=$1
|
local tag=$1
|
||||||
@ -15,7 +19,7 @@ function move_sample_redirect {
|
|||||||
sed -i -E "s/TAG/$tag/g" samples/$tag/index.html
|
sed -i -E "s/TAG/$tag/g" samples/$tag/index.html
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_with_tag {
|
function deploy_tagged_files {
|
||||||
local tag=$1
|
local tag=$1
|
||||||
rm -rf "docs/$tag"
|
rm -rf "docs/$tag"
|
||||||
cp -r ../dist/docs docs/$tag
|
cp -r ../dist/docs docs/$tag
|
||||||
@ -27,20 +31,6 @@ function update_with_tag {
|
|||||||
deploy_versioned_files $tag
|
deploy_versioned_files $tag
|
||||||
}
|
}
|
||||||
|
|
||||||
# Note: this code also exists in docs-config.sh
|
|
||||||
# tag is next|latest|master
|
|
||||||
# https://www.chartjs.org/docs/$tag/
|
|
||||||
# https://www.chartjs.org/dist/$tag/chart.*js
|
|
||||||
function update_tagged_files {
|
|
||||||
if [ "$VERSION" == "master" ]; then
|
|
||||||
update_with_tag master
|
|
||||||
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
|
|
||||||
update_with_tag latest
|
|
||||||
else
|
|
||||||
update_with_tag next
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function deploy_versioned_files {
|
function deploy_versioned_files {
|
||||||
local version=$1
|
local version=$1
|
||||||
local in_files='../dist/chart*.js'
|
local in_files='../dist/chart*.js'
|
||||||
@ -55,10 +45,15 @@ git clone $TARGET_REPO_URL $TARGET_DIR
|
|||||||
cd $TARGET_DIR
|
cd $TARGET_DIR
|
||||||
git checkout $TARGET_BRANCH
|
git checkout $TARGET_BRANCH
|
||||||
|
|
||||||
# Copy distribution files
|
# https://www.chartjs.org/dist/$VERSION
|
||||||
|
if [["$VERSION" != "$TAG"]] then
|
||||||
deploy_versioned_files $VERSION
|
deploy_versioned_files $VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
update_tagged_files
|
# https://www.chartjs.org/dist/$TAG
|
||||||
|
# https://www.chartjs.org/docs/$TAG
|
||||||
|
# https://www.chartjs.org/samples/$TAG
|
||||||
|
deploy_tagged_files $TAG
|
||||||
|
|
||||||
git add --all
|
git add --all
|
||||||
|
|
||||||
|
|||||||
@ -2,21 +2,11 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
source utils.sh
|
||||||
|
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
|
MODE=$2
|
||||||
|
|
||||||
# Note: this code also exists in deploy.sh
|
TAG=$(tag_from_version "$VERSION" "$MODE")
|
||||||
# tag is next|latest|master
|
|
||||||
# https://www.chartjs.org/docs/$tag/
|
|
||||||
function update_config {
|
|
||||||
local tag=''
|
|
||||||
if [ "$VERSION" == "master" ]; then
|
|
||||||
tag=master
|
|
||||||
elif [[ "$VERSION" =~ ^[^-]+$ ]]; then
|
|
||||||
tag=latest
|
|
||||||
else
|
|
||||||
tag=next
|
|
||||||
fi
|
|
||||||
sed -i -e "s/VERSION/$tag/g" "docs/.vuepress/config.js"
|
|
||||||
}
|
|
||||||
|
|
||||||
update_config
|
sed -i -e "s/VERSION/$TAG/g" "docs/.vuepress/config.js"
|
||||||
|
|||||||
23
scripts/utils.sh
Normal file
23
scripts/utils.sh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# tag is next|latest|master|x.x.x
|
||||||
|
# https://www.chartjs.org/dist/$tag/
|
||||||
|
# https://www.chartjs.org/docs/$tag/
|
||||||
|
# https://www.chartjs.org/samples/$tag/
|
||||||
|
function tag_from_version {
|
||||||
|
local version=$1
|
||||||
|
local mode=$2
|
||||||
|
local tag=''
|
||||||
|
if [ "$version" == "master" ]; then
|
||||||
|
tag=master
|
||||||
|
elif [[ "$version" =~ ^[^-]+$ ]]; then
|
||||||
|
if [[ "$mode" == "release" ]]
|
||||||
|
tag=$version
|
||||||
|
else
|
||||||
|
tag=latest
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
tag=next
|
||||||
|
fi
|
||||||
|
echo $tag
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user