Skip to content

Commit

Permalink
refactor workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
phnx47 committed Dec 13, 2024
1 parent 924bd17 commit a6ae2dd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ branches:
required_pull_request_reviews: null
required_status_checks:
strict: false
contexts: ['Build, Test & Pack (Linux)']
contexts: ['Build, Test & Pack']
enforce_admins: false
required_linear_history: false
restrictions: null
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Windows
name: Build Windows

on:
push:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build

on:
pull_request:
branches:
- "main"
workflow_dispatch:
workflow_call:

jobs:
build:
name: Build, Test & Pack
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build
run: dotnet build -c Release -p:ContinuousIntegrationBuild=true

- name: Run tests
run: dotnet test --no-build -c Release -p:CollectCoverage=true -e:CoverletOutputFormat=opencover

- name: Publish to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Set Dev version
if: github.ref == 'refs/heads/main'
run: |
version="$(git describe --long --tags | sed 's/^v//;0,/-/s//./')"
if [ -z "${version}" ]; then
version="0.0.0.$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)"
fi
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Set Release version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV

- name: Pack NuGet artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
run: dotnet pack --no-build -c Release -p:PackageVersion="${{ env.VERSION }}"

- name: Upload artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: src/**/*nupkg
62 changes: 5 additions & 57 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,20 @@
name: CI Linux
name: CI

on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
branches:
- "main"
workflow_dispatch:

jobs:
build-linux:
name: Build, Test & Pack (Linux)
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build
run: dotnet build -c Release -p:ContinuousIntegrationBuild=true

- name: Run tests
run: dotnet test --no-build -c Release -p:CollectCoverage=true -e:CoverletOutputFormat=opencover

- name: Publish to Codecov
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Set Dev version
if: github.ref == 'refs/heads/main'
run: |
version="$(git describe --long --tags | sed 's/^v//;0,/-/s//./')"
if [ -z "${version}" ]; then
version="0.0.0.$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)"
fi
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Set Release version
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV

- name: Pack NuGet artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
run: dotnet pack --no-build -c Release -p:PackageVersion="${{ env.VERSION }}"

- name: Upload artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: src/**/*nupkg
build:
uses: ./.github/workflows/build.yml

github:
name: Deploy to GitHub
needs: [build-linux]
needs: [build]
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
steps:
Expand All @@ -79,7 +27,7 @@ jobs:

nuget:
name: Deploy to NuGet
needs: [build-linux]
needs: [build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-24.04
steps:
Expand Down

0 comments on commit a6ae2dd

Please sign in to comment.