Repository navigation
187 lines (164 loc) · 7.12 KB
/
Copy pathRelease-CI.yml
File metadata and controls
187 lines (164 loc) · 7.12 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: release-ci
on:
push:
branches:
- release/**
- release
paths-ignore:
- "**/*.md"
- "**/*.gitignore"
- "**/*.gitattributes"
tags:
- release-packages
permissions:
contents: read
packages: write
jobs:
Build-Test-Publish:
runs-on: ubuntu-latest
services:
localstack:
image: localstack/localstack:3
ports:
- 4566:4566
env:
SERVICES: sqs,sns,kms
DEBUG: 1
EAGER_SERVICE_LOADING: 1
DOCKER_HOST: unix:///var/run/docker.sock
# Disable IAM enforcement for easier testing
ENFORCE_IAM: 0
# Skip SSL certificate validation
SKIP_SSL_CERT_DOWNLOAD: 1
# Disable signature validation (accept any credentials)
DISABLE_CUSTOM_CORS_S3: 1
DISABLE_CUSTOM_CORS_APIGATEWAY: 1
options: >-
--health-cmd "curl -f http://localhost:4566/_localstack/health || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 30s
env:
working-directory: ${{ github.workspace }}
github-token: '${{ secrets.GH_Packages }}'
nuget-token: '${{ secrets.NUGET_API_KEY }}'
# Check if this is a release-packages tag push
is-release: ${{ startsWith(github.ref, 'refs/tags/release-packages') }}
# AWS credentials for LocalStack (dummy values)
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
steps:
- name: Step-01 Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.15
with:
versionSpec: 5.x
- name: Step-02 Check out Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Step-03 Calculate Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.15
with:
useConfigFile: true
- name: Step-04 Evaluate Version
id: version
run: |
echo "NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersion }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.FullSemVer }}"
echo "MajorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }}"
echo "BranchName: ${{ steps.gitversion.outputs.BranchName }}"
echo "Is Release: ${{ env.is-release }}"
if [ "${{ env.is-release }}" == "true" ]; then
echo "package-version=${{ steps.gitversion.outputs.MajorMinorPatch }}" >> $GITHUB_OUTPUT
echo "Using RELEASE version: ${{ steps.gitversion.outputs.MajorMinorPatch }}"
else
echo "package-version=${{ steps.gitversion.outputs.NuGetVersion }}" >> $GITHUB_OUTPUT
echo "Using PRE-RELEASE version: ${{ steps.gitversion.outputs.NuGetVersion }}"
fi
- name: Step-05 Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
- name: Step-06 Verify LocalStack is Ready
run: |
echo "Waiting for LocalStack to be fully ready..."
echo "Testing connection to localhost:4566..."
# Test basic connectivity first
if ! nc -zv localhost 4566 2>&1; then
echo "ERROR: Cannot connect to localhost:4566"
echo "Checking if LocalStack container is running..."
docker ps -a
exit 1
fi
echo "Port 4566 is accessible, checking health endpoint..."
max_attempts=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
if curl -f http://localhost:4566/_localstack/health 2>/dev/null; then
echo "LocalStack is ready!"
echo "Health endpoint response:"
curl -s http://localhost:4566/_localstack/health | jq '.'
echo ""
echo "Testing if services are available..."
health_response=$(curl -s http://localhost:4566/_localstack/health)
echo "Full health response: $health_response"
break
fi
attempt=$((attempt + 1))
echo "Attempt $attempt/$max_attempts - LocalStack not ready yet, waiting..."
sleep 3
done
if [ $attempt -eq $max_attempts ]; then
echo "ERROR: LocalStack did not become ready in time"
echo "Checking LocalStack container logs..."
docker logs $(docker ps -q --filter ancestor=localstack/localstack:3) || echo "Could not get container logs"
exit 1
fi
echo ""
echo "LocalStack is ready for tests!"
- name: Step-06b Clear NuGet Cache
run: dotnet nuget locals all --clear
working-directory: '${{ env.working-directory }}'
- name: Step-07 Restore dependencies
run: dotnet restore --no-cache --force
working-directory: '${{ env.working-directory }}'
- name: Step-08 Build Version ${{ steps.version.outputs.package-version }}
run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ steps.version.outputs.package-version }}
working-directory: '${{ env.working-directory }}'
- name: Step-09 Run Unit Tests
run: |
dotnet test --configuration Release --no-build --no-restore --verbosity normal \
--filter "FullyQualifiedName!~Integration&FullyQualifiedName!~Security"
working-directory: '${{ env.working-directory }}'
- name: Step-09b Run Integration Tests with LocalStack
run: |
dotnet test --configuration Release --no-build --no-restore --verbosity normal \
--filter "Category=Integration&Category=RequiresLocalStack" \
-- RunConfiguration.TestSessionTimeout=600000
working-directory: '${{ env.working-directory }}'
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
AWS_ENDPOINT_URL: http://localhost:4566
GITHUB_ACTIONS: true
- name: Step-10 Create NuGet Package ${{ steps.version.outputs.package-version }}
run: dotnet pack --configuration Release --no-build --output ./packages -p:PackageVersion=${{ steps.version.outputs.package-version }}
working-directory: '${{ env.working-directory }}'
- name: Step-11 Publish to Github Packages
run: |
dotnet nuget add source --username CodeShayk --password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text --name github \
"https://nuget.pkg.github.com/CodeShayk/index.json" || true
find ./packages -name "*.nupkg" -print -exec \
dotnet nuget push {} --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} \
--source "https://nuget.pkg.github.com/CodeShayk/index.json" \;
working-directory: '${{ env.working-directory }}'
- name: Step-12 Publish to NuGet.org
if: ${{ env.is-release == 'true' && env.nuget-token != '' }}
run: |
find ./packages -name "*.nupkg" -print -exec dotnet nuget push {} --skip-duplicate --api-key ${{ env.nuget-token }} --source https://api.nuget.org/v3/index.json \;
working-directory: '${{ env.working-directory }}'