Skip to content

Commit

Permalink
Merge pull request #51 from OfficeForProductSafetyAndStandards/featur…
Browse files Browse the repository at this point in the history
…e/ci-cd-pipelines

Implement initial set of CI/CD pipelines
  • Loading branch information
RichardPriddy authored Dec 13, 2024
2 parents cf20db2 + f5d15e7 commit fad503f
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 1 deletion.
74 changes: 74 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CD for OPSS GDS Blazor Component Library

on:
pull_request:
types: [closed]
branches:
- main

jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Setup .NET
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

# Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

# Restore dependencies
- name: Restore dependencies
run: dotnet restore

# Increment the package version number
- name: Increment version number
working-directory: Opss.DesignSystem.Frontend.Blazor.Components
run: |
current_version=$(cat Opss.DesignSystem.Frontend.Blazor.Components.csproj | grep '<Version>' | sed -E 's/<\/?Version>//g' | xargs)
new_version=$(echo $current_version | awk -F. '{print $1"."$2+1".0"}')
sed -i "s/<Version>$current_version<\/Version>/<Version>$new_version<\/Version>/" Opss.DesignSystem.Frontend.Blazor.Components.csproj
echo "Updated version to $new_version"
# Build the solution
- name: Build the solution
run: dotnet build --no-restore --configuration Release

# Pack the Components project
- name: Pack Components project
working-directory: Opss.DesignSystem.Frontend.Blazor.Components
run: dotnet pack Opss.DesignSystem.Frontend.Blazor.Components.csproj --configuration Release --output ./artifacts

- name: LS
run: ls -l

# Push package to NuGet
- name: Push package to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
working-directory: Opss.DesignSystem.Frontend.Blazor.Components/artifacts
run: |
dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key $NUGET_API_KEY
# Check if the file has changed before committing
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: .
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git add Opss.DesignSystem.Frontend.Blazor.Components/Opss.DesignSystem.Frontend.Blazor.Components.csproj
git commit -m "Update version number" || echo "No changes to commit"
git push origin HEAD:develop
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI for OPSS GDS Blazor Component Library

on:
pull_request:
branches:
- develop

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Setup .NET
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

# Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

# Restore dependencies
- name: Restore dependencies
run: dotnet restore

# Build the solution
- name: Build the solution
run: dotnet build --no-restore --configuration Release

# Run tests
- name: Run tests
run: dotnet test
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Version>1.0.0-alpha.3</Version>
<Version>0.1.0</Version>
</PropertyGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
Expand Down

0 comments on commit fad503f

Please sign in to comment.