-
-
Notifications
You must be signed in to change notification settings - Fork 6
106 lines (83 loc) · 3.38 KB
/
Copy pathcd.yml
File metadata and controls
106 lines (83 loc) · 3.38 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Release
run-name: '[Release] ${{ github.event.release.tag_name }}'
on:
release:
types: [published]
permissions:
contents: write
id-token: write
packages: write
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Extract version from release tag
id: get_version
run: |
VERSION=${GITHUB_REF_NAME#v}
if [ -z "$VERSION" ]; then
echo "Error: VERSION is empty! GITHUB_REF_NAME was: $GITHUB_REF_NAME"
echo "Please create the release with a proper tag like 'v3.0.0'"
exit 1
fi
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "Extracted version: $VERSION"
- name: Update package versions
run: |
VERSION="${{ steps.get_version.outputs.VERSION }}"
sed -i -E "s|<Version>[^<]*</Version>|<Version>${VERSION}</Version>|g" \
src/BlazorFrame/BlazorFrame.csproj \
src/BlazorFrame.AspNetCore/BlazorFrame.AspNetCore.csproj
echo "Updated package projects to version ${VERSION}"
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run Unit Tests
run: dotnet test --configuration Release --no-build --verbosity normal
- name: Pack NuGet packages
run: dotnet pack --configuration Release --no-build --include-symbols -p:SymbolPackageFormat=snupkg --output ./artifacts
- name: List generated packages
run: ls -la ./artifacts/
- name: NuGet login (Trusted Publishing)
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet
run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish to GitHub Packages
run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ secrets.GITHUB_TOKEN }}" --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --skip-duplicate
- name: Commit version update
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if git symbolic-ref HEAD >/dev/null 2>&1; then
echo "On branch, proceeding with commit"
else
echo "Detached HEAD detected, switching to master branch"
git checkout -B master
fi
if git diff --quiet -- src/BlazorFrame/BlazorFrame.csproj src/BlazorFrame.AspNetCore/BlazorFrame.AspNetCore.csproj; then
echo "No changes to commit"
else
git add src/BlazorFrame/BlazorFrame.csproj src/BlazorFrame.AspNetCore/BlazorFrame.AspNetCore.csproj
git commit -m "Bump version to ${{ steps.get_version.outputs.VERSION }}"
git push origin master
fi