Skip to content

Commit

Permalink
Update build automation and continuous integration workflows (#397)
Browse files Browse the repository at this point in the history
* Release workflow is now only run on an explicit call to that workflow.
* A separate workflow for testing is run on every push.
* Updated the developer documentation.
  • Loading branch information
timyhac authored Jul 11, 2024
1 parent a18a681 commit 93659a9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 14 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build and publish libplctag.NET nuget package

on: [push,workflow_dispatch]
on: [workflow_dispatch]

jobs:
build:
Expand All @@ -12,8 +12,5 @@ jobs:
with:
lfs: true

- name: Publish libplctag on version change
run: .\build.cmd ReleaseLibplctag --nuget-api-key ${{secrets.NUGET_API_KEY}}

- name: Publish libplctag.NativeImport on version change
run: .\build.cmd ReleaseLibplctagNativeImport --nuget-api-key ${{secrets.NUGET_API_KEY}}
- name: Publish all packages on version change
run: .\build.cmd ReleaseAll --nuget-api-key ${{secrets.NUGET_API_KEY}}
16 changes: 16 additions & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Continuous Integration - Build all and run tests

on: [push]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Build all and run tests
run: .\build.cmd Test
File renamed without changes.
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"Compile",
"PackLibplctag",
"PackLibplctagNativeImport",
"ReleaseAll",
"ReleaseLibplctag",
"ReleaseLibplctagNativeImport",
"Restore",
Expand All @@ -107,6 +108,7 @@
"Compile",
"PackLibplctag",
"PackLibplctagNativeImport",
"ReleaseAll",
"ReleaseLibplctag",
"ReleaseLibplctagNativeImport",
"Restore",
Expand Down
15 changes: 15 additions & 0 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ class Build : NukeBuild
PushAndTag($"libplctag.NativeImport.{version}.nupkg", $"libplctag.NativeImport-v{version}");
});

Target ReleaseAll => _ => _
.DependsOn(PackLibplctag)
.DependsOn(PackLibplctagNativeImport)
.Requires(() => NugetApiUrl)
.Requires(() => NugetApiKey)
.Requires(() => Configuration.Equals(Configuration.Release))
.Executes(() =>
{
var libplctagNativeImportVersion = libplctag_NativeImport.GetProperty("Version");
PushAndTag($"libplctag.NativeImport.{libplctagNativeImportVersion}.nupkg", $"libplctag.NativeImport-v{libplctagNativeImportVersion}");

var libplctagVersion = libplctag.GetProperty("Version");
PushAndTag($"libplctag.{libplctagVersion}.nupkg", $"libplctag-v{libplctagVersion}");
});

Target UpdateCoreBinaries => _ => _
.Requires(() => LibplctagCoreVersion)
.Executes(() =>
Expand Down
23 changes: 15 additions & 8 deletions dev/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developer Documentation

This folder is for storing information regarding the development of libplctag.NET - the .NET wrapper for libplctag.
This folder is for storing information regarding the development of libplctag.NET.

## Glossary

Expand All @@ -15,17 +15,24 @@ This folder is for storing information regarding the development of libplctag.NE



## Build Automation

## How to update libplctag.NativeImport
GitHub Actions have been created to automate some common activities such as updating the core binaries and release nuget packages.

These workflows delegate the actual automation logic to the [`_build`](../build) [NUKE](https://nuke.build/) project.

### How to release Nuget packages

1. Update the version number in the csproj files of the libplctag or libplctag.NativeImport projects.
2. Trigger the "Build and publish libplctag.NET nuget package" workflow.
4. Create a GitHub "Release" with details of the new release.

## How to update the core binaries libplctag.NativeImport

When a new version of libplctag core is released, the library binaries need to be updated in libplctag.NativeImport.
The build script can be used to copy these libraries in the project without error.

1. Run the script with the selected version:
`> .\build.cmd UpdateCoreBinaries --libplctag-core-version 2.6.0`
1. Trigger the "Update libplctag core" workflow.
2. Verify that the files have been correctly copied.
3. Make relevant modifications to libplctag.NativeImport such as modifying the method signatures (if required).
4. Increment version number of libplctag.NativeImport project.
5. Run the build script with `ReleaseLibplctagNativeImport` to upload to nuget.
`> .\build.cmd ReleaseLibplctagNatveImport`
Note there is a github action which automatically executes this.
4. Finally, release the updated project as a new Nuget packages.

0 comments on commit 93659a9

Please sign in to comment.