Skip to content

Commit 0ed016c

Browse files
committed
organization, improves CI
1 parent 0523365 commit 0ed016c

13 files changed

Lines changed: 97 additions & 123 deletions
Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,44 @@
11
name: build-and-test
2+
3+
permissions:
4+
contents: read
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
8+
cancel-in-progress: true
9+
210
on:
3-
# Testing - run for any PRs.
411
pull_request:
512
branches:
613
- main
14+
workflow_dispatch:
715

816
env:
9-
"PipelineEnvironment": true
17+
PipelineEnvironment: true
18+
NUGET_XMLDOC_MODE: skip
1019

1120
jobs:
1221
build-and-test:
1322
runs-on: ubuntu-latest
1423

1524
steps:
1625
- uses: actions/checkout@v6
26+
with:
27+
persist-credentials: false
1728

1829
- name: Setup .NET
1930
uses: actions/setup-dotnet@v5
2031
with:
2132
dotnet-version: 10.0.x
2233

23-
- name: Install dependencies with retry
24-
shell: bash
25-
run: |
26-
retries=5
27-
base_wait_time=15
28-
exponent=2
29-
30-
for i in $(seq 1 $retries); do
31-
echo "::group::dotnet restore (attempt $i/$retries)"
32-
if dotnet restore -v detailed; then
33-
echo "::endgroup::"
34-
echo "✅ dotnet restore succeeded on attempt $i."
35-
break
36-
else
37-
echo "::endgroup::"
38-
if [ "$i" -lt "$retries" ]; then
39-
wait_time=$(( base_wait_time * (exponent ** (i - 1)) ))
40-
echo "❌ dotnet restore failed (attempt $i). Retrying in ${wait_time}s…"
41-
sleep "$wait_time"
42-
else
43-
echo "::error::dotnet restore failed after $retries attempts"
44-
exit 1
45-
fi
46-
fi
47-
done
48-
49-
- name: Build
50-
run: dotnet build --configuration Release --no-restore
34+
- name: Restore tests
35+
run: dotnet restore test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --verbosity minimal
36+
37+
- name: Build tests
38+
run: dotnet build test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --configuration Release --no-restore --verbosity minimal
5139

5240
- name: Test
53-
run: dotnet test test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --no-restore --verbosity normal
41+
run: dotnet test test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --configuration Release --no-build --no-restore --verbosity minimal
5442

5543
- name: Pack
56-
run: dotnet pack --no-build --configuration Release --output .
44+
run: dotnet pack src/Soenneker.Gen.EnumValues/Soenneker.Gen.EnumValues.csproj --configuration Release --no-build --no-restore --output . --verbosity minimal

.github/workflows/codeql.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: codeql
22

3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
37
on:
48
push:
59
branches: [ "main" ]
610
paths-ignore:
711
- 'test/**'
12+
workflow_dispatch:
813

9-
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
14+
env:
15+
NUGET_XMLDOC_MODE: skip
1216

1317
permissions:
1418
actions: read
@@ -23,6 +27,8 @@ jobs:
2327
steps:
2428
- name: Checkout repository
2529
uses: actions/checkout@v6
30+
with:
31+
persist-credentials: false
2632

2733
- name: Setup .NET
2834
uses: actions/setup-dotnet@v5
@@ -36,10 +42,10 @@ jobs:
3642
build-mode: manual
3743

3844
- name: Restore src
39-
run: dotnet restore ./src
45+
run: dotnet restore ./src/Soenneker.Gen.EnumValues/Soenneker.Gen.EnumValues.csproj --verbosity minimal
4046

4147
- name: Build src
42-
run: dotnet build ./src --no-restore -c Release
48+
run: dotnet build ./src/Soenneker.Gen.EnumValues/Soenneker.Gen.EnumValues.csproj --configuration Release --no-restore --verbosity minimal
4349

4450
- name: Perform CodeQL Analysis
4551
uses: github/codeql-action/analyze@v4
Lines changed: 56 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: publish-package
2+
23
concurrency:
34
group: ${{ github.workflow }}-${{ github.ref }}
45
cancel-in-progress: true
@@ -9,119 +10,94 @@ on:
910
- main
1011
paths-ignore:
1112
- 'test/**'
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: write
17+
packages: write
1218

