From: Jukka Kurkela Date: Sun, 4 Apr 2021 13:10:29 +0000 (+0300) Subject: Update release process to create versioned docs (#8817) X-Git-Tag: v3.1.0~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6d43bbbc55b8aedbb5cd040f7dea06f6fd9e7b8;p=thirdparty%2FChart.js.git Update release process to create versioned docs (#8817) * Update release process to create versioned docs * Remove test, separate tag --- diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/release.yml similarity index 65% rename from .github/workflows/npmpublish.yml rename to .github/workflows/release.yml index 068eaf7cf..e017eeaf0 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/scripts/deploy-docs.sh b/scripts/deploy-docs.sh index d6bdccf00..7d696208a 100755 --- a/scripts/deploy-docs.sh +++ b/scripts/deploy-docs.sh @@ -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 diff --git a/scripts/docs-config.sh b/scripts/docs-config.sh index 89c71b053..9c61add91 100755 --- a/scripts/docs-config.sh +++ b/scripts/docs-config.sh @@ -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" diff --git a/scripts/utils.sh b/scripts/utils.sh new file mode 100644 index 000000000..1cc8fcb30 --- /dev/null +++ b/scripts/utils.sh @@ -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 +}