Skip to content

Commit

Permalink
Merge branch 'develop' into feature/NM-PolyhedralMeshes
Browse files Browse the repository at this point in the history
  • Loading branch information
nrmontagne committed Nov 23, 2023
2 parents dfb84de + e4d0631 commit 6ff944a
Show file tree
Hide file tree
Showing 22 changed files with 875 additions and 938 deletions.
204 changes: 100 additions & 104 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,76 @@
# This workflow creates the deployement on github.
# This workflow manages the deployement of BRIDGES:
# - NuGet Package for relevant branches (see "deploy-package" environment)
# - Pre-Release and Release for release and master branches, respectively
name: Deploy

# Controls the event triggering the workflow
on:
# Gives the possibility to trigger the workflow manually.
workflow_dispatch:
inputs:
version:
description: 'Package Version: v[Major].[Minor].[Patch]'
required: true
type: string

env:
# Path of the Project being Tested and Packaged.
PROJECT_PATH: 'BRIDGES/BRIDGES.csproj'
# Output directory for the NuGet Package
PKG_OUTPUT_DIR: ${{ github.workspace }}/output
# URL of the GitHub Package Repository
NUGET_SRC_URL: https://nuget.pkg.github.com/bridges-libraries/index.json
on: # Controls the event triggering the workflow
workflow_dispatch: # The workflow can be triggered manually.

env: # Environment variable shared among the jobs
PKG_OUTPUT_DIR: ${{ github.workspace }}/output # Output directory for the NuGet Package

# Token automatically generated by GitHub for the workflow
GITHUB_TOKEN: ${{ github.token }}

jobs:
# Verify the inputs & Set up the workflow
verify_inputs:

runs-on : ubuntu-latest

# Map a step output to a job output
manage_version:
runs-on: ubuntu-latest # Specify the runner os
environment: versioning # Specify the protection rules, variables and secrets
outputs:
version_number : ${{ steps.verify-version.outputs.PKG_VERSION_NUMBER }}