1319
env:
14-
"PipelineEnvironment": true
20+
PipelineEnvironment: true
21+
NUGET_XMLDOC_MODE: skip
1522

1623
jobs:
1724
publish-package:
1825
runs-on: ubuntu-latest
1926

2027
steps:
2128
- uses: actions/checkout@v6
22-
29+
with:
30+
persist-credentials: false
31+
2332
- name: Setting up build version
33+
shell: bash
2434
run: |
25-
version=$(($GITHUB_RUN_NUMBER))
26-
echo "BUILD_VERSION=4.0.$version" >> ${GITHUB_ENV}
35+
echo "BUILD_VERSION=4.0.${GITHUB_RUN_NUMBER}" >> "$GITHUB_ENV"
36+
37+
- name: Get release notes from latest commit
38+
shell: bash
39+
run: |
40+
{
41+
echo "PACKAGE_RELEASE_NOTES<<EOF"
42+
git log -1 --pretty=%B
43+
echo "EOF"
44+
} >> "$GITHUB_ENV"
2745
2846
- name: Setup .NET
2947
uses: actions/setup-dotnet@v5
3048
with:
3149
dotnet-version: 10.0.x
3250

33-
- name: Install dependencies with retry
34-
shell: bash
35-
run: |
36-
retries=5
37-
base_wait_time=15
38-
exponent=2
39-
40-
for i in $(seq 1 $retries); do
41-
echo "::group::dotnet restore (attempt $i/$retries)"
42-
if dotnet restore -v detailed; then
43-
echo "::endgroup::"
44-
echo "✅ dotnet restore succeeded on attempt $i."
45-
break
46-
else
47-
echo "::endgroup::"
48-
if [ "$i" -lt "$retries" ]; then
49-
wait_time=$(( base_wait_time * (exponent ** (i - 1)) ))
50-
echo "❌ dotnet restore failed (attempt $i). Retrying in ${wait_time}s…"
51-
sleep "$wait_time"
52-
else
53-
echo "::error::dotnet restore failed after $retries attempts"
54-
exit 1
55-
fi
56-
fi
57-
done
51+
- name: Restore tests
52+
run: dotnet restore test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --verbosity minimal
5853

5954
- name: Build
60-
run: dotnet build --configuration Release --no-restore
55+
run: dotnet build test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --configuration Release --no-restore --verbosity minimal
6156

6257
- name: Test
63-
run: dotnet test test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --no-restore --verbosity normal
58+
run: dotnet test test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj --configuration Release --no-build --no-restore --verbosity normal
6459

