Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement initial set of CI/CD pipelines #51

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading