-
-
Notifications
You must be signed in to change notification settings - Fork 244
94 lines (89 loc) · 3.34 KB
/
build-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build
on:
workflow_call:
inputs:
solution:
description: 'The solution to build'
default: ''
required: false
type: string
org:
description: 'The organization to publish CI builds to'
default: 'foundatiofx'
required: false
type: string
compose-command:
description: 'The docker compose command to run for tests'
default: 'docker compose up -d && docker compose up ready || true'
required: false
type: string
secrets:
NUGET_KEY:
required: false
FEEDZ_KEY:
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Build Reason
run: |
branch=${GITHUB_REF##*/}.
if [[ "$branch" = "main." ]]; then
branch=""
elif [[ "$branch" = "master." ]]; then
branch=""
elif [[ "${GITHUB_REF}" = refs/tags* ]]; then
branch=""
elif [[ "${GITHUB_REF}" = refs/pull* ]]; then
branch=""
fi
echo "GIT_BRANCH_SUFFIX=$branch" >> $GITHUB_ENV
echo branch: $branch ref: $GITHUB_REF event: $GITHUB_EVENT_NAME actor: $GITHUB_ACTOR
- name: Build Version
run: |
dotnet tool install --global minver-cli --version 6.0.0
version=$(minver --tag-prefix v --default-pre-release-identifiers alpha.${GIT_BRANCH_SUFFIX}0)
echo "MINVERVERSIONOVERRIDE=$version" >> $GITHUB_ENV
echo "### Version: $version" >> $GITHUB_STEP_SUMMARY
- name: Build
run: dotnet build ${{ inputs.solution }} --configuration Release
- name: Start Services
if: hashFiles('docker-compose.yml') != ''
run: ${{ inputs.compose-command }}
- name: Run Tests
run: dotnet test ${{ inputs.solution }} --configuration Release --no-build --logger GitHubActions
- name: Package
if: github.event_name != 'pull_request'
run: dotnet pack ${{ inputs.solution }} --configuration Release --no-build
- name: Publish CI Packages
if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'
run: |
for package in $(find -name "*.nupkg" | grep "minver" -v); do
# GitHub
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
echo "${0##*/}": Pushing $package to GitHub...
dotnet nuget push $package --source https://nuget.pkg.github.com/${{ inputs.org }}/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
fi
# Feedz (remove once GitHub supports anonymous access)
if [ -n "${{ secrets.FEEDZ_KEY }}" ]; then
echo "${0##*/}": Pushing $package to Feedz...
dotnet nuget push $package --source https://f.feedz.io/foundatio/foundatio/nuget --api-key ${{ secrets.FEEDZ_KEY }} --skip-duplicate
fi
done
- name: Publish Release Packages
if: startsWith(github.ref, 'refs/tags/v')
run: |
for package in $(find -name "*.nupkg" | grep "minver" -v); do
echo "${0##*/}": Pushing $package...
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate
done