-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (79 loc) · 2.96 KB
/
release-client.yml
File metadata and controls
96 lines (79 loc) · 2.96 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
name: Release Client Libraries
on:
workflow_dispatch:
jobs:
validate:
name: Validate version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.read_version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Read version from semver.txt
id: read_version
run: |
version=$(tr -d '[:space:]' < src/CoderPatros.Tea.Client/semver.txt)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Validate semver format
run: |
if ! echo "${{ steps.read_version.outputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then
echo "::error::Version '${{ steps.read_version.outputs.version }}' is not valid semver"
exit 1
fi
- name: Check tag does not exist
run: |
if git ls-remote --tags https://github.com/${{ github.repository }} | grep -q "refs/tags/client/v${{ steps.read_version.outputs.version }}$"; then
echo "::error::Tag client/v${{ steps.read_version.outputs.version }} already exists"
exit 1
fi
test:
name: Test (${{ matrix.os }})
needs: validate
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
release:
name: Release
needs: [validate, test]
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ needs.validate.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Pack Client
run: dotnet pack src/CoderPatros.Tea.Client/CoderPatros.Tea.Client.csproj -c Release -p:Version=${{ env.VERSION }} -o ./artifacts
- name: Pack Client DI Extensions
run: dotnet pack src/CoderPatros.Tea.Client.Extensions.DependencyInjection/CoderPatros.Tea.Client.Extensions.DependencyInjection.csproj -c Release -p:Version=${{ env.VERSION }} -o ./artifacts
- name: Push to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Create and push tag
run: |
git tag "client/v${{ env.VERSION }}"
git push origin "client/v${{ env.VERSION }}"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: client/v${{ env.VERSION }}
name: Client Libraries v${{ env.VERSION }}
generate_release_notes: true
files: ./artifacts/*.nupkg