Skip to content

Commit 785b48f

Browse files
committed
Refactor workflows and enhance NuGet packaging
Updated GitHub Actions workflows to use reusable workflows for building and publishing `libpng` libraries, consolidating and simplifying the build process. Added a new `push-nuget.yml` workflow to automate NuGet package publishing. Enhanced the `Hexa.NET.Libpng.csproj` file by incrementing the package version, adding a `PackageIcon` property, and updating dependencies. Included the `icon.png` file in the NuGet package to improve branding and metadata completeness.
1 parent 18afc63 commit 785b48f

File tree

6 files changed

+87
-227
lines changed

6 files changed

+87
-227
lines changed

.github/workflows/build-libpng.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/cmake-android.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

.github/workflows/cmake.yml

Lines changed: 32 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,37 @@
1-
name: Build libpng Libraries
1+
name: Build and Update libpng Libraries
22

33
on: [workflow_dispatch]
44

55
jobs:
66
build:
7-
runs-on: ${{ matrix.os }}
8-
strategy:
9-
matrix:
10-
include:
11-
- os: ubuntu-latest
12-
arch: x86_64
13-
cmake-arch: x64
14-
vcpkg-triplet: x64-linux
15-
- os: linux
16-
arch: arm64
17-
cmake-arch: aarch64
18-
runner-label: self-hosted
19-
vcpkg-triplet: arm64-linux
20-
- os: windows-latest
21-
arch: x86_64
22-
cmake-arch: x64
23-
vcpkg-triplet: x64-windows-static
24-
- os: windows-latest
25-
arch: x86
26-
cmake-arch: win32
27-
vcpkg-triplet: x86-windows-static
28-
- os: windows-latest
29-
arch: arm64
30-
cmake-arch: arm64
31-
vcpkg-triplet: arm64-windows-static
32-
- os: macos-latest
33-
arch: x86_64
34-
cmake-arch: x86_64
35-
vcpkg-triplet: x64-osx
36-
- os: macos-latest
37-
arch: arm64
38-
cmake-arch: arm64
39-
vcpkg-triplet: arm64-osx
40-
41-
steps:
42-
- uses: actions/[email protected]
43-
with:
44-
repository: "pnggroup/libpng"
45-
path: "libpng"
46-
ref: "v1.6.47"
47-
submodules: true
48-
49-
- name: Install Dependencies on Ubuntu
50-
if: matrix.os == 'linux' || matrix.os == 'ubuntu-latest'
51-
run: |
52-
sudo apt-get update
53-
sudo apt-get install -y build-essential cmake curl zip unzip tar ninja-build
54-
55-
- name: Install vcpkg on Linux and macOS
56-
if: runner.os != 'Windows'
57-
run: |
58-
cd libpng
59-
git clone https://github.com/microsoft/vcpkg.git
60-
./vcpkg/bootstrap-vcpkg.sh
61-
./vcpkg/vcpkg install zlib --triplet ${{ matrix.vcpkg-triplet }}
62-
63-
- name: Install vcpkg on Windows
64-
if: runner.os == 'Windows'
65-
run: |
66-
cd libpng
67-
git clone https://github.com/microsoft/vcpkg.git
68-
./vcpkg/bootstrap-vcpkg.bat
69-
./vcpkg/vcpkg.exe install zlib --triplet ${{ matrix.vcpkg-triplet }}
70-
71-
- name: Configure libpng with CMake on Linux
72-
if: matrix.os == 'linux' || matrix.os == 'ubuntu-latest'
73-
run: |
74-
cd libpng
75-
cmake -S ./ -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.cmake-arch }} -DPNG_SHARED=ON -DPNG_STATIC=OFF -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg-triplet }} -DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake"
76-
77-
- name: Configure libpng with CMake on Windows
78-
if: matrix.os == 'windows-latest' && matrix.arch != 'arm64'
79-
run: |
80-
cd libpng
81-
cmake -S ./ -B ./build -DCMAKE_BUILD_TYPE=Release -A ${{ matrix.cmake-arch }} -DPNG_SHARED=ON -DPNG_STATIC=OFF -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg-triplet }} -DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake"
82-
83-
- name: Configure libpng with CMake on Windows (ARM64)
84-
if: matrix.os == 'windows-latest' && matrix.arch == 'arm64'
85-
run: |
86-
cd libpng
87-
cmake -S ./ -B ./build -DCMAKE_BUILD_TYPE=Release -A ${{ matrix.cmake-arch }} -DPNG_SHARED=ON -DPNG_STATIC=OFF -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg-triplet }} -DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake"
88-
89-
- name: Configure libpng with CMake on macOS
90-
if: matrix.os == 'macos-latest'
91-
run: |
92-
cd libpng
93-
cmake -S ./ -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake-arch }} -DPNG_SHARED=ON -DPNG_STATIC=OFF -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg-triplet }} -DCMAKE_TOOLCHAIN_FILE="./vcpkg/scripts/buildsystems/vcpkg.cmake"
94-
95-
- name: Build libpng
96-
run: cmake --build libpng/build --config Release
97-
98-
- name: Move Windows binaries
99-
if: matrix.os == 'windows-latest'
100-
run: |
101-
mv libpng/build/Release/*.dll libpng/build/
102-
103-
- name: Upload Artifacts
104-
uses: actions/[email protected]
105-
with:
106-
name: libpng-${{ matrix.os }}-${{ matrix.arch }}-artifacts
107-
path: |
108-
libpng/build/*.dll
109-
libpng/build/*.so
110-
libpng/build/*.dylib
111-
if-no-files-found: ignore # 'warn' or 'ignore' or 'error'
7+
uses: JunaMeinhold/cmake-actions/.github/workflows/[email protected]
8+
with:
9+
lib-name: "libpng"
10+
repo: "pnggroup/libpng"
11+
repo-tag: "v1.6.47"
12+
repo-path: libpng
13+
cmake-flags: "-DCMAKE_BUILD_TYPE=Release -DPNG_SHARED=ON -DPNG_STATIC=OFF"
14+
cmake-flags-windows: "-DCMAKE_SYSTEM_VERSION=10.0.26100.0"
15+
ndk-version: "28.1.13356709"
16+
android-api: "21"
17+
build-output-dir: artifacts
18+
bin-name-osx: "libpng16.dylib"
19+
bin-name-linux: "libpng16.so"
20+
bin-name-android: "libpng.so"
21+
bin-name-windows: "Release/libpng16.dll"
22+
bin-name-osx-normalized: "libpng.dylib"
23+
bin-name-linux-normalized: "libpng.so"
24+
bin-name-android-normalized: "libpng.so"
25+
bin-name-windows-normalized: "libpng16.dll"
26+
use-vcpkg: true
27+
vcpkg-packages: "zlib"
28+
29+
create-pr:
30+
uses: JunaMeinhold/cmake-actions/.github/workflows/[email protected]
31+
needs: [build]
32+
with:
33+
lib-name: "libpng"
34+
lib-version: "v1.6.47"
35+
pr-branch: libpng-artifacts-branch
36+
pr-base-branch: master
37+
pr-reviewers: JunaMeinhold

.github/workflows/push-nuget.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish NuGet Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- 1.**
7+
workflow_dispatch:
8+
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '9.0.x'
22+
23+
- name: Restore dependencies
24+
run: |
25+
dotnet restore Hexa.NET.Libpng/Hexa.NET.Libpng.csproj
26+
27+
- name: Build the project
28+
run: |
29+
dotnet build Hexa.NET.Libpng/Hexa.NET.Libpng.csproj --configuration Release
30+
31+
- name: Pack the project
32+
run: |
33+
dotnet pack Hexa.NET.Libpng/Hexa.NET.Libpng.csproj --configuration Release --output ./nupkgs
34+
35+
- name: Exclude unwanted packages
36+
run: |
37+
# Exclude packages that don't start with "Hexa.NET."
38+
for package in ./nupkgs/*.nupkg; do
39+
package_name=$(basename "$package")
40+
if [[ ! $package_name == Hexa.NET* ]]; then
41+
echo "Removing $package_name as it does not start with Hexa.NET."
42+
rm -f "$package"
43+
fi
44+
done
45+
46+
- name: List packages
47+
run: ls ./nupkgs/
48+
49+
- name: Publish the package
50+
run: dotnet nuget push ./nupkgs/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate

Hexa.NET.Libpng/Hexa.NET.Libpng.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<IsAotCompatible>true</IsAotCompatible>
1515

1616
<AssemblyVersion>1.6.47</AssemblyVersion>
17-
<PackageVersion>1.0.3</PackageVersion>
17+
<PackageVersion>1.0.4</PackageVersion>
1818
<Description>A .NET wrapper for the libpng library. (v1.6.47)</Description>
1919
<PackageTags>libpng png Hexa HexaGen Source Generator C# .NET DotNet Sharp Windows macOS Android Bindings Wrapper Native</PackageTags>
2020
<Authors>Juna Meinhold</Authors>
@@ -24,6 +24,7 @@
2424
<RepositoryType>git</RepositoryType>
2525
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2626
<PackageReadmeFile>README.md</PackageReadmeFile>
27+
<PackageIcon>icon.png</PackageIcon>
2728

2829
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2930
<NoWarn>$(NoWarn);1591</NoWarn>
@@ -32,8 +33,8 @@
3233
</PropertyGroup>
3334

3435
<ItemGroup>
35-
<PackageReference Include="HexaGen.Runtime" Version="1.1.18" />
36-
<PackageReference Include="Hexa.NET.ZLib" Version="1.0.0" />
36+
<PackageReference Include="HexaGen.Runtime" Version="1.1.22" />
37+
<PackageReference Include="Hexa.NET.ZLib" Version="1.0.1" />
3738
</ItemGroup>
3839

3940
<ItemGroup>
@@ -96,6 +97,7 @@
9697
<ItemGroup>
9798
<Content Include="../LICENSE.txt" Pack="true" PackagePath="\" />
9899
<Content Include="../README.md" Pack="true" PackagePath="\" />
100+
<Content Include="../icon.png" Pack="true" PackagePath="\" />
99101
</ItemGroup>
100102

101103
</Project>

icon.png

201 KB
Loading

0 commit comments

Comments
 (0)