You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sh...@apache.org on 2021/08/17 21:15:59 UTC

[lucenenet] 01/01: Update website build script based on my fork tests and to see if the PAT from infra is working or not.

This is an automated email from the ASF dual-hosted git repository.

shazwazza pushed a commit to branch docs/bugfix/testing-website-build
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit a9ad666edcafe83de6e40ab65426301eb83049db
Author: Shannon <sd...@gmail.com>
AuthorDate: Tue Aug 17 15:15:34 2021 -0600

    Update website build script based on my fork tests and to see if the PAT from infra is working or not.
---
 .github/workflows/Lucene-Net-Website.yml | 70 ++++++++++++++++++++------------
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/.github/workflows/Lucene-Net-Website.yml b/.github/workflows/Lucene-Net-Website.yml
index 173766c..ae5fa60 100644
--- a/.github/workflows/Lucene-Net-Website.yml
+++ b/.github/workflows/Lucene-Net-Website.yml
@@ -15,11 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
-
 name: 'Lucene.Net.Website'
 
 # This will:
 # checkout this repo
+# get current or latest tag to parse a version for use in the website
 # Build the website
 # Checkout the website repo
 # Create a branch
@@ -27,6 +27,7 @@ name: 'Lucene.Net.Website'
 # Create a PR
 
 on:
+  workflow_dispatch:
   create:
     tags:
       - Website_*
@@ -34,58 +35,72 @@ on:
     #branches:
     #- master
     paths:
-    - 'websites/site/**/*'
-    #- '.github/workflows/Lucene-Net-Website.yml' # This causes the action to run whenever this file is added to any branch (seems like overkill)
+    - 'websites/site/**'
+    - '.github/workflows/Lucene-Net-Website.yml'
 
 env:
   # If a tag is specified, the tag will be in the format: Website_4_8_0_beta00013 which
   # will be parsed to create the version number used in the docs like 4.8.0-beta00013
   CURRENT_TAG: "NO-VERSION"
   RELEASE_VERSION: "(no tag)"
-  # SITE_REPO: shazwazza/lucenenet-site
-  SITE_REPO: apache/lucenenet-site
+  SITE_REPO: "${{ github.repository }}-site"
+  GIT_MAIN_REPO:  "${{ github.workspace }}\\main-repo\\.git"
 
 jobs:
   build:
     runs-on: windows-latest
-    if: ${{ github.repository == 'apache/lucenenet' }} # Run only on the main fork (SHAZWAZZA - check whether this is right)
     steps:
       - name: Checkout Lucene.Net source
         uses: actions/checkout@v2
         with:
           path: main-repo
-       
+          fetch-depth: 0
+
       - name: Set version from tag
         run: |
           # initialize to SHA
-          echo ("CURRENT_TAG=" + $Env:GITHUB_SHA) >> $env:GITHUB_ENV          
+          echo ("CURRENT_TAG=" + $Env:GITHUB_SHA) >> $env:GITHUB_ENV
           $ref = $Env:GITHUB_REF
-          
-          # if the ref is a tag
+
           if ($ref.StartsWith("refs/tags/")) {
             $tag = $ref.Substring(10)
+            echo "extracted tag name from refs/tags as $tag"
+          }
+          else {
+            echo "Get the latest Lucene.Net_ tag"
+            $tag = & git --git-dir "$Env:GIT_MAIN_REPO" tag --list --sort=-version:refname 'Lucene.Net_[0-9]_[0-9]_[0-9]*' | select -first 1
+          }
+
+          if ($tag -eq $null) {
+            echo "::error::Could not determine current version tag"
+            exit 1
+          }
 
-            # write the environment var
-            echo ("CURRENT_TAG=" + $tag) >> $env:GITHUB_ENV
+          # write the environment var
+          echo ("CURRENT_TAG=" + $tag) >> $env:GITHUB_ENV
 
-            $parts = $tag.Split("_")
-            $version = '';
-            For ($i=0; $i -le $parts.Length; $i++) {
-                $version += $parts[$i]
-                if ($i -eq ($parts.Length - 2)) {
-                    $version += "-"
-                }
-                elseif ($i -lt ($parts.Length - 1)) {
-                    $version += "."
-                }
+          $parts = $tag.Split("_")
+          $version = '';
+          For ($i=1; $i -le $parts.Length; $i++) {
+            $version += $parts[$i]
+            if ($i -eq ($parts.Length - 2)) {
+              $version += "-"
             }
-            if ($version -ne '') {
-              # the tag parsed to the correct version format, write the environment var
-              echo ("RELEASE_VERSION=" + $version) >> $env:GITHUB_ENV
+            elseif ($i -lt ($parts.Length - 1)) {
+              $version += "."
             }
           }
+
+          if ($version -ne '') {
+            # the tag parsed to the correct version format, write the environment var
+            echo ("RELEASE_VERSION=" + $version) >> $env:GITHUB_ENV
+          }
+          else {
+            echo "::error::Could not parse current version tag"
+            exit 1
+          }
         shell: powershell
-        
+
       - name: Verify environment variables
         run: |
           echo "CURRENT_TAG=$Env:CURRENT_TAG"
@@ -93,8 +108,9 @@ jobs:
         shell: powershell
 
       - name: Build website
-        run: ./main-repo/websites/site/site.ps1
+        run: ./main-repo/websites/site/site.ps1 -Clean
         shell: powershell
+
       - name: Checkout Lucene.Net website
         uses: actions/checkout@v2
         with: