]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update release process to create versioned docs (#8817)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sun, 4 Apr 2021 13:10:29 +0000 (16:10 +0300)
committerGitHub <noreply@github.com>
Sun, 4 Apr 2021 13:10:29 +0000 (09:10 -0400)
* Update release process to create versioned docs
* Remove test, separate tag

.github/workflows/release.yml [moved from .github/workflows/npmpublish.yml with 65% similarity]
scripts/deploy-docs.sh
scripts/docs-config.sh
scripts/utils.sh [new file with mode: 0644]

similarity index 65%
rename from .github/workflows/npmpublish.yml
rename to .github/workflows/release.yml
index 068eaf7cf04a1578957038fedcdfa5c524ba4cfb..e017eeaf0e17abde6fc8aee533a6a9f38e02331c 100644 (file)
@@ -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 }}
index d6bdccf00ee74a747d4b749e725c724d6cb380fc..7d696208aa1a627b929549475bc4b920d08f69b4 100755 (executable)
@@ -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
 
index 89c71b0538e0003126c8209416e285f81da5972c..9c61add9152ff8e8812ab8c2decee28377f3f44e 100755 (executable)
@@ -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 (file)
index 0000000..1cc8fcb
--- /dev/null
@@ -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
+}