Skip to content

Commit 600495a

Browse files
committed
move to MC namespace
1 parent 18b02a1 commit 600495a

41 files changed

Lines changed: 1315 additions & 344 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
env:
10+
DOTNET_VERSION: '9.0.x'
11+
12+
jobs:
13+
build:
14+
name: Build and Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v5
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: ${{ env.DOTNET_VERSION }}
25+
26+
- name: Restore dependencies
27+
run: dotnet restore ManagedCode.Umap.slnx
28+
29+
- name: Build
30+
run: dotnet build ManagedCode.Umap.slnx --configuration Release --no-restore
31+
32+
- name: Test
33+
run: dotnet test ManagedCode.Umap.slnx --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
34+
35+
- name: Upload coverage reports to Codecov
36+
if: always()
37+
uses: codecov/codecov-action@v5
38+
with:
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
files: ./**/coverage.cobertura.xml
41+
fail_ci_if_error: false

.github/workflows/release.yml

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
8+
env:
9+
DOTNET_VERSION: '9.0.x'
10+
11+
jobs:
12+
build:
13+
name: Build and Test
14+
runs-on: ubuntu-latest
15+
16+
outputs:
17+
version: ${{ steps.version.outputs.version }}
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Setup .NET
24+
uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: ${{ env.DOTNET_VERSION }}
27+
28+
- name: Extract version from Directory.Build.props
29+
id: version
30+
run: |
31+
VERSION=$(grep -oPm1 "(?<=<Version>)[^<]+" Directory.Build.props)
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
echo "Version from Directory.Build.props: $VERSION"
34+
35+
- name: Restore dependencies
36+
run: dotnet restore ManagedCode.Umap.slnx
37+
38+
- name: Build
39+
run: dotnet build ManagedCode.Umap.slnx --configuration Release --no-restore
40+
41+
- name: Test
42+
run: dotnet test ManagedCode.Umap.slnx --configuration Release --no-build --verbosity normal
43+
44+
- name: Pack NuGet packages
45+
run: dotnet pack ManagedCode.Umap/ManagedCode.Umap.csproj --configuration Release --no-build --output ./artifacts
46+
47+
- name: Upload artifacts
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: nuget-packages
51+
path: ./artifacts/*.nupkg
52+
retention-days: 5
53+
54+
publish-nuget:
55+
name: Publish to NuGet
56+
needs: build
57+
runs-on: ubuntu-latest
58+
if: github.ref == 'refs/heads/main'
59+
60+
outputs:
61+
published: ${{ steps.publish.outputs.published }}
62+
version: ${{ needs.build.outputs.version }}
63+
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v5
67+
68+
- name: Download artifacts
69+
uses: actions/download-artifact@v5
70+
with:
71+
name: nuget-packages
72+
path: ./artifacts
73+
74+
- name: Setup .NET
75+
uses: actions/setup-dotnet@v4
76+
with:
77+
dotnet-version: ${{ env.DOTNET_VERSION }}
78+
79+
- name: Publish to NuGet
80+
id: publish
81+
continue-on-error: true
82+
run: |
83+
set +e
84+
OUTPUT=""
85+
PUBLISHED=false
86+
87+
for package in ./artifacts/*.nupkg; do
88+
echo "Publishing $package..."
89+
RESULT=$(dotnet nuget push "$package" \
90+
--api-key ${{ secrets.NUGET_API_KEY }} \
91+
--source https://api.nuget.org/v3/index.json \
92+
--skip-duplicate 2>&1)
93+
EXIT_CODE=$?
94+
echo "$RESULT"
95+
OUTPUT="$OUTPUT$RESULT"
96+
97+
if [ $EXIT_CODE -eq 0 ]; then
98+
echo "Successfully published $package"
99+
PUBLISHED=true
100+
elif echo "$RESULT" | grep -q "already exists"; then
101+
echo "Package already exists, skipping..."
102+
else
103+
echo "Failed to publish $package"
104+
exit 1
105+
fi
106+
done
107+
108+
if [ "$PUBLISHED" = true ] || echo "$OUTPUT" | grep -q "Your package was pushed"; then
109+
echo "published=true" >> $GITHUB_OUTPUT
110+
echo "At least one package was successfully published"
111+
else
112+
echo "published=false" >> $GITHUB_OUTPUT
113+
echo "No new packages were published (all already exist)"
114+
fi
115+
116+
create-release:
117+
name: Create GitHub Release and Tag
118+
needs: publish-nuget
119+
runs-on: ubuntu-latest
120+
if: needs.publish-nuget.outputs.published == 'true'
121+
122+
steps:
123+
- name: Checkout
124+
uses: actions/checkout@v5
125+
with:
126+
fetch-depth: 0
127+
token: ${{ secrets.GITHUB_TOKEN }}
128+
129+
- name: Download artifacts
130+
uses: actions/download-artifact@v5
131+
with:
132+
name: nuget-packages
133+
path: ./artifacts
134+
135+
- name: Create and push tag
136+
id: create_tag
137+
run: |
138+
VERSION="${{ needs.publish-nuget.outputs.version }}"
139+
TAG="v$VERSION"
140+
141+
git config user.name "github-actions[bot]"
142+
git config user.email "github-actions[bot]@users.noreply.github.com"
143+
144+
if git rev-parse "$TAG" >/dev/null 2>&1; then
145+
echo "Tag $TAG already exists"
146+
echo "tag_exists=true" >> $GITHUB_OUTPUT
147+
else
148+
echo "Creating tag $TAG"
149+
git tag -a "$TAG" -m "Release $VERSION"
150+
git push origin "$TAG"
151+
echo "tag_exists=false" >> $GITHUB_OUTPUT
152+
fi
153+
154+
- name: Get previous tag
155+
id: prev_tag
156+
run: |
157+
CURRENT_TAG="v${{ needs.publish-nuget.outputs.version }}"
158+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -A1 "^$CURRENT_TAG$" | tail -n1 || echo "")
159+
if [ "$PREVIOUS_TAG" = "$CURRENT_TAG" ] || [ -z "$PREVIOUS_TAG" ]; then
160+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -v "^$CURRENT_TAG$" | head -n1 || echo "")
161+
fi
162+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
163+
echo "Current tag: $CURRENT_TAG"
164+
echo "Previous tag: $PREVIOUS_TAG"
165+
166+
- name: Generate release notes
167+
id: release_notes
168+
run: |
169+
VERSION="${{ needs.publish-nuget.outputs.version }}"
170+
CURRENT_TAG="v$VERSION"
171+
PREVIOUS_TAG="${{ steps.prev_tag.outputs.previous_tag }}"
172+
173+
echo "# Release $VERSION" > release_notes.md
174+
echo "" >> release_notes.md
175+
echo "Released on $(date +'%Y-%m-%d')" >> release_notes.md
176+
echo "" >> release_notes.md
177+
178+
if [ -n "$PREVIOUS_TAG" ]; then
179+
echo "## 📋 Changes since $PREVIOUS_TAG" >> release_notes.md
180+
echo "" >> release_notes.md
181+
182+
echo "### ✨ Features" >> release_notes.md
183+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --grep="^feat" --grep="^feature" >> release_notes.md || true
184+
echo "" >> release_notes.md
185+
186+
echo "### 🐛 Bug Fixes" >> release_notes.md
187+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --grep="^fix" --grep="^bugfix" >> release_notes.md || true
188+
echo "" >> release_notes.md
189+
190+
echo "### 📚 Documentation" >> release_notes.md
191+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --grep="^docs" --grep="^doc" >> release_notes.md || true
192+
echo "" >> release_notes.md
193+
194+
echo "### 🔧 Other Changes" >> release_notes.md
195+
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD --invert-grep --grep="^feat" --grep="^feature" --grep="^fix" --grep="^bugfix" --grep="^docs" --grep="^doc" >> release_notes.md || true
196+
echo "" >> release_notes.md
197+
else
198+
echo "## 🎉 Initial Release" >> release_notes.md
199+
echo "" >> release_notes.md
200+
echo "### Recent Changes" >> release_notes.md
201+
git log --pretty=format:"- %s (%h)" --max-count=20 >> release_notes.md
202+
echo "" >> release_notes.md
203+
fi
204+
205+
echo "" >> release_notes.md
206+
echo "## 📦 NuGet Packages" >> release_notes.md
207+
echo "" >> release_notes.md
208+
for package in ./artifacts/*.nupkg; do
209+
PACKAGE_NAME=$(basename "$package" .nupkg)
210+
BASE_NAME=$(echo "$PACKAGE_NAME" | sed "s/\.$VERSION//")
211+
echo "- [$BASE_NAME v$VERSION](https://www.nuget.org/packages/$BASE_NAME/$VERSION)" >> release_notes.md
212+
done
213+
214+
echo "" >> release_notes.md
215+
echo "---" >> release_notes.md
216+
echo "*This release was automatically created by GitHub Actions*" >> release_notes.md
217+
218+
- name: Create GitHub Release
219+
uses: softprops/action-gh-release@v2
220+
with:
221+
tag_name: v${{ needs.publish-nuget.outputs.version }}
222+
name: v${{ needs.publish-nuget.outputs.version }}
223+
body_path: release_notes.md
224+
draft: false
225+
prerelease: false
226+
files: ./artifacts/*.nupkg
227+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)