-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (121 loc) · 4.64 KB
/
alpha-release.yml
File metadata and controls
141 lines (121 loc) · 4.64 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Alpha Release
on:
push:
branches: [master]
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch:
inputs:
base_version:
description: 'Base version (without alpha suffix)'
required: false
default: '1.0.0'
permissions:
contents: read
concurrency:
group: alpha-release-${{ github.ref }}
cancel-in-progress: true
env:
BASE_VERSION: '1.0.0'
jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET & Restore
uses: ./.github/actions/setup-dotnet-build
- name: Build
run: dotnet build -c Release --no-restore
- name: Run unit tests
run: >
dotnet test tests/ServiceBusToolset.Application.Tests
-c Release --no-build
--collect:"XPlat Code Coverage"
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
- name: Generate coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@cf6fe1b38ed5becc89ffe056c1f240825993be5b # 5.5.4
with:
reports: ./**/coverage.cobertura.xml
targetdir: ./coverage-report
reporttypes: TextSummary
- name: Extract and publish coverage badge
id: coverage
env:
GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
run: |
SUMMARY=$(cat ./coverage-report/Summary.txt)
LINE_COVERAGE=$(echo "$SUMMARY" | grep -i 'Line coverage' | grep -oP '[\d.]+(?=%)')
echo "Line coverage: ${LINE_COVERAGE}%"
if [ -z "$LINE_COVERAGE" ]; then
echo "::warning::Could not parse line coverage"
exit 0
fi
echo "coverage=${LINE_COVERAGE}" >> $GITHUB_OUTPUT
# Determine badge color
if (( $(echo "$LINE_COVERAGE >= 80" | bc -l) )); then
COLOR="brightgreen"
elif (( $(echo "$LINE_COVERAGE >= 60" | bc -l) )); then
COLOR="yellowgreen"
else
COLOR="red"
fi
echo "color=${COLOR}" >> $GITHUB_OUTPUT
- name: Update coverage badge gist
if: steps.coverage.outputs.coverage != '' && env.GIST_TOKEN != ''
uses: schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: ${{ vars.COVERAGE_GIST_ID }}
filename: coverage-badge.json
label: coverage
message: ${{ steps.coverage.outputs.coverage }}%
color: ${{ steps.coverage.outputs.color }}
alpha-release:
name: Alpha Release
runs-on: ubuntu-latest
needs: test
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET & Restore
uses: ./.github/actions/setup-dotnet-build
- name: Build
run: dotnet build -c Release --no-restore
- name: Generate version
id: version
env:
INPUT_BASE_VERSION: ${{ github.event.inputs.base_version }}
run: |
# Use input version if provided (workflow_dispatch), otherwise use env default
BASE="${INPUT_BASE_VERSION:-$BASE_VERSION}"
# Validate version matches strict semver pattern
if [[ ! "$BASE" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid base version '$BASE'. Must match X.Y.Z semver format."
exit 1
fi
ALPHA_VERSION="${BASE}-alpha.${GITHUB_RUN_NUMBER}"
echo "version=$ALPHA_VERSION" >> $GITHUB_OUTPUT
echo "Generated version: $ALPHA_VERSION"
- name: Pack CLI
env:
VERSION: ${{ steps.version.outputs.version }}
run: dotnet pack src/ServiceBusToolset.CLI -c Release --no-build -o ./artifacts -p:Version="$VERSION"
- name: Pack Application
env:
VERSION: ${{ steps.version.outputs.version }}
run: dotnet pack src/ServiceBusToolset.Application -c Release --no-build -o ./artifacts -p:Version="$VERSION"
- name: Push to NuGet
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
if [ -z "$NUGET_API_KEY" ]; then
echo "::warning::NUGET_API_KEY secret not set, skipping publish"
exit 0
fi
dotnet nuget push ./artifacts/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push ./artifacts/*.snupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate