Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions .github/workflows/build-docker-task.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Build docker image task

env:
IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }}
DOCKER_REGISTRY: docker.io
DOCKER_IMAGE: ptr727/projecttemplate
DOCKER_TAG_PREFIX: docker.io/ptr727/projecttemplate
DOCKER_FILE: ./Docker/Ubuntu.Rolling.Dockerfile

on:
workflow_call:
Expand All @@ -20,18 +22,10 @@ jobs:
uses: ./.github/workflows/get-version-task.yml
secrets: inherit

build-matrix:
name: Build docker matrix
build-docker:
name: Build docker project
runs-on: ubuntu-latest
needs: [get-version]
strategy:
matrix:
include:
- file: ./Docker/Ubuntu.Rolling.Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:${{ endsWith(github.ref, 'refs/heads/main') && 'latest' || 'develop' }}
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:${{ needs.get-version.outputs.SemVer2 }}

steps:

Expand Down Expand Up @@ -60,16 +54,19 @@ jobs:
with:
context: .
push: ${{ inputs.push }}
file: ${{ matrix.file }}
tags: ${{ matrix.tags }}
platforms: ${{ matrix.platforms }}
cache-from: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:buildcache,mode=max
file: ${{ env.DOCKER_FILE }}
tags: |
${{ env.DOCKER_TAG_PREFIX }}:${{ env.IS_MAIN_BRANCH == 'true' && 'latest' || 'develop' }}
${{ env.DOCKER_TAG_PREFIX }}:${{ needs.get-version.outputs.SemVer2 }}
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=${{ env.DOCKER_TAG_PREFIX }}:buildcache
cache-to: type=registry,ref=${{ env.DOCKER_TAG_PREFIX }}:buildcache,mode=max
build-args: |
LABEL_VERSION=${{ needs.get-version.outputs.SemVer2 }}
BUILD_CONFIGURATION=${{ endsWith(github.ref, 'refs/heads/main') && 'Release' || 'Debug' }}
BUILD_CONFIGURATION=${{ env.IS_MAIN_BRANCH == 'true' && 'Release' || 'Debug' }}
BUILD_VERSION=${{ needs.get-version.outputs.AssemblyVersion }}
BUILD_FILE_VERSION=${{ needs.get-version.outputs.AssemblyFileVersion }}
BUILD_ASSEMBLY_VERSION=${{ needs.get-version.outputs.AssemblyFileVersion }}
BUILD_INFORMATION_VERSION=${{ needs.get-version.outputs.AssemblyInformationalVersion }}
BUILD_PACKAGE_VERSION=${{ needs.get-version.outputs.SemVer2 }}

83 changes: 83 additions & 0 deletions .github/workflows/build-executable-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build executable task

env:
IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }}
PROJECT_FILE: ./Console/Console.csproj
PROJECT_ARTIFACT: Console.7z

on:
workflow_call:
outputs:
artifact-id:
value: ${{ jobs.upload-build-artifacts.outputs.artifact-id }}
workflow_dispatch:

jobs:

get-version:
name: Get version information
uses: ./.github/workflows/get-version-task.yml
secrets: inherit

build-executable-matrix:
name: Build executable project matrix
runs-on: ubuntu-latest
needs: [get-version]
strategy:
matrix:
runtime: [ win-x64, linux-x64, linux-musl-x64, linux-arm, linux-arm64, osx-x64, osx-arm64 ]

steps:

- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x

- name: Checkout code
uses: actions/checkout@v6

- name: Build executable project
run: >-
dotnet publish ${{ env.PROJECT_FILE }}
--runtime ${{ matrix.runtime }}
--output ${{ runner.temp }}/publish/${{ matrix.runtime }}
--configuration ${{ env.IS_MAIN_BRANCH == 'true' && 'Release' || 'Debug' }}
-property:PublishAot=false
-property:Version=${{ needs.get-version.outputs.AssemblyVersion }}
-property:FileVersion=${{ needs.get-version.outputs.AssemblyFileVersion }}
-property:AssemblyVersion=${{ needs.get-version.outputs.AssemblyVersion }}
-property:InformationalVersion=${{ needs.get-version.outputs.AssemblyInformationalVersion }}
-property:PackageVersion=${{ needs.get-version.outputs.SemVer2 }}

