Merge pull request #715 from leancodepl/fix/kratos-passkey-auth #2027
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Corelibrary Build & Publish | |
on: | |
push: | |
branches: | |
- "v[0-9]+.[0-9]+-?*" | |
pull_request: | |
workflow_dispatch: | |
env: | |
DOTNET_VERSION: 8.0.100 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
jobs: | |
event_file: | |
name: "Event File" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Event File | |
path: ${{ github.event_path }} | |
prepare: | |
name: Prepare & Version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
publish_artifacts: ${{ steps.version.outputs.publish_artifacts }} | |
publish_nuget: ${{ steps.version.outputs.publish_nuget }} | |
artifacts_name: ${{ steps.version.outputs.artifacts_name }} | |
steps: | |
- name: Version | |
id: version | |
run: | | |
BRANCH=${GITHUB_REF#refs/*/} | |
if [[ $BRANCH =~ ^v([0-9]+.[0-9]+)(-[a-zA-Z0-9]+)?$ ]] | |
then | |
BUILD_NUMBER=$(( GITHUB_RUN_NUMBER + 500 )) # compensate for old jenkins CI | |
BRANCH_VERSION=${BASH_REMATCH[1]} | |
VERSION_SUFFIX=${BASH_REMATCH[2]} | |
VERSION="${BRANCH_VERSION}.${BUILD_NUMBER}${VERSION_SUFFIX}" | |
PUBLISH_ARTIFACTS=1 | |
ARTIFACTS_NAME="LeanCode.CoreLibrary.$VERSION.zip" | |
else | |
VERSION="0.0.0" | |
PUBLISH_ARTIFACTS=0 | |
ARTIFACTS_NAME="<none>" | |
fi | |
echo Building on "$BRANCH" | |
echo Building version: "$VERSION" | |
echo "Artifacts will be saved as $ARTIFACTS_NAME" | |
if [[ $GITHUB_EVENT_NAME == 'workflow_dispatch' ]] | |
then | |
echo "Packages will be published to NuGet" | |
PUBLISH_NUGET=1 | |
else | |
PUBLISH_NUGET=0 | |
fi | |
if [[ $PUBLISH_ARTIFACTS == 0 && $PUBLISH_NUGET == 1 ]] | |
then | |
echo "Only vX.Y branches can be published to NuGet, failing" | |
exit 1 | |
fi | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "publish_artifacts=${PUBLISH_ARTIFACTS}" >> $GITHUB_OUTPUT | |
echo "publish_nuget=${PUBLISH_NUGET}" >> $GITHUB_OUTPUT | |
echo "artifacts_name=${ARTIFACTS_NAME}" >> $GITHUB_OUTPUT | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: [prepare] | |
permissions: | |
checks: write | |
pull-requests: write | |
env: | |
VERSION: ${{ needs.prepare.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Restore | |
run: dotnet restore | |
- name: Tool Restore | |
run: dotnet tool restore | |
- name: Check formatting | |
run: dotnet csharpier . --check | |
- name: Build | |
run: dotnet build --configuration Release --no-restore | |
env: | |
GIT_COMMIT: ${{ github.sha }} | |
- name: Pack | |
if: ${{ needs.prepare.outputs.publish_artifacts == '1' }} | |
env: | |
ZIP: ${{ needs.prepare.outputs.artifacts_name }} | |
run: | | |
dotnet pack --no-build -c Release -o "$PWD/packed" | |
zip -j "$ZIP" "$PWD"/packed/*.nupkg | |
- name: Publish artifacts | |
if: ${{ needs.prepare.outputs.publish_artifacts == '1' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.prepare.outputs.artifacts_name }} | |
path: ${{ needs.prepare.outputs.artifacts_name }} | |
test: | |
runs-on: ubuntu-latest | |
name: Test | |
needs: [prepare, build] | |
services: | |
mssql: | |
image: mcr.microsoft.com/mssql/server:2022-latest | |
env: | |
ACCEPT_EULA: Y | |
SA_PASSWORD: Passw12# | |
ports: | |
- "1433:1433" | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_PASSWORD: Passw12# | |
ports: | |
- "5432:5432" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Install trx2junit | |
run: dotnet tool install --global trx2junit | |
- name: Restore | |
run: dotnet restore | |
- name: Test | |
run: dotnet msbuild /t:RunTestsWithCoverage | |
working-directory: test | |
- name: Azure Test | |
run: dotnet test -c Release --logger trx --results-directory ../../TestResults | |
working-directory: test/Infrastructure/LeanCode.Azure.Tests | |
env: | |
CORELIB_TESTS_TENANT_ID: ${{ secrets.CORELIB_TESTS_TENANT_ID }} | |
CORELIB_TESTS_CLIENT_ID: ${{ secrets.CORELIB_TESTS_CLIENT_ID }} | |
CORELIB_TESTS_CLIENT_SECRET: ${{ secrets.CORELIB_TESTS_CLIENT_SECRET }} | |
CORELIB_TESTS_NPGSQL_CONNECTION_STRING: ${{ secrets.CORELIB_TESTS_NPGSQL_CONNECTION_STRING }} | |
CORELIB_TESTS_AZURE_BLOB_STORAGE_SERVICE_URI: ${{ secrets.CORELIB_TESTS_AZURE_BLOB_STORAGE_SERVICE_URI }} | |
CORELIB_TESTS_AZURE_TABLE_STORAGE_SERVICE_URI: ${{ secrets.CORELIB_TESTS_AZURE_TABLE_STORAGE_SERVICE_URI }} | |
CORELIB_TESTS_AZURE_BLOB_STORAGE_CONTAINER_NAME: ${{ secrets.CORELIB_TESTS_AZURE_BLOB_STORAGE_CONTAINER_NAME }} | |
CORELIB_TESTS_AZURE_TABLE_STORAGE_TABLE_NAME: ${{ secrets.CORELIB_TESTS_AZURE_TABLE_STORAGE_TABLE_NAME }} | |
- name: Integration Test - SQL Server | |
run: dotnet test -c Release --logger trx --results-directory ../TestResults | |
working-directory: test/LeanCode.IntegrationTests | |
env: | |
ASPNETCORE_TEST_CONTENTROOT_LEANCODE_INTEGRATIONTESTS: /home/runner/work/corelibrary/corelibrary/test/LeanCode.IntegrationTests | |
SqlServer__ConnectionStringBase: Server=localhost,1433;User Id=sa;Password=Passw12#;Encrypt=false | |
LeanCodeIntegrationTests__Database: sqlserver | |
- name: Integration Test - Postgres | |
run: dotnet test -c Release --logger trx --results-directory ../TestResults | |
working-directory: test/LeanCode.IntegrationTests | |
env: | |
ASPNETCORE_TEST_CONTENTROOT_LEANCODE_INTEGRATIONTESTS: /home/runner/work/corelibrary/corelibrary/test/LeanCode.IntegrationTests | |
Postgres__ConnectionStringBase: Host=localhost;Username=postgres;Password=Passw12# | |
LeanCodeIntegrationTests__Database: postgres | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
if: always() | |
- name: Convert Test Results to jUnit | |
run: find -name '*.trx' -exec trx2junit --output TestResults {} + | |
working-directory: test | |
if: always() | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: > | |
always() && | |
github.event.sender.login != 'dependabot[bot]' && | |
( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository ) | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
files: test/TestResults/*.xml | |
- name: Upload Test Results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Unit Test Results | |
path: test/TestResults/*.xml | |
publish: | |
runs-on: ubuntu-latest | |
name: Publish to feeds | |
needs: [prepare, build, test] | |
if: ${{ needs.prepare.outputs.publish_artifacts == '1' }} | |
steps: | |
- name: Fetch build | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.prepare.outputs.artifacts_name }} | |
- name: Unzip | |
run: | | |
unzip "$ZIP" | |
env: | |
ZIP: ${{ needs.prepare.outputs.artifacts_name }} | |
- name: Push to Feedz | |
run: | | |
find -name '*.nupkg' -exec dotnet nuget push -k "$FEEDZ_API_KEY" -s 'https://f.feedz.io/leancode/public/nuget/index.json' -n '{}' ';' | |
env: | |
FEEDZ_API_KEY: ${{ secrets.FEEDZ_API_KEY }} | |
- name: Create release | |
if: ${{ needs.prepare.outputs.publish_nuget == '1' }} | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ format('v{0}', needs.prepare.outputs.version) }} | |
release_name: ${{ format('Release v{0}', needs.prepare.outputs.version) }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push to NuGet | |
if: ${{ needs.prepare.outputs.publish_nuget == '1' }} | |
run: | | |
find -name '*.nupkg' -exec dotnet nuget push -k "$NUGET_API_KEY" -s 'https://api.nuget.org/v3/index.json' -n '{}' ';' | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |