Skip to content

Commit

Permalink
Updated to .NET 6 and improved Actions Workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ashneilson committed Nov 27, 2021
1 parent 01247cc commit ed4c19d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 94 deletions.
44 changes: 16 additions & 28 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
# Action Name
name: "CodeQL"

# Environment Variables
env:
PROJECT_NAME: "RICADO.Unitronics"

# When the Action will Run
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '42 19 * * 0'
- cron: '0 7 * * 5'

# Workflow Jobs
jobs:
# Analyze Job
analyze:
if: github.actor != 'dependabot[bot]'
name: Analyze
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]

steps:
# Step 1 - Checkout Code
- name: Checkout Code
Expand All @@ -36,25 +27,22 @@ jobs:
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

# Step 3 - Setup .NET 5 with GitHub Packages Authentication
- name: Setup .NET 5 with GitHub Packages Authentication
languages: csharp
queries: security-and-quality

# Step 3 - Setup .NET 6 with GitHub Packages Authentication
- name: Setup .NET 6 with GitHub Packages Authentication
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.100'
dotnet-version: 6.0.x
source-url: https://nuget.pkg.github.com/ricado-group/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GH_ACTIONS_PAT }}

# Step 4 - Restore NuGet Packages
- name: Restore NuGet Packages
run: dotnet restore "${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj"

# Step 5 - Build the Library
- name: Build the Library
run: dotnet build "${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj" -c Release
# Step 4 - Build the Library
- name: Run CodeQL Autobuild
uses: github/codeql-action/autobuild@v1

# Step 6 - Perform CodeQL Analysis
# Step 5 - Perform CodeQL Analysis
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
71 changes: 10 additions & 61 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Action Name
name: Main Automated Builds

# Environment Variables
env:
PROJECT_NAME: "RICADO.Unitronics"

# Controls when the action will run.
# When the Action will Run
on:
push:
branches:
Expand All @@ -15,67 +11,20 @@ on:

# Workflow Jobs
jobs:
# Build Job
build:
runs-on: ubuntu-latest
steps:
# Step 1 - Checkout Code
- name: Checkout Code
uses: actions/checkout@v2

# Step 2 - Extract Environment Variables
- name: Extract Environment Variables
uses: FranzDiebold/github-env-vars-action@v2.3.0

# Step 3 - Setup .NET 5 with GitHub Packages Authentication
- name: Setup .NET 5 with GitHub Packages Authentication
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.100'
source-url: https://nuget.pkg.github.com/ricado-group/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GH_ACTIONS_PAT }}

# Step 4 - Restore NuGet Packages
- name: Restore NuGet Packages
run: dotnet restore "${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj"

# Step 5 - Build the Library
- name: Build the Library
run: dotnet build "${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj" -c Release

# Step 6 - Pack the Library
- name: Pack the Library
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: dotnet pack "${{ env.PROJECT_NAME}}/${{ env.PROJECT_NAME }}.csproj" -c Release -p:PackageVersion=${{ env.CI_REF_NAME }}

# Step 7 - Push the Package to GitHub Packages
- name: Push the Package to GitHub Packages
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: dotnet nuget push "${{ env.PROJECT_NAME }}/bin/Release/*.nupkg" -k ${{ secrets.GH_ACTIONS_PAT }} -s "https://nuget.pkg.github.com/ricado-group/index.json" --skip-duplicate

# Step 8 - Push the Package to NuGet
- name: Push the Package to Nuget
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: dotnet nuget push "${{ env.PROJECT_NAME }}/bin/Release/*.nupkg" -k ${{ secrets.NUGET_APIKEY }} -s "https://api.nuget.org/v3/index.json" --skip-duplicate

# Step 9 - Generate the Changelog
- name: Generate the Changelog
id: changelog
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: metcalfc/changelog-generator@v3.0.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

# Step 10 - Create New Release
- name: Create New Release
id: create-release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 2 - Build and Publish
- name: Build and Publish
uses: ricado-group/dotnet-library-build-release-action@v1.2
with:
tag_name: ${{ env.CI_REF_NAME }}
release_name: Version ${{ env.CI_REF_NAME }}
body: |
${{ steps.changelog.outputs.changelog }}
project-name: 'RICADO.Unitronics'
github-token: ${{ secrets.GITHUB_TOKEN }}
private-nuget-url: 'https://nuget.pkg.github.com/ricado-group/index.json'
private-nuget-token: ${{ secrets.GH_ACTIONS_PAT }}
public-nuget-token: ${{ secrets.NUGET_APIKEY }}
publish-public: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# RICADO.Unitronics
A Unitronics PLC Communication Library for .NET 5 Applications
A Unitronics PLC Communication Library for .NET 6 Applications
2 changes: 1 addition & 1 deletion RICADO.Unitronics/PComB/WriteOperandRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected override ICollection<byte> BuildMessageData()
case OperandType.XB:
if (tryGetValue(out bool boolValue))
{
messageData.Add(boolValue == true ? 1 : 0);
messageData.Add(boolValue == true ? (byte)1 : (byte)0);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions RICADO.Unitronics/RICADO.Unitronics.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Authors>RICADO Group</Authors>
<Company>RICADO Group LP</Company>
<Description>A Unitronics PLC Communication Library for .NET 5 Applications</Description>
<Description>A Unitronics PLC Communication Library for .NET 6 Applications</Description>
<Copyright>Copyright © RICADO Group LP 2009 - 2021</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>packageIcon.png</PackageIcon>
Expand Down
2 changes: 1 addition & 1 deletion RICADO.Unitronics/UnitronicsPLC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class UnitronicsPLC : IDisposable

internal Guid InternalUniqueID => _internalUniqueId;

internal ushort BufferSize => IsEnhanced ? 1000 : 496;
internal ushort BufferSize => IsEnhanced ? (ushort)1000 : (ushort)496;

internal bool IsBasic => _model switch
{
Expand Down

0 comments on commit ed4c19d

Please sign in to comment.