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/10/26 18:41:30 UTC
[lucenenet] branch master updated: Website build automation (#533)
This is an automated email from the ASF dual-hosted git repository.
shazwazza pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
The following commit(s) were added to refs/heads/master by this push:
new f819eb9 Website build automation (#533)
f819eb9 is described below
commit f819eb92c14a1ffddf6c9d60638c8d03c2dafcd3
Author: Shannon Deminick <sd...@gmail.com>
AuthorDate: Wed Oct 27 05:41:23 2021 +1100
Website build automation (#533)
* Starts action for building docs
* allows manual execution
* Try getting current branch again
* Try getting current branch again
* try git cmd again
* try git cmd again
* trigger new build, need to see what happens.
* try deeper fetch depth
* can't use ::debug
* ok, that should work now.
* branch switching
* branch switching
* use regex to match branch name
* bit more cleanup
* Update docs build
* stupid yaml
* bump docfx
* Update docs docfx params to force clear the caches so xrefs work
* oops fix sha1 reference
* oops fix sha1 reference
* oops fix sha1 reference
* trigger another docs build
* try to exit if processes fail along the way.
* Getting deps problems on the build server with our custom plugin, so changing it's deps.
* updates listening path for docs.
* website: Added release notes for 4.8.0-beta00015
* remove temp check
* Updates trigger
* Updates docs trigger
* remove temp check
* remove path triggers that don't work
* change globbing pattern.
Co-authored-by: Shad Storhaug <sh...@shadstorhaug.com>
---
.github/workflows/Lucene-Net-Documentation.yml | 159 +++++++++++++++++++++
.github/workflows/Lucene-Net-Website.yml | 87 ++++++-----
.../LuceneDocsPlugins/LuceneDocsPlugins.csproj | 14 +-
src/docs/LuceneDocsPlugins/app.config | 2 +-
websites/apidocs/docfx.global.json | 20 +--
websites/apidocs/docs.ps1 | 22 ++-
websites/site/site.ps1 | 2 +-
7 files changed, 241 insertions(+), 65 deletions(-)
diff --git a/.github/workflows/Lucene-Net-Documentation.yml b/.github/workflows/Lucene-Net-Documentation.yml
new file mode 100644
index 0000000..555dcda
--- /dev/null
+++ b/.github/workflows/Lucene-Net-Documentation.yml
@@ -0,0 +1,159 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: 'Lucene.Net.Documentation'
+
+# This will:
+# checkout this repo
+# get current or latest tag to parse a version for use in the docs
+# change to docs/VERSION branch
+# Build the docs
+
+# Checkout the website repo
+# Create a branch
+# Commit/Push to the branch
+# Create a PR
+
+# push the docs/VERSION branch
+
+on:
+ workflow_dispatch:
+ push:
+ tags:
+ - Docs_*
+ #branches:
+ #- master
+ paths:
+ - 'websites/apidocs/**'
+ - 'src/docs/LuceneDocsPlugins/**'
+
+env:
+ # If a tag is specified, the tag will be in the format: Docs_4_8_0_beta00013
+ # Or if not tag is specified, the latest Lucene.Net_4_8_0_beta00013 release tag will be used
+ # 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: "${{ github.repository }}-site"
+ GIT_MAIN_REPO: "${{ github.workspace }}\\main-repo\\.git"
+
+jobs:
+ build:
+ runs-on: windows-latest
+ steps:
+
+ # Checkout the main repo with all history so we get all tags
+ - 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
+ $ref = $Env:GITHUB_REF
+
+ 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
+
+ $parts = $tag.Split("_")
+ $version = '';
+ For ($i=1; $i -le $parts.Length; $i++) {
+ $version += $parts[$i]
+ if ($i -eq ($parts.Length - 2)) {
+ $version += "-"
+ }
+ 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"
+ echo "RELEASE_VERSION=$Env:RELEASE_VERSION"
+ shell: powershell
+
+ - name: Change branch
+ run: |
+ git --git-dir "$Env:GIT_MAIN_REPO" checkout -b "docs/${{ env.RELEASE_VERSION }}"
+ shell: powershell
+
+ - name: Build docs
+ run: ./main-repo/websites/apidocs/docs.ps1 -Clean -LuceneNetVersion ${{ env.RELEASE_VERSION }}
+ shell: powershell
+
+ - name: Checkout Lucene.Net website
+ uses: actions/checkout@v2
+ with:
+ repository: ${{ env.SITE_REPO }}
+ ref: asf-site
+ path: website-repo
+
+ - name: Copy documentation site files
+ run: Get-ChildItem -Path "$Env:GITHUB_WORKSPACE\main-repo\websites\apidocs\_site" | Copy-Item -Destination "$Env:GITHUB_WORKSPACE\website-repo\docs\$Env:RELEASE_VERSION" -Recurse -Force
+ shell: powershell
+
+ # Always push to the same branch based on the CURRENT_TAG (latest version tag)
+ # Because we are always building the docs against a consistent version
+ - name: Create Pull Request
+ id: cpr
+ uses: peter-evans/create-pull-request@v3
+ with:
+ token: ${{ secrets.LUCENE_NET_WEBSITE_BUILD }}
+ path: website-repo
+ commit-message: New documentation version built
+ committer: GitHub <no...@github.com>
+ author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
+ branch: ${{ env.CURRENT_TAG }}
+ delete-branch: true
+ title: 'New documentation version built ${{ env.CURRENT_TAG }}'
+ body: |
+ New documentation version built ${{ env.CURRENT_TAG }}
+ - For version ${{ env.RELEASE_VERSION }}
+
+ - name: Check outputs
+ run: |
+ echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
+ echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
+
+ # TODO: Commit and push docs branch
diff --git a/.github/workflows/Lucene-Net-Website.yml b/.github/workflows/Lucene-Net-Website.yml
index 173766c..c77e59d 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,83 +27,95 @@ name: 'Lucene.Net.Website'
# Create a PR
on:
- create:
- tags:
- - Website_*
+ workflow_dispatch:
push:
+ tags:
+ - Website_*
#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/**'
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:
+
+ # Checkout the main repo with all history so we get all tags
- 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
$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
-
- $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 "parsed version is $version"
+ 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"
echo "RELEASE_VERSION=$Env:RELEASE_VERSION"
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:
repository: ${{ env.SITE_REPO }}
ref: asf-site
path: website-repo
+
- name: Copy website files
run: Get-ChildItem -Path "$Env:GITHUB_WORKSPACE\main-repo\websites\site\_site" | Copy-Item -Destination "$Env:GITHUB_WORKSPACE\website-repo" -Recurse -Force
shell: powershell
+
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
@@ -113,12 +125,13 @@ jobs:
commit-message: New website version built
committer: GitHub <no...@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
- branch: task/website-build-${{ env.CURRENT_TAG }}
+ branch: task/website-build-${{ github.sha }}
delete-branch: true
- title: 'New website build ${{ env.CURRENT_TAG }}'
+ title: 'New website build ${{ github.sha }}'
body: |
- New website build on rev/tag ${{ env.CURRENT_TAG }}
+ New website build on rev/tag ${{ github.sha }}
For release version ${{ env.RELEASE_VERSION }}
+
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
diff --git a/src/docs/LuceneDocsPlugins/LuceneDocsPlugins.csproj b/src/docs/LuceneDocsPlugins/LuceneDocsPlugins.csproj
index db6def1..d747c58 100644
--- a/src/docs/LuceneDocsPlugins/LuceneDocsPlugins.csproj
+++ b/src/docs/LuceneDocsPlugins/LuceneDocsPlugins.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -77,17 +77,11 @@ under the License.
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.DocAsCode.Dfm">
- <Version>2.47.0</Version>
- </PackageReference>
- <PackageReference Include="System.Composition">
+ <PackageReference Include="Microsoft.Composition">
<Version>1.0.31</Version>
</PackageReference>
- <PackageReference Include="System.Composition.Hosting">
- <Version>1.3.0</Version>
- </PackageReference>
- <PackageReference Include="YamlDotNet.Signed">
- <Version>6.0.0</Version>
+ <PackageReference Include="Microsoft.DocAsCode.Dfm">
+ <Version>2.58.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/src/docs/LuceneDocsPlugins/app.config b/src/docs/LuceneDocsPlugins/app.config
index 8daa7c8..c10b554 100644
--- a/src/docs/LuceneDocsPlugins/app.config
+++ b/src/docs/LuceneDocsPlugins/app.config
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
diff --git a/websites/apidocs/docfx.global.json b/websites/apidocs/docfx.global.json
index 4b7c184..d042649 100644
--- a/websites/apidocs/docfx.global.json
+++ b/websites/apidocs/docfx.global.json
@@ -1,14 +1,14 @@
{
"_appTitle": "Apache Lucene.NET 4.8.0-beta00014 Documentation",
- "_disableContribution": false,
- "_appFaviconPath": "logo/favicon.ico",
- "_enableSearch": true,
- "_appLogoPath": "logo/lucene-net-color.png",
- "_appFooter": "Copyright \u0026copy; 2021 The Apache Software Foundation, Licensed under the \u003ca href=\u0027http://www.apache.org/licenses/LICENSE-2.0\u0027 target=\u0027_blank\u0027\u003eApache License, Version 2.0\u003c/a\u003e\u003cbr/\u003e \u003csmall\u003eApache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation. \u003cbr/\u003eAll other marks mentioned may be trademarks or regist [...]
- "_gitContribute": {
- "repo": "https://github.com/apache/lucenenet",
+ "_disableContribution": false,
+ "_appFaviconPath": "logo/favicon.ico",
+ "_enableSearch": true,
+ "_appLogoPath": "logo/lucene-net-color.png",
+ "_appFooter": "Copyright © 2021 The Apache Software Foundation, Licensed under the <a href='http://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache License, Version 2.0</a><br/> <small>Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation. <br/>All other marks mentioned may be trademarks or registered trademarks of their respective owners.</small>",
+ "_gitContribute": {
+ "repo": "https://github.com/apache/lucenenet",
"branch": "docs/4.8.0-beta00014",
- "apiSpecFolder": "websites/apidocs/apiSpec"
- },
- "_gitSource": "https://github.com/apache/lucenenet.git"
+ "apiSpecFolder": "websites/apidocs/apiSpec"
+ },
+ "_gitSource": "https://github.com/apache/lucenenet.git"
}
diff --git a/websites/apidocs/docs.ps1 b/websites/apidocs/docs.ps1
index 390da4d..b35bb23 100644
--- a/websites/apidocs/docs.ps1
+++ b/websites/apidocs/docs.ps1
@@ -35,6 +35,8 @@ param (
[int] $StagingPort = 8080
)
+$ErrorActionPreference = "Stop"
+
# if the base URL is the lucene live site default value we also need to include the version
if ($BaseUrl -eq 'https://lucenenet.apache.org/docs/') {
$BaseUrl += $LuceneNetVersion
@@ -72,7 +74,7 @@ $DocFxExe = "$ToolsFolder\docfx\docfx.exe"
if (-not (test-path $DocFxExe)) {
Write-Host "Retrieving docfx..."
$DocFxZip = "$ToolsFolder\tmp\docfx.zip"
- Invoke-WebRequest "https://github.com/dotnet/docfx/releases/download/v2.56.2/docfx.zip" -OutFile $DocFxZip -TimeoutSec 60
+ Invoke-WebRequest "https://github.com/dotnet/docfx/releases/download/v2.58/docfx.zip" -OutFile $DocFxZip -TimeoutSec 60
#unzip
Expand-Archive $DocFxZip -DestinationPath (Join-Path -Path $ToolsFolder -ChildPath "docfx")
@@ -121,9 +123,13 @@ if ($DisablePlugins -eq $false) {
$pluginSln = (Join-Path -Path $RepoRoot "src\docs\DocumentationTools.sln")
& $nuget restore $pluginSln
+ if (-not $?) {throw "Failed to restore plugin sln"}
+
$PluginsFolder = (Join-Path -Path $ApiDocsFolder "Templates\LuceneTemplate\plugins")
New-Item $PluginsFolder -type directory -force
& $msbuild $pluginSln /target:LuceneDocsPlugins "/p:OutDir=$PluginsFolder"
+
+ if (-not $?) {throw "Failed to build plugin sln"}
}
# update the docjx.global.json file based
@@ -205,15 +211,19 @@ if ($? -and $DisableBuild -eq $false) {
# build the output
Write-Host "Building site output for $projFile..."
- # Before we build the site we have to clear the frickin docfx cache!
- # else the xref links don't work on the home page. That is crazy.
- Remove-Item (Join-Path -Path $ApiDocsFolder "obj\.cache") -recurse -force -ErrorAction SilentlyContinue
+ # Specifying --force, --forcePostProcess and --cleanupCacheHistory
+ # seems to be required in order for all xref links to resolve consistently across
+ # all of the docfx builds (see https://dotnet.github.io/docfx/RELEASENOTE.html?tabs=csharp).
+ # Previously we used to do this:
+ # Remove-Item (Join-Path -Path $ApiDocsFolder "obj\.cache") -recurse -force -ErrorAction SilentlyContinue
+ # to force remove the cache else the xref's wouldn't work correctly. So far with these new parameters
+ # it seems much happier.
if ($Clean) {
- & $DocFxExe build $projFile --log "$DocFxLog" --loglevel $LogLevel --force --debug
+ & $DocFxExe build $projFile --log "$DocFxLog" --loglevel $LogLevel --force --debug --cleanupCacheHistory --force --forcePostProcess
}
else {
- & $DocFxExe build $projFile --log "$DocFxLog" --loglevel $LogLevel --debug
+ & $DocFxExe build $projFile --log "$DocFxLog" --loglevel $LogLevel --debug --cleanupCacheHistory --force --forcePostProcess
}
# Add the baseUrl to the output xrefmap, see https://github.com/dotnet/docfx/issues/2346#issuecomment-356054027
diff --git a/websites/site/site.ps1 b/websites/site/site.ps1
index 60e65d0..241ebbb 100644
--- a/websites/site/site.ps1
+++ b/websites/site/site.ps1
@@ -52,7 +52,7 @@ if (-not (test-path $DocFxExe))
{
Write-Host "Retrieving docfx..."
$DocFxZip = "$ToolsFolder\tmp\docfx.zip"
- Invoke-WebRequest "https://github.com/dotnet/docfx/releases/download/v2.56.6/docfx.zip" -OutFile $DocFxZip -TimeoutSec 60
+ Invoke-WebRequest "https://github.com/dotnet/docfx/releases/download/v2.58/docfx.zip" -OutFile $DocFxZip -TimeoutSec 60
#unzip
Expand-Archive $DocFxZip -DestinationPath (Join-Path -Path $ToolsFolder -ChildPath "docfx")
}