Skip to content

Commit

Permalink
Merge pull request #345 from zapadi/dev/rework-foundation
Browse files Browse the repository at this point in the history
Dev/rework foundation
  • Loading branch information
zapadi committed Feb 12, 2024
2 parents 2b7eb14 + c232428 commit 1afd7e6
Show file tree
Hide file tree
Showing 15 changed files with 331 additions and 143 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build-and-test.yml
@@ -0,0 +1,35 @@
name: 'Build and Test'

on:
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: false
default: 'Manual build and run tests'
workflow_run:
workflows: [ Build ]
types:
- completed

jobs:
build:
uses: ./.github/workflows/build.yml
test:
name: Test - ${{matrix.os}}
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
steps:
- name: Test
if: ${{ github.event.workflow_run.conclusion == 'success' }}
timeout-minutes: 60
run: >-
dotnet test "${{ env.PROJECT_PATH }}"
--no-restore
--no-build
--verbosity normal
--logger "trx;LogFileName=test-results.trx" || true
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,86 @@
name: 'Build'

on:
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: false
default: 'Manual run'
# workflow_call:
push:
# paths:
# - '**.cs'
# - '**.csproj'
pull_request:
branches: [ master ]
paths:
- '**.cs'
- '**.csproj'

env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true

# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true

DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false

DOTNET_MULTILEVEL_LOOKUP: 0

PROJECT_PATH: .

CONFIGURATION: Release

# Set the build number in MinVer.
MINVERBUILDMETADATA: build.${{github.run_number}}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build ${{ matrix.os }} - dotnet ${{ matrix.dotnet }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]

steps:
- name: Print manual run reason
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0

- name: Setup .NET (global.json)
uses: actions/setup-dotnet@v4

- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Restore
run: dotnet restore "${{ env.PROJECT_PATH }}"

- name: Build
run: >-
dotnet build "${{ env.PROJECT_PATH }}"
--configuration "${{ env.CONFIGURATION }}"
--no-restore
-p:ContinuousIntegrationBuild=true
117 changes: 0 additions & 117 deletions .github/workflows/ci-cd.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/pack.yml
@@ -0,0 +1,103 @@
name: 'Pack'

on:
workflow_run:
workflows: [ 'Build' ]
types: [ requested ]
branches: [ master ]

workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: false
default: 'Manual pack'
version:
description: 'Version'
required: true

env:
CONFIGURATION: 'Release'

PROJECT_PATH: "."

PROJECT_NAME: redmine-net-api

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
pack:
name: Pack
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Determine Version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
else
echo "VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
fi
echo "$GITHUB_ENV"
- name: Print Version
run: |
echo "$VERSION"
- name: Validate Version matches SemVer format
run: |
if [[ ! "$VERSION" =~ ^([0-9]+\.){2}[0-9]+$ ]]; then
echo "The version does not match the SemVer format (X.Y.Z). Please provide a valid version."
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0

- name: Setup .NET Core (global.json)
uses: actions/setup-dotnet@v4

- name: Install dependencies
run: dotnet restore "${{ env.PROJECT_PATH }}"

- name: Pack
run: >-
dotnet pack ./src/redmine-net-api/redmine-net-api.csproj
--output ./artifacts
--configuration "${{ env.CONFIGURATION }}"
-p:Version=$VERSION
-p:PackageVersion=${{ env.VERSION }}
-p:SymbolPackageFormat=snupkg
- name: Pack Signed
run: >-
dotnet pack ./src/redmine-net-api/redmine-net-api.csproj
--output ./artifacts
--configuration "${{ env.CONFIGURATION }}"
--include-symbols
--include-source
-p:Version=$VERSION
-p:PackageVersion=${{ env.VERSION }}
-p:SymbolPackageFormat=snupkg
-p:Sign=true
- name: Install dotnet-validate
run: >-
dotnet tool install
--global dotnet-validate
--version 0.0.1-preview.304
- name: Validate NuGet package
run: |
dotnet-validate package local ./artifacts/**.nupkg
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: ./artifacts
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,47 @@
name: 'Publish to NuGet'

on:
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: false
default: 'Manual publish to nuget'
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
publish:
name: Publish to Nuget
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Print manual run reason
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
path: ./artifacts

- name: Publish packages
run: >-
dotnet nuget push ./artifacts/**.nupkg
--source 'https://api.nuget.org/v3/index.json'
--api-key ${{secrets.NUGET_TOKEN}}
--skip-duplicate
- name: Upload artifacts to the GitHub release
uses: Roang-zero1/github-upload-release-artifacts-action@v3.0.0
with:
args: ./artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1afd7e6

Please sign in to comment.