Skip to content

Commit

Permalink
Merge pull request #19 from hootanht/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
hootanht authored Sep 12, 2024
2 parents 4a969e5 + 2347498 commit d27e247
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- 'master' # Run the workflow when pushing to the master branch
pull_request: # Run the workflow on pull requests

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
Expand Down Expand Up @@ -87,10 +88,21 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4

# Authenticate with GitHub Packages using the GITHUB_TOKEN secret
- name: Authenticate with GitHub Packages
run: dotnet nuget add source https://nuget.pkg.github.com/hootanht/index.json -n github -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text

# Publish all NuGet packages to GitHub Packages
- name: Publish NuGet package to GitHub Packages
run: |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.GITHUB_TOKEN }}" --source https://nuget.pkg.github.com/hootanht/index.json --skip-duplicate
}
# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish NuGet package
- name: Publish NuGet package to NuGet.org
run: |
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml → .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: CI

on:
pull_request:
branches:
- master
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
pull_request: # Run the workflow on pull requests

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions PersianDate/PersianDate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<NeutralLanguage>en-US</NeutralLanguage>
<PackageProjectUrl>https://github.com/hootanht/PrsianDate</PackageProjectUrl>
<Version>1.0.5</Version>
<RepositoryUrl>https://github.com/hootanht/PrsianDate</RepositoryUrl>
<RepositoryUrl>https://github.com/hootanht/PersianDate</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageSource>https://api.nuget.org/v3/index.json</PackageSource>
<PackageSource>https://nuget.pkg.github.com/hootanht/index.json</PackageSource>
<PublishProfile>nuget</PublishProfile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Persian Data Library is a library that can be convert **Gregorian** (Milady) yea
## Persian Date Public Version
| Target | Branch | Version | Download link | Total downloads | CI Build Status | CD Build Status |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
| Nuget | master | v1.0.5 | [![NuGet](https://img.shields.io/nuget/v/PersianDateShamsi.svg)](https://www.nuget.org/packages/PersianDateShamsi) | [![NuGet downloads](https://img.shields.io/nuget/dt/PersianDateShamsi.svg)](https://www.nuget.org/packages/PersianDateShamsi) | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/ci.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CD.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) |
| Release | master | v1.0.5 | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/ci.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) | | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/ci.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CD.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) |
| Nuget | master | v1.0.5 | [![NuGet](https://img.shields.io/nuget/v/PersianDateShamsi.svg)](https://www.nuget.org/packages/PersianDateShamsi) | [![NuGet downloads](https://img.shields.io/nuget/dt/PersianDateShamsi.svg)](https://www.nuget.org/packages/PersianDateShamsi) | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CI.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CD.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) |
| Release | master | v1.0.5 | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CI.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) | | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CI.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) | [![Build Status](https://github.com/hootanht/PersianDate/actions/workflows/CD.yml/badge.svg)](https://github.com/hootanht/PersianDate/actions) |

## Cross Platform

Expand Down Expand Up @@ -81,8 +81,31 @@ Version 1.0.1

## CI Pipeline

The CI pipeline is now integrated into the CD pipeline and is defined in `.github/workflows/CD.yml`. It uses `macos-latest` as the VM image. The pipeline handles manual triggers, pull requests, and releases. It restores NuGet packages, builds the solution, runs tests, and validates the NuGet package. The pipeline installs .NET version 8.0.x to ensure compatibility with all targeted frameworks.
The CI pipeline is now integrated into the CD pipeline and is defined in `.github/workflows/CI.yml`. It uses `macos-latest` as the VM image. The pipeline handles manual triggers, pull requests, and releases. It restores NuGet packages, builds the solution, runs tests, and validates the NuGet package. The pipeline installs .NET version 8.0.x to ensure compatibility with all targeted frameworks.

## CD Pipeline

The CD pipeline is defined in `.github/workflows/CD.yml` and uses `macos-latest` as the VM image. It includes steps for creating, validating, testing, and deploying the NuGet package. The pipeline handles manual triggers, pull requests, and releases. It uses environment variables for the NuGet directory and the latest versions of GitHub Actions for checkout, setup-dotnet, and upload-artifact. The pipeline installs .NET version 8.0.x to ensure compatibility with all targeted frameworks. Additionally, it includes a step to delete existing tags if they already exist before creating a new release to avoid the 'Validation Failed: already_exists' error. The step now handles the case where the tag deletion fails and ensures the deletion step successfully removes the existing tag before proceeding to create a new release.

## Requirements

- .NET 8.0 SDK

## Setup and Run

1. **Install .NET 8.0 SDK**: Download and install the .NET 8.0 SDK from the official [.NET website](https://dotnet.microsoft.com/download/dotnet/8.0).

2. **Restore Dependencies**: Open a terminal or command prompt in the project directory and run:
```sh
dotnet restore
```

3. **Build the Project**: Build the project by running:
```sh
dotnet build
```

4. **Run Tests**: Run the tests to ensure everything is working correctly:
```sh
dotnet test
```

0 comments on commit d27e247

Please sign in to comment.