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
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
|
||||
|
||||
name: Node.js Package
|
||||
name: Release
|
||||
|
||||
on:
|
||||
release:
|
||||
@ -18,19 +15,8 @@ jobs:
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
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]
|
||||
release:
|
||||
needs: setup
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -45,7 +31,7 @@ jobs:
|
||||
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}"
|
||||
./scripts/docs-config.sh "$VERSION" release
|
||||
npm run docs
|
||||
npm pack
|
||||
env:
|
||||
@ -56,7 +42,7 @@ jobs:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
VERSION: ${{ needs.setup.outputs.version }}
|
||||
- name: Deploy Docs
|
||||
run: ./scripts/deploy-docs.sh "$VERSION"
|
||||
run: ./scripts/deploy-docs.sh "$VERSION" release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
|
||||
GH_AUTH_EMAIL: ${{ secrets.GH_AUTH_EMAIL }}
|
||||
@ -72,3 +58,30 @@ jobs:
|
||||
asset_path: ${{ 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
|
||||
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
|
||||
|
||||
source utils.sh
|
||||
|
||||
TARGET_DIR='gh-pages'
|
||||
TARGET_BRANCH='master'
|
||||
TARGET_REPO_URL="https://$GITHUB_TOKEN@github.com/chartjs/chartjs.github.io.git"
|
||||
|
||||
VERSION=$1
|
||||
MODE=$2
|
||||
TAG=$(tag_from_version "$VERSION" "$MODE")
|
||||
|
||||
function move_sample_redirect {
|
||||
local tag=$1
|
||||
@ -15,7 +19,7 @@ function move_sample_redirect {
|
||||
sed -i -E "s/TAG/$tag/g" samples/$tag/index.html
|
||||
}
|
||||
|
||||
function update_with_tag {
|
||||
function deploy_tagged_files {
|
||||
local tag=$1
|
||||
rm -rf "docs/$tag"
|
||||
cp -r ../dist/docs docs/$tag
|
||||
@ -27,20 +31,6 @@ function update_with_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 {
|
||||
local version=$1
|
||||
local in_files='../dist/chart*.js'
|
||||
@ -55,10 +45,15 @@ git clone $TARGET_REPO_URL $TARGET_DIR
|
||||
cd $TARGET_DIR
|
||||
git checkout $TARGET_BRANCH
|
||||
|
||||
# Copy distribution files
|
||||
deploy_versioned_files $VERSION
|
||||
# https://www.chartjs.org/dist/$VERSION
|
||||
if [["$VERSION" != "$TAG"]] then
|
||||
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
|
||||
|
||||
|
||||
@ -2,21 +2,11 @@
|
||||
|
||||
set -e
|
||||
|
||||
source utils.sh
|
||||
|
||||
VERSION=$1
|
||||
MODE=$2
|
||||
|
||||
# Note: this code also exists in deploy.sh
|
||||
# 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"
|
||||
}
|
||||
TAG=$(tag_from_version "$VERSION" "$MODE")
|
||||
|
||||
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