Skip to content

Merge pull request #47 from TechnologyEnhancedLearning/feat-add-tel-f… #182

Merge pull request #47 from TechnologyEnhancedLearning/feat-add-tel-f…

Merge pull request #47 from TechnologyEnhancedLearning/feat-add-tel-f… #182

Workflow file for this run

name: release
on:
push:
branches:
- 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
IS_LOCAL_DEV: false
USE_BCL_PROJECT_REFERENCE: false
BCL_Local_Source: ${{ github.workspace }}/CICDPackageLocation
BCL_Source: "https://nuget.pkg.github.com/phil-nhs/index.json"
jobs:
generate-semantic-version:
runs-on: ubuntu-latest
outputs:
semantic-release-version: ${{ steps.set-semantic-version.outputs.semantic-release-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: Debug Git Remote Branches
run: git remote show origin
- name: Check Existing Tags
run: |
echo "Checking existing tags..."
git fetch --tags
git tag -l # List all tags to see if there are any conflicts
##configured with .releaseseec
- name: run semantic release
id: set-semantic-version
env:
github_token: ${{ secrets.github_token }}
run: |
set +e
SEMVER_VERSION=$(npx semantic-release | grep -oP 'Published release \K[\d.]+')
echo "semantic-release-version=$SEMVER_VERSION" >> $GITHUB_OUTPUT
# Check if SEMVER_VERSION is empty and echo the message if so
if [ -z "$SEMVER_VERSION" ]; then
echo "Changes do not warrant a version change. gh_pages and packages won't be updated."
fi
set -e
build-bcl-package-and-publish:
needs: [generate-semantic-version]
runs-on: ubuntu-latest
if: ${{ needs.generate-semantic-version.outputs.semantic-release-version != '' }} # Only run if there's a version
env:
BCL_VERSION: ${{ needs.generate-semantic-version.outputs.semantic-release-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
- name: List files in the directory and check for nuget.config
run: |
ls
ls -l nuget.config
- name: Print environment variables
run: |
echo "BCL_Local_Source=$BCL_Local_Source"
echo "BCL_VERSION=$BCL_VERSION"
- 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: Restore NuGet Packages for Specifically the BCL Package Library Project
run: dotnet restore Package.BlazorComponentLibrary/Package.BlazorComponentLibrary.csproj
- 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 and Pack BlazorComponentLibrary
run: |
dotnet build Package.BlazorComponentLibrary -c Release \
/p:BCLVersion=$BCL_VERSION \
/p:NupkgOutputPath=$NUPKG_OUTPUT_PATH
- name: echo hint information about restore
run: echo "if a hash error occurs for the bcl package the version number may need increasing or a clean step"
- name: Publish to GitHub Prod 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
Update-gh-pages-site:
needs: [build-bcl-package-and-publish, generate-semantic-version]
runs-on: ubuntu-latest
if: ${{ needs.generate-semantic-version.outputs.semantic-release-version != '' }} # Only run if there's a version
env:
BCL_VERSION: ${{ needs.generate-semantic-version.outputs.semantic-release-version }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- 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
# Blazor client so appsetting in wwwroot and public
- 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
- name: Create docs directory
run: mkdir -p docs
- 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
# No this will be in the release branch that we do a prod wiki host
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs # The folder the action should deploy
branch: gh-pages # The branch the action should deploy to