- name: Upload matrix build artifacts
uses: actions/upload-artifact@v6
with:
name: publish-${{ matrix.runtime }}
path: ${{ runner.temp }}/publish

upload-build-artifacts:
name: Upload matrix build artifacts
outputs:
artifact-id: ${{ steps.artifact-upload-step.outputs.artifact-id }}
runs-on: ubuntu-latest
needs: [ build-executable-matrix ]

steps:

- name: Download matrix build artifacts
uses: actions/download-artifact@v7
with:
pattern: publish-*
merge-multiple: true
path: ${{ runner.temp }}/publish

- name: Zip build output
run: 7z a -t7z ${{ runner.temp }}/${{ env.PROJECT_ARTIFACT }} ${{ runner.temp }}/publish/*

- name: Upload build artifacts
id: artifact-upload-step
uses: actions/upload-artifact@v6
with:
name: executable-build
path: ${{ runner.temp }}/${{ env.PROJECT_ARTIFACT }}
Comment thread
ptr727 marked this conversation as resolved.
72 changes: 72 additions & 0 deletions .github/workflows/build-library-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build library task

env:
IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }}
PROJECT_FILE: ./Library/Library.csproj
PROJECT_ARTIFACT: Library.7z

on:
workflow_call:
inputs:
nuget:
required: false
type: boolean
default: false
outputs:
artifact-id:
value: ${{ jobs.build-library.outputs.artifact-id }}
workflow_dispatch:

jobs:

get-version:
name: Get version information
uses: ./.github/workflows/get-version-task.yml
secrets: inherit

build-library:
name: Build library project
runs-on: ubuntu-latest
outputs:
artifact-id: ${{ steps.artifact-upload-step.outputs.artifact-id }}
needs: [get-version]

steps:

- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x

- name: Checkout code
uses: actions/checkout@v6

- name: Build library project
run: >-
dotnet build ${{ env.PROJECT_FILE }}
--output ${{ runner.temp }}/publish
--configuration ${{ env.IS_MAIN_BRANCH == 'true' && 'Release' || 'Debug' }}
Comment thread
ptr727 marked this conversation as resolved.
-property:Version=${{ needs.get-version.outputs.AssemblyVersion }}
-property:FileVersion=${{ needs.get-version.outputs.AssemblyFileVersion }}
-property:AssemblyVersion=${{ needs.get-version.outputs.AssemblyVersion }}
-property:InformationalVersion=${{ needs.get-version.outputs.AssemblyInformationalVersion }}
-property:PackageVersion=${{ needs.get-version.outputs.SemVer2 }}

- name: Publish to NuGet.org
if: ${{ inputs.nuget }}
run: >-
dotnet nuget push ${{ runner.temp }}/publish/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_API_KEY }}
--skip-duplicate

- name: Zip output
run: |
7z a -t7z ${{ runner.temp }}/${{ env.PROJECT_ARTIFACT }} ${{ runner.temp }}/publish/*

- name: Upload build artifacts
id: artifact-upload-step
uses: actions/upload-artifact@v6
with:
name: library-build
path: ${{ runner.temp }}/${{ env.PROJECT_ARTIFACT }}
66 changes: 30 additions & 36 deletions .github/workflows/build-project-task.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Build project task

env:
IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }}

on:
workflow_call:
inputs:
Expand All @@ -20,54 +23,45 @@ jobs:
uses: ./.github/workflows/get-version-task.yml
secrets: inherit

build-project:
name: Build project
build-library:
name: Build library project
uses: ./.github/workflows/build-library-task.yml
secrets: inherit
with:
nuget: ${{ inputs.nuget }}

build-executable:
name: Build executable project
uses: ./.github/workflows/build-executable-task.yml
secrets: inherit

github-release:
name: Publish GitHub release
if: ${{ inputs.github }}
runs-on: ubuntu-latest
needs: get-version
permissions:
contents: write
needs: [get-version, build-library, build-executable]

steps:

- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
- name: Download library build artifacts
uses: actions/download-artifact@v7
with:
dotnet-version: 10.x
artifact-ids: ${{ needs.build-library.outputs.artifact-id }}
Comment thread
ptr727 marked this conversation as resolved.
path: ./Publish

- name: Checkout code
uses: actions/checkout@v6

- name: Build project
run: >-
dotnet build ./Library/Library.csproj
--output ./Publish/
--configuration ${{ endsWith(github.ref, 'refs/heads/main') && 'Release' || 'Debug' }}
-property:Version=${{ needs.get-version.outputs.AssemblyVersion }}
-property:FileVersion=${{ needs.get-version.outputs.AssemblyFileVersion }}
-property:AssemblyVersion=${{ needs.get-version.outputs.AssemblyVersion }}
-property:InformationalVersion=${{ needs.get-version.outputs.AssemblyInformationalVersion }}
-property:PackageVersion=${{ needs.get-version.outputs.SemVer2 }}

- name: Publish to NuGet.org
if: ${{ inputs.nuget }}
run: >-
dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_API_KEY }}
--skip-duplicate

- name: Zip output
run: |
7z a -t7z ./Publish/Library.7z ./Publish/*
- name: Download executable build artifacts
uses: actions/download-artifact@v7
with:
artifact-ids: ${{ needs.build-executable.outputs.artifact-id }}
Comment thread
ptr727 marked this conversation as resolved.
path: ./Publish

- name: Create GitHub release
uses: softprops/action-gh-release@v2
if: ${{ inputs.github }}
with:
generate_release_notes: true
tag_name: ${{ needs.get-version.outputs.SemVer2 }}
prerelease: ${{ !endsWith(github.ref, 'refs/heads/main') }}
prerelease: ${{ env.IS_MAIN_BRANCH != 'true' }}
files: |
LICENSE
README.md
./Publish/Library.7z
./Publish/*
9 changes: 4 additions & 5 deletions .github/workflows/date-badge-task.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
name: Create date badge task

env:
IS_MAIN_BRANCH: ${{ endsWith(github.ref, 'refs/heads/main') }}

on:
workflow_call:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

date-badge:
name: Create date badge
runs-on: ubuntu-latest
if: ${{ endsWith(github.ref, 'refs/heads/main') }}

steps:

Expand All @@ -22,6 +20,7 @@ jobs:
echo "date=$(date)" >> $GITHUB_OUTPUT

- name: Build date badge
if: ${{ env.IS_MAIN_BRANCH }}
Comment thread
ptr727 marked this conversation as resolved.
uses: RubbaBoy/BYOB@v1
with:
name: lastbuild
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and publish release
name: Build and publish project release

on:
push:
Expand All @@ -13,11 +13,19 @@ jobs:

build-project:
name: Build project
permissions:
contents: write
uses: ./.github/workflows/build-project-task.yml
secrets: inherit
with:
# Push to GitHub and NuGet
github: true
nuget: true

date-badge:
needs: build-project
name: Create date badge
permissions:
contents: write
needs: [build-project]
uses: ./.github/workflows/date-badge-task.yml
secrets: inherit
6 changes: 5 additions & 1 deletion .github/workflows/publish-docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ main, develop ]
workflow_dispatch:
schedule:
# Rebuild docker images weekly on Mondays at 02:00 UTC
- cron: '0 2 * * MON'

concurrency:
Expand All @@ -18,10 +19,13 @@ jobs:
uses: ./.github/workflows/build-docker-task.yml
secrets: inherit
with:
# Push to registry
push: true

date-badge:
needs: build-docker
name: Create date badge
permissions:
contents: write
needs: [build-docker]
uses: ./.github/workflows/date-badge-task.yml
secrets: inherit
Loading