Browse Source

Merge pull request #286 from VaclavElias/master

feat: GitHub Actions improvments, release notes generation added
Vaclav Elias 1 year ago
parent
commit
ae353978c0

+ 16 - 5
.github/workflows/stride-docs-github.yml

@@ -2,6 +2,11 @@
 
 name: Build Stride Docs for GitHub Staging
 
+env:
+  COMMON_SETTINGS_PATH: en/docfx.json
+  VERSION: "2.0.0.${{ github.run_number }}"
+  DOCS_PATH: stride-docs
+
 on:
   workflow_dispatch:
 
@@ -10,8 +15,7 @@ jobs:
     runs-on: windows-2022
 
     steps:
-    # Setup .NET SDK
-    - name: Dotnet Setup
+    - name: .NET SDK Setup
       uses: actions/setup-dotnet@v4
       with:
         dotnet-version: 8.x
@@ -20,9 +24,16 @@ jobs:
     - name: Checkout Stride Docs
       uses: actions/checkout@v4
       with:
-        path: stride-docs
+        path: ${{ env.DOCS_PATH }}
         lfs: true
 
+    - name: Set Version in docfx.json
+      run: |
+        $settingsContent = Get-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Raw
+        $updatedDocFxJsonContent = $settingsContent -replace '2.0.0.x', "${{ env.VERSION }}"
+        Set-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Value $updatedDocFxJsonContent
+      shell: pwsh
+
     # Checkout the Stride repository from the default branch
     - name: Checkout Stride (note the LFS)
       uses: actions/checkout@v4
@@ -40,11 +51,11 @@ jobs:
 
     - name: Build documentation
       run: ./build-all.bat
-      working-directory: stride-docs
+      working-directory: ${{ env.DOCS_PATH }}
 
     - name: Deploy
       uses: peaceiris/[email protected]
       with:
         github_token: ${{ secrets.GITHUB_TOKEN }}
-        publish_dir: stride-docs/_site
+        publish_dir: ${{ env.DOCS_PATH }}/_site
         publish_branch: gh-pages

+ 24 - 7
.github/workflows/stride-docs-release-azure.yml

@@ -3,6 +3,11 @@
 
 name: Build Stride Docs for Azure Web App Release 🚀
 
+env:
+  COMMON_SETTINGS_PATH: en/docfx.json
+  VERSION: "2.0.0.${{ github.run_number }}"
+  DOCS_PATH: stride-docs
+
 on:
   push:
     branches:
@@ -23,8 +28,7 @@ jobs:
     runs-on: windows-2022
 
     steps:
-    # Setup .NET SDK
-    - name: Dotnet Setup
+    - name: .NET SDK Setup
       uses: actions/setup-dotnet@v4
       with:
         dotnet-version: 8.x
@@ -33,9 +37,16 @@ jobs:
     - name: Checkout Stride Docs
       uses: actions/checkout@v4
       with:
-        path: stride-docs
+        path: ${{ env.DOCS_PATH }}
         lfs: true
 
+    - name: Set Version in docfx.json
+      run: |
+        $settingsContent = Get-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Raw
+        $updatedDocFxJsonContent = $settingsContent -replace '2.0.0.x', "${{ env.VERSION }}"
+        Set-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Value $updatedDocFxJsonContent
+      shell: pwsh
+
     # Checkout the Stride repository from the default branch
     - name: Checkout Stride (note the LFS)
       uses: actions/checkout@v4
@@ -53,10 +64,10 @@ jobs:
 
     - name: Build documentation
       run: ./build-all.bat
-      working-directory: stride-docs
+      working-directory: ${{ env.DOCS_PATH }}
 
     - name: Compress artifact
