-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPL-12294: Preparing for package publish. (#9)
Preparing for package publish * Refactor existing workflows to one file. * Inspired https://www.meziantou.net/publishing-a-nuget-package-following-best-practices-using-github.htm
- Loading branch information
1 parent
6529246
commit 15cb9a0
Showing
15 changed files
with
203 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
# src: https://www.meziantou.net/publishing-a-nuget-package-following-best-practices-using-github.htm | ||
|
||
name: publish | ||
on: | ||
workflow_dispatch: # Allow running the workflow manually from the GitHub UI | ||
push: | ||
branches: | ||
- 'main' # Run the workflow when pushing to the main branch | ||
pull_request: | ||
branches: | ||
- '*' # Run the workflow for all pull requests | ||
release: | ||
types: | ||
- published # Run the workflow when a new GitHub release is published | ||
|
||
env: | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | ||
DOTNET_NOLOGO: true | ||
NuGetDirectory: ${{ github.workspace}}/nuget | ||
|
||
defaults: | ||
run: | ||
shell: pwsh | ||
|
||
jobs: | ||
create-nuget: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer | ||
|
||
# Install the .NET SDK indicated in the global.json file | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
|
||
# Create the NuGet package in the folder from the environment variable NuGetDirectory | ||
- run: dotnet pack dotnet/UneceGenerator --configuration Release --output ${{ env.NuGetDirectory }} | ||
|
||
# Publish the NuGet package as an artifact, so they can be used in the following jobs | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: nuget | ||
if-no-files-found: error | ||
retention-days: 7 | ||
path: ${{ env.NuGetDirectory }}/*.nupkg | ||
|
||
validate-nuget: | ||
runs-on: ubuntu-latest | ||
needs: [ create-nuget ] | ||
steps: | ||
# Install the .NET SDK indicated in the global.json file | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
|
||
# Download the NuGet package created in the previous job | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: nuget | ||
path: ${{ env.NuGetDirectory }} | ||
|
||
- name: Install nuget validator | ||
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global | ||
|
||
# Validate metadata and content of the NuGet package | ||
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab | ||
# If some rules are not applicable, you can disable them | ||
# using the --excluded-rules or --excluded-rule-ids option | ||
- name: Validate package | ||
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") --excluded-rules Symbols --excluded-rule-ids 52 | ||
|
||
dotnet-tests: | ||
uses: ./.github/workflows/dotnet-tests.yml | ||
with: | ||
working-directory: "dotnet/UneceGenerator" | ||
|
||
python-tests: | ||
uses: ./.github/workflows/python-tests.yml | ||
with: | ||
working-directory: "python" | ||
|
||
deploy: | ||
# Publish only when creating a GitHub Release | ||
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository | ||
# You can update this logic if you want to manage releases differently | ||
if: github.event_name == 'release' | ||
runs-on: ubuntu-latest | ||
needs: [ validate-nuget, dotnet-tests, python-tests ] | ||
steps: | ||
# Download the NuGet package created in the previous job | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: nuget | ||
path: ${{ env.NuGetDirectory }} | ||
|
||
# Install the .NET SDK indicated in the global.json file | ||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v4 | ||
|
||
# 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 | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<Nullable>enable</Nullable> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# UNECE units dotnet tools | ||
|
||
This solution consists of two projects: | ||
|
||
- [UneceGenerator](UneceGenerator/README.md) which can be used to re-generate the C# classes based on | ||
the `parsedUneceUnits.json` file created by the | ||
python [unece_excel_parser](../../python/src/unece_excel_parser/README.md) tool. | ||
- [UneceUnits](UneceUnits/README.md) final output project with generated C# classes which is published as a NuGet | ||
package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
dotnet/UneceGenerator/UneceUnits.Contract/UneceUnits.Contract.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>UneceUnits</RootNamespace> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
</Project> |
4 changes: 0 additions & 4 deletions
4
dotnet/UneceGenerator/UneceUnits.Tests/UneceUnits.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<Title>UneceUnits</Title> | ||
<PackageId>UneceUnits</PackageId> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/quadient/unece-units</PackageProjectUrl> | ||
<Copyright>https://www.quadient.com</Copyright> | ||
<RepositoryUrl>https://github.com/quadient/unece-units</RepositoryUrl> | ||
<Authors>Quadient, jakubsemerak, yardee</Authors> | ||
<PackageTags>UNECE; units; rec. 20; rec.21</PackageTags> | ||
<Description> | ||
UNECE Units generated structures for working with UNECE rec. 20 and rec. 21 standards. | ||
</Description> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<PackageReleaseNotes>https://github.com/quadient/unece-units/releases/</PackageReleaseNotes> | ||
|
||
<!-- Generate XML documentation --> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<NoWarn>CS0618,CS1591</NoWarn> | ||
<PackageIcon>quadient.png</PackageIcon> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\UneceUnits.Contract\UneceUnits.Contract.csproj" /> | ||
<ProjectReference Include="..\UneceUnits.Contract\UneceUnits.Contract.csproj"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MinVer" Version="5.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="README.md" Pack="true" PackagePath=""/> | ||
<None Include="quadient.png" Pack="true" PackagePath=""/> | ||
</ItemGroup> | ||
</Project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"rollForward": "feature", | ||
"version": "8.0.200" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# UNECE units python pre-processing tool | ||
|
||
Python based UNECE Excel Parser that parses input UNECE XLXS file into pre-processed JSON output. | ||
|
||
This JSON can then used as input to re-generate dotnet UNECE units classes in | ||
the [dotnet UneceGenerator](../../../dotnet/UneceGenerator/README.md). | ||
|
||
# Development | ||
|
||
- developed using python `3.12.0` | ||
- mainly using `pint` library for linking units | ||
- in the project root folder: | ||
- `cd python` | ||
- create virtual environment `python -m venv venv` | ||
- activate virtual environment, for example on windows run `.\venv\Scripts\Activate.ps1` | ||
- run `pip install -e src/unece_excel_parser` to install dependencies & fix imports | ||
- run `pip install -e src/unece_excel_parser[dev]` to install dev dependencies (for running tests) | ||
- (optional) set python interpreter in dev IDE to point to python.exe in venv folder | ||
|
||
## Run | ||
|
||
From `python/src/unece_excel_parser` folder run: | ||
|
||
`python .\unece_excel_parser.py -rec20 files/rec20_Rev17e-2021.xlsx -rec21 files/rec21_Rev12e_Annex-V-VI_2021.xls` |