6560
- name: Pack
66-
run: dotnet pack --no-build --configuration Release --output .
61+
shell: bash
62+
run: |
63+
mkdir -p artifacts
64+
dotnet pack src/Soenneker.Gen.EnumValues/Soenneker.Gen.EnumValues.csproj \
65+
--configuration Release \
66+
--no-build \
67+
--no-restore \
68+
--output ./artifacts
6769
6870
- name: Publish to NuGet with retry
71+
shell: bash
6972
run: |
70-
nupkg_files=$(find . -name "*.nupkg")
71-
retries=5
72-
base_wait_time=20
73-
exponent=3.5
74-
75-
for i in $(seq 1 $retries); do
76-
if dotnet nuget push $nupkg_files --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET__TOKEN}} --skip-duplicate; then
77-
break
78-
fi
79-
80-
if [ $i -lt $retries ]; then
81-
wait_time=$(awk "BEGIN {print int($base_wait_time * ($exponent ^ ($i - 1)))}")
82-
echo "NuGet publish failed, retrying in $wait_time seconds..."
83-
sleep $wait_time
73+
for i in 1 2 3; do
74+
dotnet nuget push ./artifacts/*.nupkg \
75+
--source "https://api.nuget.org/v3/index.json" \
76+
--api-key "${{ secrets.NUGET__TOKEN }}" \
77+
--skip-duplicate && break
78+
79+
if [ "$i" -lt 3 ]; then
80+
echo "NuGet publish failed, retrying in 10 seconds..."
81+
sleep 10
8482
else
85-
echo "NuGet publish failed after $retries retries."
83+
echo "NuGet publish failed after 3 attempts."
8684
exit 1
8785
fi
8886
done
8987
90-
- name: Add GitHub NuGet Source
91-
run: |
92-
dotnet nuget add source https://nuget.pkg.github.com/soenneker/index.json \
93-
--name "github" \
94-
--username "any" \
95-
--password ${{ secrets.GH__TOKEN }} \
96-
--store-password-in-clear-text
97-
9888
- name: Publish to GitHub Packages
89+
shell: bash
9990
run: |
100-
dotnet nuget push ./*.nupkg \
101-
--source "github" \
102-
--api-key ${{ secrets.GH__TOKEN }}
91+
dotnet nuget push ./artifacts/*.nupkg \
92+
--source "https://nuget.pkg.github.com/soenneker/index.json" \
93+
--api-key "${{ secrets.GH__TOKEN }}" \
94+
--skip-duplicate
10395
10496
- name: Create GitHub Release
97+
env:
98+
GH_TOKEN: ${{ secrets.GH__TOKEN }}
99+
shell: bash
105100
run: |
106-
changelog=$(git log -20 --pretty=format:"- %s")
107-
tag_name="v$BUILD_VERSION"
108-
109-
json_payload=$(
110-
jq -n \
111-
--arg tag_name "$tag_name" \
112-
--arg name "$tag_name" \
113-
--arg body "$changelog" \
114-
'{
115-
tag_name: $tag_name,
116-
name: $name,
117-
body: $body,
118-
draft: false,
119-
prerelease: false
120-
}'
121-
)
122-
123-
curl -s -X POST \
124-
-H "Authorization: Bearer ${{ secrets.GH__TOKEN }}" \
125-
-H "Accept: application/vnd.github+json" \
126-
https://api.github.com/repos/${{ github.repository }}/releases \
127-
-d "$json_payload"
101+
gh release create "v$BUILD_VERSION" \
102+
--title "v$BUILD_VERSION" \
103+
--notes "${{ env.PACKAGE_RELEASE_NOTES }}"

Soenneker.Gen.EnumValues.slnx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
</Folder>
55
<Folder Name="/.github/workflows/">
66
<File Path=".github/workflows/build-and-test.yml" />
7+
<File Path=".github/workflows/codeql.yml" />
78
<File Path=".github/workflows/publish-package.yml" />
89
</Folder>
910
<Folder Name="/src/">
10-
<Project Path="src/Soenneker.Gen.EnumValues.csproj" />
11+
<Project Path="src/Soenneker.Gen.EnumValues/Soenneker.Gen.EnumValues.csproj" />
1112
</Folder>
1213
<Folder Name="/test/">
1314
<Project Path="test/Soenneker.Gen.EnumValues.Tests/Soenneker.Gen.EnumValues.Tests.csproj" />
1415
</Folder>
15-
</Solution>
16+
</Solution>

src/Dtos/EnumBuildSourceContext.cs renamed to src/Soenneker.Gen.EnumValues/Dtos/EnumBuildSourceContext.cs

File renamed without changes.

src/EnumInstance.cs renamed to src/Soenneker.Gen.EnumValues/EnumInstance.cs

File renamed without changes.

src/EnumTypeCandidate.cs renamed to src/Soenneker.Gen.EnumValues/EnumTypeCandidate.cs

File renamed without changes.

src/EnumValueSourceGenerator.Emission.cs renamed to src/Soenneker.Gen.EnumValues/EnumValueSourceGenerator.Emission.cs

File renamed without changes.

src/EnumValueSourceGenerator.InstanceGathering.cs renamed to src/Soenneker.Gen.EnumValues/EnumValueSourceGenerator.InstanceGathering.cs

File renamed without changes.

src/EnumValueSourceGenerator.SourceFragments.cs renamed to src/Soenneker.Gen.EnumValues/EnumValueSourceGenerator.SourceFragments.cs

File renamed without changes.

0 commit comments

Comments
 (0)