pkg_version: ${{ steps.create-version.outputs.PKG_VERSION }}
pkg_release_type: ${{ steps.create-version.outputs.PKG_RELEASE_TYPE }}
steps:
- name: Verify branch
# Get the repository variable and Increment the version
- name: Select and Increment version
id: create-version
shell: bash
run: |
if [[ ${{github.ref}} =~ .*master$ ]]
then
echo "The reference branch is 'master'"
elif [[ ${{github.ref}} =~ ^.*/release/.*$ ]]
then
echo "The reference branch is 'release'"
elif [[ ${{github.ref}} =~ .*develop$ ]]
then
echo "The reference branch is 'develop'"
else
exit 1
fi
- name: Verify version & Get version number
id: verify-version
shell: bash
run : |
version=${{inputs.version}}
if [[ ${version} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
echo "PKG_VERSION_NUMBER=${version:1}" >> $GITHUB_OUTPUT
else
echo "The package version must start with 'v'."
exit 1
version=${{vars.VERSION}} # Get the current package version
numbers=( ${version//./ } ) # Split into array to get version numbers
if [[ ${{github.ref}} =~ .*master$ ]]; then # For master branch
((numbers[0]++)) # Increment the major version number
version="${numbers[0]}.0.0"
echo "PKG_VERSION=$version" >> $GITHUB_OUTPUT
echo "PKG_RELEASE_TYPE=" >> $GITHUB_OUTPUT
elif [[ ${{github.ref}} =~ ^.*/release/.*$ ]]; then # For release branches
((numbers[1]++)) # Increment the minor version number
version="${numbers[0]}.${numbers[1]}.0"
echo "PKG_VERSION=$version" >> $GITHUB_OUTPUT
echo "PKG_RELEASE_TYPE=" >> $GITHUB_OUTPUT
elif [[ ${{github.ref}} =~ .*develop$ ]]; then # For release branch
((numbers[2]++)) # Increment the patch version number
version="${numbers[0]}.${numbers[1]}.${numbers[2]}"
echo "PKG_VERSION=$version" >> $GITHUB_OUTPUT
echo "PKG_RELEASE_TYPE=-alpha" >> $GITHUB_OUTPUT
else # For feature branches
((numbers[2]++)) # Increment the patch version number
version="${numbers[0]}.${numbers[1]}.${numbers[2]}"
echo "PKG_VERSION=$version" >> $GITHUB_OUTPUT
echo "PKG_RELEASE_TYPE=-beta" >> $GITHUB_OUTPUT
fi
# Build the NuGet package & Publish it on GitHub Packages
deploy_package:
needs : verify_inputs

runs-on : ubuntu-latest

# Generate a temporary token for the Github App
- name: Generate a GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.VARIABLES_GITHUB_APP_ID }}
private-key: ${{ secrets.VARIABLES_GITHUB_APP_PRIVATE_KEY }}
# Update the repository variable
- name: Update version variable
env:
VAR_NAME: 'VERSION'
VAR_VALUE: ${{ steps.create-version.outputs.PKG_VERSION }}
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh api --method PATCH -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{github.repository}}/actions/variables/${{env.VAR_NAME}} -f name='${{env.VAR_NAME}}' -f value='${{env.VAR_VALUE}}'
nuget_packaging:
needs : manage_version # Specify jobs needed to run this one
runs-on : ubuntu-latest # Specify the runner os
steps:
# Check-out the branch
- name: Check-out Branch
uses: actions/checkout@v3
# Setup the .Net environment
- name: Check-out Branch
- name: Setup .Net environmnent
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
Expand All @@ -84,39 +82,44 @@ jobs:
run: dotnet test --verbosity normal
# Pack the project in a NuGet package
- name: Create NuGet
env:
PACKAGE_ID: 'BRIDGES'
run: |
if [[ ${{github.ref}} =~ .*master$ ]]
then
dotnet pack ${{env.PROJECT_PATH}} -p:PackageId='BRIDGES' -p:PackageVersion=${{needs.verify_inputs.outputs.version_number}} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output ${{ env.PKG_OUTPUT_DIR }}
elif [[ ${{github.ref}} =~ ^.*/release/.*$ ]]
then
dotnet pack ${{env.PROJECT_PATH}} -p:PackageId='BRIDGES' -p:PackageVersion=${{needs.verify_inputs.outputs.version_number}}-beta -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output ${{ env.PKG_OUTPUT_DIR }}
elif [[ ${{github.ref}} =~ .*develop$ ]]
then
dotnet pack ${{env.PROJECT_PATH}} -p:PackageId='BRIDGES-Dev' -p:PackageVersion=${{needs.verify_inputs.outputs.version_number}}-beta -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output ${{ env.PKG_OUTPUT_DIR }}
else
echo "::error file=deploy.yml,line=94,col=9,endColumn=13::Wrong branch for deployement"
exit 1
fi
# Publish the NuGet package on GitHub
- name: Publish NuGet Package
run: |
dotnet nuget push ${{ env.PKG_OUTPUT_DIR }}/*.nupkg --api-key ${{ env.GITHUB_TOKEN }} --source ${{ env.NUGET_SRC_URL }}
dotnet nuget push ${{ env.PKG_OUTPUT_DIR }}/*.snupkg --api-key ${{ env.GITHUB_TOKEN }} --source ${{ env.NUGET_SRC_URL }}
dotnet pack ${{vars.PROJECT_PATH}} -p:PackageId=${{ env.PACKAGE_ID }} \
-p:PackageVersion=${{ needs.manage_version.outputs.PKG_VERSION }}${{ needs.manage_version.outputs.PKG_RELEASE_TYPE }} \
-p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg \
--output ${{ env.PKG_OUTPUT_DIR }}
# Upload the artefacts (Package and Symbols)
- name: Upload Github Artifacts
uses: actions/upload-artifact@v3
with:
name: package
path: ${{ env.PKG_OUTPUT_DIR }}/*

# Tag the commit with the package version
tag_commit:
needs : deploy_package

runs-on : ubuntu-latest


publish_nuget:
needs : nuget_packaging # Specify jobs needed to run this one
runs-on : ubuntu-latest # Specify the runner os
steps:
# Setup the .Net environment
- name: Setup .Net environmnent
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
# Download the artefacts (Package and Symbols)
- name: Download Github Artifacts
uses: actions/download-artifact@v3
with:
name: package
path: ${{ env.PKG_OUTPUT_DIR }}/
# Publish the NuGet package on GitHub
- name: Publish NuGet Package
run: |
dotnet nuget push ${{ env.PKG_OUTPUT_DIR }}/*.nupkg --api-key ${{ github.token }} --source ${{ vars.NUGET_SRC_URL }}
dotnet nuget push ${{ env.PKG_OUTPUT_DIR }}/*.snupkg --api-key ${{ github.token }} --source ${{ vars.NUGET_SRC_URL }}
create_tag:
needs: [manage_version, nuget_packaging] # Specify jobs needed to run this one
runs-on : ubuntu-latest # Specify the runner os
steps:
# Create a tag on the latest commit of the branch
- name: Create tag
Expand All @@ -126,16 +129,15 @@ jobs:
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{inputs.version}}',
ref: 'refs/tags/v${{ needs.manage_version.outputs.PKG_VERSION }}${{ needs.manage_version.outputs.PKG_RELEASE_TYPE }}',
sha: context.sha
})
# Create a (Pre-)Release on Github
release_package:
needs : tag_commit
if : ${{ endsWith( github.ref , 'master') || contains( github.ref , '/release/') }}

create_release:
needs : [manage_version, create_tag]
runs-on : ubuntu-latest

if : ${{ endsWith( github.ref , 'master') || contains( github.ref , '/release/') }}

steps:
# Download the artefacts (Package and Symbols)
Expand All @@ -148,21 +150,15 @@ jobs:
- name: Evaluate if Pre-Release
shell: bash
run : |
if [[ ${{github.ref}} =~ .*master$ ]]
then
if [[ ${{github.ref}} =~ .*master$ ]]; then
echo "IS_PRERELEASE=false" >> $GITHUB_ENV
elif [[ ${{github.ref}} =~ ^.*/release/.*$ ]]
then
echo "IS_PRERELEASE=true" >> $GITHUB_ENV
else
echo "The package should not be released."
exit 1
echo "IS_PRERELEASE=true" >> $GITHUB_ENV
fi
# Publish the Release
- name: Publish Release
uses: ncipollo/release-action@v1
with :
prerelease : ${{env.IS_PRERELEASE}}
prerelease : ${{ env.IS_PRERELEASE }}
artifacts: ${{ env.PKG_OUTPUT_DIR }}/*
tag : ${{inputs.version}}

tag : ${{ needs.manage_version.outputs.PKG_VERSION }}${{ needs.manage_version.outputs.PKG_RELEASE_TYPE }}
16 changes: 8 additions & 8 deletions BRIDGES/Serialisation/Deserialise.DataStructures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ public static partial class Deserialise
/// <returns> The deserialised <see cref="Meshes.HalfedgeMesh.Mesh{TPosition}"/> from the string representation. </returns>
/// <exception cref="NotImplementedException"> The specified file format for the halfedge mesh deserialisation is not implemented. </exception>
[Deserialiser(typeof(Meshes.HalfedgeMesh.Mesh<>))]
public static Meshes.HalfedgeMesh.Mesh<TPosition> HalfedgeMesh<TPosition>(string text, PolyhedralMeshSerialisationFormat format)
public static Meshes.HalfedgeMesh.Mesh<TPosition> HalfedgeMesh<TPosition>(string text, Formats.PolyhedralMeshSerialisationFormat format)
where TPosition : IEquatable<TPosition>,
Algebra.Fundamentals.IAddable<TPosition> /* To Do : Remove */,
Algebra.Sets.IGroupAction<TPosition, double>
{
switch (format)
{
case PolyhedralMeshSerialisationFormat.Json:
case Formats.PolyhedralMeshSerialisationFormat.Json:
return HalfedgeMeshFromJson<TPosition>(text);
case PolyhedralMeshSerialisationFormat.Xml:
case Formats.PolyhedralMeshSerialisationFormat.Xml:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Obj:
case Formats.PolyhedralMeshSerialisationFormat.Obj:
throw new NotImplementedException();
default:
throw new NotImplementedException("The specified file format for the halfedge mesh deserialisation is not implemented.");
Expand All @@ -47,18 +47,18 @@ public static Meshes.HalfedgeMesh.Mesh<TPosition> HalfedgeMesh<TPosition>(string
/// <param name="format"> Format of the serialisation. </param>
/// <returns> The deserialised <see cref="Meshes.FaceVertexMesh.Mesh{TPosition}"/> from the string representation. </returns>
[Deserialiser(typeof(Meshes.FaceVertexMesh.Mesh<>))]
public static Meshes.FaceVertexMesh.Mesh<TPosition> FaceVertexMesh<TPosition>(string text, PolyhedralMeshSerialisationFormat format)
public static Meshes.FaceVertexMesh.Mesh<TPosition> FaceVertexMesh<TPosition>(string text, Formats.PolyhedralMeshSerialisationFormat format)
where TPosition : IEquatable<TPosition>,
Algebra.Fundamentals.IAddable<TPosition> /* To Do : Remove */,
Algebra.Sets.IGroupAction<TPosition, double>
{
switch (format)
{
case PolyhedralMeshSerialisationFormat.Json:
case Formats.PolyhedralMeshSerialisationFormat.Json:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Xml:
case Formats.PolyhedralMeshSerialisationFormat.Xml:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Obj:
case Formats.PolyhedralMeshSerialisationFormat.Obj:
throw new NotImplementedException();
default:
throw new NotImplementedException("The specified file format for the face|vertex mesh deserialisation is not implemented.");
Expand Down
8 changes: 3 additions & 5 deletions BRIDGES/Serialisation/Formats/PolyhedralMeshFormat.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using BRIDGES.Serialisation.Formats;
using System;
using System.Collections.Generic;
using System.Text;
using System;

namespace BRIDGES.Serialisation

namespace BRIDGES.Serialisation.Formats
{
/// <summary>
/// Specifies the file formats available for the meshes.
Expand Down
24 changes: 12 additions & 12 deletions BRIDGES/Serialisation/Serialise.DataStructures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ public static partial class Serialise
/// <param name="format"> Format of the serialisation. </param>
/// <returns> A string representation of the <see cref="Meshes.HalfedgeMesh.Mesh{TPosition}"/>. </returns>
[Serialiser(typeof(Meshes.HalfedgeMesh.Mesh<>))]
public static string HalfedgeMesh<TPosition>(Meshes.HalfedgeMesh.Mesh<TPosition> mesh, PolyhedralMeshSerialisationFormat format)
public static string HalfedgeMesh<TPosition>(Meshes.HalfedgeMesh.Mesh<TPosition> mesh, Formats.PolyhedralMeshSerialisationFormat format)
where TPosition : IEquatable<TPosition>,
Algebra.Fundamentals.IAddable<TPosition> /* To Do : Remove */,
Algebra.Sets.IGroupAction<TPosition, double>
{
switch (format)
{
case PolyhedralMeshSerialisationFormat.Json:
case Formats.PolyhedralMeshSerialisationFormat.Json:
return HalfedgeMeshToJson(mesh);
case PolyhedralMeshSerialisationFormat.Xml:
case Formats.PolyhedralMeshSerialisationFormat.Xml:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Obj:
case Formats.PolyhedralMeshSerialisationFormat.Obj:
return PolyhedralMeshToObj(mesh);
default:
throw new NotImplementedException("The specified file format for the halfedge mesh serialisation is not implemented.");
Expand All @@ -47,18 +47,18 @@ public static string HalfedgeMesh<TPosition>(Meshes.HalfedgeMesh.Mesh<TPosition>
/// <param name="format"> Format of the serialisation. </param>
/// <returns> A string representation of the <see cref="Meshes.FaceVertexMesh.Mesh{TPosition}"/>. </returns>
[Serialiser(typeof(Meshes.FaceVertexMesh.Mesh<>))]
public static string FaceVertexMesh<TPosition>(Meshes.FaceVertexMesh.Mesh<TPosition> mesh, PolyhedralMeshSerialisationFormat format)
public static string FaceVertexMesh<TPosition>(Meshes.FaceVertexMesh.Mesh<TPosition> mesh, Formats.PolyhedralMeshSerialisationFormat format)
where TPosition : IEquatable<TPosition>,
Algebra.Fundamentals.IAddable<TPosition> /* To Do : Remove */,
Algebra.Sets.IGroupAction<TPosition, double>
{
switch (format)
{
case PolyhedralMeshSerialisationFormat.Json:
case Formats.PolyhedralMeshSerialisationFormat.Json:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Xml:
case Formats.PolyhedralMeshSerialisationFormat.Xml:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Obj:
case Formats.PolyhedralMeshSerialisationFormat.Obj:
return PolyhedralMeshToObj(mesh);
default:
throw new NotImplementedException("The specified file format for the face|vertex mesh serialisation is not implemented.");
Expand All @@ -73,18 +73,18 @@ public static string FaceVertexMesh<TPosition>(Meshes.FaceVertexMesh.Mesh<TPosit
/// <param name="mesh"> <see cref="Meshes.IMesh{TPosition}"/> to serialise. </param>
/// <param name="format"> Format of the serialisation. </param>
/// <returns> A string representation of the <see cref="Meshes.IMesh{TPosition}"/>. </returns>
public static string PolyhedralMesh<TPosition>(Meshes.IMesh<TPosition> mesh, PolyhedralMeshSerialisationFormat format)
public static string PolyhedralMesh<TPosition>(Meshes.IMesh<TPosition> mesh, Formats.PolyhedralMeshSerialisationFormat format)
where TPosition : IEquatable<TPosition>,
Algebra.Fundamentals.IAddable<TPosition> /* To Do : Remove */,
Algebra.Sets.IGroupAction<TPosition, double>
{
switch (format)
{
case PolyhedralMeshSerialisationFormat.Json:
case Formats.PolyhedralMeshSerialisationFormat.Json:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Xml:
case Formats.PolyhedralMeshSerialisationFormat.Xml:
throw new NotImplementedException();
case PolyhedralMeshSerialisationFormat.Obj:
case Formats.PolyhedralMeshSerialisationFormat.Obj:
return PolyhedralMeshToObj(mesh);
default:
throw new NotImplementedException("The specified file format for the polyhedral mesh serialisation is not implemented.");
Expand Down
Loading

0 comments on commit 6ff944a

Please sign in to comment.