Skip to content

Bump Microsoft.AspNetCore.Components.Web from 8.0.14 to 8.0.21 #211

Bump Microsoft.AspNetCore.Components.Web from 8.0.14 to 8.0.21

Bump Microsoft.AspNetCore.Components.Web from 8.0.14 to 8.0.21 #211

Workflow file for this run

# TODO could share artifacts between jobs to reduce number of builds
# this should have just been BCLSource %LocalPackagePath% but set locally now
# would have been better with github environments appsetting setting some of program.cs for wasm
name: Dev pipeline for test lint packaging artifact and gh-page trigger
on:
# Trigger the workflow for push requests to all branches except 'main' and 'master'
push:
branches-ignore:
- 'main'
- 'master'
# pull_request:
# branches-ignore:
# - 'main'
# - 'master'
permissions:
contents: write
actions: write
env:
# BUILD_CONFIGURATION: 'Debug'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGES_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
GITHUB_USERNAME: "Phil-NHS"
NUPKG_OUTPUT_PATH: ${{ github.workspace }}/CICDPackageLocation
USE_BCL_PROJECT_REFERENCE: false
BCL_Local_Source: ${{ github.workspace }}/CICDPackageLocation
BCL_Source: "https://nuget.pkg.github.com/phil-nhs/index.json"
jobs:
branch-name-check:
name: Enforce Branch Name Convention
if: success() || failure() #Run all checks incase multiple fixes needed but dont make packages if there are fails
runs-on: ubuntu-latest
steps:
- name: Validate Branch Name
run: |
#BRANCH_NAME="${GITHUB_HEAD_REF}"
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
echo "Validating branch name: $BRANCH_NAME"
if [[ "$BRANCH_NAME" =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|sample|security|config|bugfix|hotfix)-[a-zA-Z0-9._/-]+$ ]] || [[ "$BRANCH_NAME" == "master" ]]; then
echo "✅ Branch name is valid"
else
echo "❌ Invalid branch name: $BRANCH_NAME"
echo "Branch names must follow one of the allowed prefixes:"
echo " build-*, feat-*, fix-*, bugfix-*, hotfix-*, build-*, chore-*, ci-*, docs-*, perf-*, refactor-*, revert-*, style-*, test-*, sample-*, security-*, config-*, bugfix-*, hotfix-*"
exit 1
fi
continue-on-error: false
commitlint:
runs-on: ubuntu-latest
if: success() || failure() #Run all checks incase multiple fixes needed but dont make packages if there are fails
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
with:
configFile: .commitlintrc.json
continue-on-error: false #we dont want to package etc if bad commits also pre-commit prefered
gitguardian-scan:
runs-on: ubuntu-latest
if: success() || failure() #Run all checks incase multiple fixes needed but dont make packages if there are fails
steps:
- uses: actions/checkout@v3
- name: GitGuardian Scan
uses: GitGuardian/gg-shield-action@v1
env:
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
continue-on-error: false # we dont want secrets going further and the keys need to be changed if this is triggered
Unit-Tests:
runs-on: ubuntu-latest
if: success() || failure() #Run all checks incase multiple fixes needed but dont make packages if there are fails
steps:
- name: See other project pipeline for Tests
run: echo " See other project pipeline for Tests this is a placeholder"
continue-on-error: false
E2E-Tests:
runs-on: ubuntu-latest
if: success() || failure() #Run all checks incase multiple fixes needed but dont make packages if there are fails
steps:
- name: See other project pipeline for Tests
run: echo " See other project pipeline for Tests this is a placeholder"
continue-on-error: false
# Now we've done due diligence
generate-dev-semantic-version:
if: success()
needs: [commitlint, gitguardian-scan, Unit-Tests, E2E-Tests, branch-name-check]
runs-on: ubuntu-latest
outputs:
dev-package-version: ${{ steps.set-dev-semantic-version.outputs.dev-semantic-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for Semantic Release to analyze commit history
- name: Install Semantic Release Packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGES_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
run: |
echo "Installing semantic-release packages..."
npm install -D \
semantic-release \
@semantic-release/changelog \
@semantic-release/git \
@semantic-release/commit-analyzer \
@semantic-release/release-notes-generator \
@semantic-release/github
echo "Semantic Release packages installed."
npm ls --depth=0 # Debug: List installed packages
- name: Run Semantic Version (None Blocking)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGES_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
run: |
set +e
SEMVER_OUTPUT_RAW=$(npx semantic-release)
echo "Raw SEMVER_OUTPUT_RAW=$SEMVER_OUTPUT_RAW"
SEMVER_OUTPUT=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Published release \K[^\s]+')
# In dev even if there is no version change we will package and update the website, this means it will for ci which isnt necessary
# but also if we squash a load of commits we will still get the package updated
echo "In dev even if there is no version change we will package and update the website, this means it will for ci which isnt necessary but also if we squash a load of commits we will still get the package updated"
STATUS=$?
if [ -z "$SEMVER_OUTPUT" ]; then
SEMVER_OUTPUT=$(echo "$SEMVER_OUTPUT_RAW" | grep -oP 'Found git tag v\K[^\s]+')
fi
echo "if using git tag it will just be last made so not guaranteed to be the same branch but ok for now"
# Export the result to the environment
echo "SEMVER_OUTPUT=$SEMVER_OUTPUT" >> $GITHUB_ENV
set -e
- name: Rename Semver Version With Date Time Dev
id: set-dev-semantic-version
run: |
echo "Semantic Release Output $SEMVER_OUTPUT"
timestamp=$(date +"%y%m%d-%H%M")
echo "Timestamp $timestamp"
echo "shouldnt timestamp but ok for now"
echo "If it is nonversion triggering change and the first on the branch will get the release version because it is the most recent tag"
full_version="${SEMVER_OUTPUT}-${timestamp}"
echo "extracted version $full_version"
echo "dev-semantic-version=$full_version" >> $GITHUB_OUTPUT
# - name: debug github commands
# run: |
# echo "but we want more complex versioning currently so wont use tag but will for release"
# echo "as we will name commits like fix(broken-thing): changed broken line, and branches fix/broken-thing we should be able to use them in package names"
# echo "branch tag $(git describe --tags --abbrev=0)"
# echo "branch name $(git branch --show-current)"
# echo "Triggering Commit SHA: $GITHUB_SHA"
# echo "Triggering Commit Subject: $(git log -1 --pretty=%s $GITHUB_SHA)"
# echo "Commit Type/Scope: $(git log -1 --pretty=%s $GITHUB_SHA | cut -d':' -f1)"
build-bcl-dev-package-and-publish:
if: success() #not needed but being explicit
needs: [generate-dev-semantic-version, commitlint, gitguardian-scan,Unit-Tests,E2E-Tests, branch-name-check]
runs-on: ubuntu-latest
env:
BCL_VERSION: ${{ needs.generate-dev-semantic-version.outputs.dev-package-version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Debug Version Output BCL var
run: echo "Extracted Version $BCL_VERSION "
# the restore cant be given env values to override values like it can in build so we need to remove this file so we use the env values
- name: Remove Local PackageSettings (CI Only)
run: |
rm -f PackageSettings.props.local
ls
- name: Replace local environment variable in nuget config because cant provide it as a parameter
run: sed -i "s|%LocalPackagePath%|$BCL_Local_Source|g" nuget.config
- name: Clean lock files because the newly generated package file will superseed the locks
run: |
find . -name "packages.lock.json" -type f -exec rm -f {} \;
- name: Set up Node.js so we have gulp for retrieving TEL Frontend Css
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install npm packages so we have gulp for retrieving TEL Frontend Css
working-directory: ./Package.BlazorComponentLibrary
run: npm ci
#CI is an install with adhering to package-lock
- name: Build BlazorComponentLibrary (it publishes on build)
run: |
dotnet build Package.BlazorComponentLibrary -c Release \
/p:BCLVersion=$BCL_VERSION \
/p:NupkgOutputPath=$NUPKG_OUTPUT_PATH \
/p:UseBCLProjectReference=$USE_BCL_PROJECT_REFERENCE
- name: Publish to GitHub DEV BCL Packages
run: |
dotnet nuget push "$BCL_Local_Source/TELBlazorComponentLibrary.GitPageBlazorWasm.*.nupkg" \
--source "https://nuget.pkg.github.com/phil-nhs/index.json" \
--api-key ${{ secrets.PACKAGES_TOKEN }} \
--skip-duplicate
Make-Blazor-Wiki-Artifact-Trigger-GH-Pages-In-BlazorWasmTest:
if: success() #not needed but being explicit
needs: [ branch-name-check, build-bcl-dev-package-and-publish,generate-dev-semantic-version, commitlint, gitguardian-scan, Unit-Tests, E2E-Tests]
runs-on: ubuntu-latest
env:
BCL_VERSION: ${{ needs.generate-dev-semantic-version.outputs.dev-package-version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Clean Solution
run: |
echo "Cleaning the solution..."
dotnet clean GitPageBlazorWASM.sln
- name: Remove Local PackageSettings (CI Only)
run: rm -f PackageSettings.props.local
- name: Replace local environment variable in nuget config because cant provide it as a parameter
run: |
echo "sed -i \"s|%LocalPackagePath%|$BCL_Source|g\" nuget.config"
sed -i "s|%LocalPackagePath%|$BCL_Source|g" nuget.config
sed -i "s|%GITHUB_USERNAME%|$GITHUB_USERNAME|g" nuget.config
sed -i "s|%GITHUB_PACKAGES_TOKEN%|$PACKAGES_TOKEN |g" nuget.config
- name: debug BCL_VERSION
run: |
echo "BCL_VERSION $BCL_VERSION"
- name: Clean lock files because the newly generated package file will superseed the locks
run: |
echo "Listing packages.lock.json files:"
find . -name "packages.lock.json" -type f -print
echo ""
echo "Deleting packages.lock.json files:"
find . -name "packages.lock.json" -type f -exec rm -f {} \;
echo "Listing packages.lock.json files:"
find . -name "packages.lock.json" -type f -print
- name: Build Shared Pages
run: |
dotnet build SharedPages -c Release \
/p:BCLVersion=$BCL_VERSION \
/p:NupkgOutputPath=$NUPKG_OUTPUT_PATH \
/p:UseBCLProjectReference=$USE_BCL_PROJECT_REFERENCE \
/p:GhPageRelease=false \
/p:LocalPackagePath=$BCL_Source
# - name: is it because solution level not receive /p for project so need githun_env values
# run: |
# echo "BCLVersion=$BCL_VERSION" >> $GITHUB_ENV
# echo "LocalPackagePath=$BCL_SOURCE" >> $GITHUB_ENV
# echo "GITHUB_USERNAME=$GITHUB_USERNAME" >> $GITHUB_ENV
# echo "UseBCLProjectReference=$USE_BCL_PROJECT_REFERENCE" >> $GITHUB_ENV
# echo "GITHUB_PACKAGES_TOKEN=$PACKAGES_TOKEN" >> $GITHUB_ENV
# Hardcoding here the INDEPENDENT_CLIENT_GH_PAGES value
- name: Modify appsettings.json with hardcoded value
run: |
jq '.INDEPENDENT_CLIENT_GH_PAGES = "true"' TestHostPrerenderWASM/TestHostPrerenderWASM.Client/wwwroot/appsettings.json > tmp.json && mv tmp.json TestHostPrerenderWASM/TestHostPrerenderWASM.Client/wwwroot/appsettings.json
# List files in the root to ensure appsettings.json exists
- name: List files in TestHostPrerenderWASM.Client
run: ls -la TestHostPrerenderWASM/TestHostPrerenderWASM.Client
# Print the contents of appsettings.json inside 'TestHostPrerenderWASM.Client' folder
- name: Display appsettings.json content
run: cat TestHostPrerenderWASM/TestHostPrerenderWASM.Client/wwwroot/appsettings.json
- name: Publish client using client release .csproj logic
run: |
dotnet publish ./TestHostPrerenderWASM/TestHostPrerenderWASM.Client/TestHostPrerenderWASM.Client.csproj --configuration Release \
/p:BCLVersion=$BCL_VERSION \
/p:NupkgOutputPath=$NUPKG_OUTPUT_PATH \
/p:UseBCLProjectReference=$USE_BCL_PROJECT_REFERENCE \
/p:GhPageRelease=true \
/p:LocalPackagePath=$BCL_Source
# - name: Debug - List all files in docs folder
# run: |
# echo "Listing contents of ./docs directory"
# ls -alh ./docs
# echo "Listing contents of ./docs/wwwroot directory"
# ls -alh ./docs/wwwroot || echo "wwwroot directory not found"
# echo "Checking for bclversion.txt in ./docs"
# if [ -f "./docs/bclversion.txt" ]; then
# echo "Contents of ./docs/bclversion.txt:"
# cat ./docs/bclversion.txt
# else
# echo "bclversion.txt not found in ./docs"
# fi
#include hidden so we get jekyll
- name: Creating artifact of publish folder for test gh page workflow
uses: actions/upload-artifact@v4
with:
name: gh-blazor-components-wiki-site-using-package-${{env.BCL_VERSION}}
include-hidden-files: true
path: |
./docs
./docs/.nojekyll # explicitly include the .nojekyll file
retention-days: 90
- name: Debug artifact location
run: |
# Get the artifact list for the current workflow run
ARTIFACT_LIST=$(gh api "repos/TechnologyEnhancedLearning/GitPageBlazorWASM/actions/runs/${GITHUB_RUN_ID}/artifacts")
# Echo the entire artifact list for debugging purposes
echo "Artifact List: $ARTIFACT_LIST"
# Extract the download URL from the artifact list (first artifact in the list)
#ARTIFACT_URL=$(echo "$ARTIFACT_LIST" | jq -r '.artifacts[0].archive_download_url')
ARTIFACT_URL=$(echo "$ARTIFACT_LIST" | jq -r '.artifacts[0].url')
# Echo the artifact URL to confirm
echo "Artifact URL: $ARTIFACT_URL"
echo "artifact_url=$ARTIFACT_URL" >> $GITHUB_ENV
- name: Trigger Workflow in GitPageBlazorWASM-Test Repository
run: |
# Set the required variables
repo_owner="TechnologyEnhancedLearning" # Replace with the repository owner (organization or user)
repo_name="GitPageBlazorWASM-TestGHPage" # Replace with the repository name
event_type="artifact_ready"
#artifact_url="https://api.github.com/repos/TechnologyEnhancedLearning/GitPageBlazorWASM/actions/artifacts/2859947943"
# Trigger the workflow in another repository
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PACKAGES_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"artifact_url\": \"$artifact_url\"}}"
- name: Debug - List all files
run: |
echo "Listing files in the root directory:"
ls -al
echo "Listing files in the docs directory:"
ls -al ./docs
echo "Checking artifact details:"
gh api "repos/TechnologyEnhancedLearning/GitPageBlazorWASM/actions/runs/${GITHUB_RUN_ID}/artifacts"