-      run: 7z a -r DocFX-app.zip ./stride-docs/_site/*
+      run: 7z a -r DocFX-app.zip ./${{ env.DOCS_PATH }}/_site/*
 
     - name: Upload artifact for deployment job
       uses: actions/upload-artifact@v4
@@ -64,6 +75,12 @@ jobs:
         name: DocFX-app
         path: DocFX-app.zip
 
+    - name: Create GitHub Release
+      run: |
+        gh release create ${{ env.VERSION }} --title "v${{ env.VERSION }}" --notes "Release notes for ${{ env.VERSION }}" --draft
+      env:
+        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
   deploy:
     if: github.repository == 'stride3d/stride-docs'
     runs-on: windows-2022
@@ -83,7 +100,7 @@ jobs:
     #   run: ls
 
     - name: Decompress artifact
-      run: 7z x DocFX-app.zip "-o./stride-docs/_site"
+      run: 7z x DocFX-app.zip "-o./${{ env.DOCS_PATH }}/_site"
 
     - name: Deploy to Azure Web App
       id: deploy-to-webapp
@@ -92,4 +109,4 @@ jobs:
         app-name: 'stride-doc'
         slot-name: 'Production'
         publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4803638D673FA67D0C8650F34C4FA9D1 }}
-        package: ./stride-docs/_site
+        package: ./${{ env.DOCS_PATH }}/_site

+ 16 - 5
.github/workflows/stride-docs-release-fast-track-azure.yml

@@ -4,6 +4,11 @@
 # The Fast Track skips creating artifacts and compressing them
 name: Build Stride Docs (Fast Track) for Azure Web App Release 🚀
 
+env:
+  COMMON_SETTINGS_PATH: en/docfx.json
+  VERSION: "2.0.0.${{ github.run_number }}"
+  DOCS_PATH: stride-docs
+
 on:
   workflow_dispatch:
 
@@ -17,8 +22,7 @@ jobs:
       name: 'Production'
 
     steps:
-    # Setup .NET SDK
-    - name: Dotnet Setup
+    - name: .NET SDK Setup
       uses: actions/setup-dotnet@v4
       with:
         dotnet-version: 8.x
@@ -27,9 +31,16 @@ jobs:
     - name: Checkout Stride Docs
       uses: actions/checkout@v4
       with:
-        path: stride-docs
+        path: ${{ env.DOCS_PATH }}
         lfs: true
 
+    - name: Set Version in docfx.json
+      run: |
+        $settingsContent = Get-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Raw
+        $updatedDocFxJsonContent = $settingsContent -replace '2.0.0.x', "${{ env.VERSION }}"
+        Set-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Value $updatedDocFxJsonContent
+      shell: pwsh
+
     # Checkout the Stride repository from the default branch
     - name: Checkout Stride (note the LFS)
       uses: actions/checkout@v4
@@ -47,7 +58,7 @@ jobs:
 
     - name: Build documentation
       run: ./build-all.bat
-      working-directory: stride-docs
+      working-directory: ${{ env.DOCS_PATH }}
 
     - name: Deploy to Azure Web App
       id: deploy-to-webapp
@@ -56,4 +67,4 @@ jobs:
         app-name: 'stride-doc'
         slot-name: 'Production'
         publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4803638D673FA67D0C8650F34C4FA9D1 }}
-        package: ./stride-docs/_site
+        package: ./${{ env.DOCS_PATH }}/_site

+ 16 - 5
.github/workflows/stride-docs-staging-fast-track-azure.yml

@@ -4,6 +4,11 @@
 # The Fast Track skips creating artifacts and compressing them
 name: Build Stride Docs (Fast Track) for Azure Web App Staging
 
+env:
+  COMMON_SETTINGS_PATH: en/docfx.json
+  VERSION: "2.0.0.${{ github.run_number }}"
+  DOCS_PATH: stride-docs
+
 on:
   workflow_dispatch:
 
@@ -17,8 +22,7 @@ jobs:
       name: 'Production'
 
     steps:
-    # Setup .NET SDK
-    - name: Dotnet Setup
+    - name: .NET SDK Setup
       uses: actions/setup-dotnet@v4
       with:
         dotnet-version: 8.x
@@ -27,9 +31,16 @@ jobs:
     - name: Checkout Stride Docs
       uses: actions/checkout@v4
       with:
-        path: stride-docs
+        path: ${{ env.DOCS_PATH }}
         lfs: true
 
+    - name: Set Version in docfx.json
+      run: |
+        $settingsContent = Get-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Raw
+        $updatedDocFxJsonContent = $settingsContent -replace '2.0.0.x', "${{ env.VERSION }}"
+        Set-Content -Path "${{ env.DOCS_PATH }}/${{ env.COMMON_SETTINGS_PATH }}" -Value $updatedDocFxJsonContent
+      shell: pwsh
+
     # Checkout the Stride repository from the default branch
     - name: Checkout Stride (note the LFS)
       uses: actions/checkout@v4
@@ -47,7 +58,7 @@ jobs:
 
     - name: Build documentation
       run: ./build-all.bat
-      working-directory: stride-docs
+      working-directory: ${{ env.DOCS_PATH }}
 
     - name: Deploy to Azure Web App
       id: deploy-to-webapp
@@ -56,4 +67,4 @@ jobs:
         app-name: 'stride-doc'
         slot-name: 'staging'
         publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_32FCD402B970463A9143B24C9B225749 }}
-        package: ./stride-docs/_site
+        package: ./${{ env.DOCS_PATH }}/_site