diff --git a/.gitea/workflows/build-and-publish.yml b/.gitea/workflows/build-and-publish.yml new file mode 100644 index 0000000..0ebad99 --- /dev/null +++ b/.gitea/workflows/build-and-publish.yml @@ -0,0 +1,192 @@ +name: Build, Test & Publish DataModels + Apps + +on: + push: + branches: + - master + create: # nowe tagi + tags: + - 'v*' + pull_request: + types: [opened, synchronize, reopened, closed] + workflow_dispatch: # ręczne uruchomienie + +jobs: + restore-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # potrzebne do MinVer i git describe + repository: FA/FA_WEB # ← nazwa repozytorium (organizacja/repo) + ref: ${{ github.ref }} # lub ${{ gitea.ref }} – w Gitea obie działają + # Najważniejsze – nadpisz domyślny URL + url: http://srv51.mikr.us:20120/git/FA/FA_WEB.git + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' # zmień na swoją wersję jeśli inna + + - name: Restore all projects + run: | + echo "=== Restore wszystkich projektów ===" + find . -name "*.csproj" -type f -exec dotnet restore "{}" \; + + - name: Run tests + run: | + echo "=== Uruchamianie testów ===" + dotnet test --no-restore --configuration Release --logger "trx" + + pack-datamodels: + runs-on: ubuntu-latest + needs: restore-and-test + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Install MinVer CLI + run: dotnet tool install --global minver-cli + + - name: Pack DataModel projects + env: + MINVER_AUTO_INCREMENT: patch + MINVER_MINIMUM_MAJOR_MINOR: 2.0 + MINVER_DEFAULT_PRE_RELEASE_IDENTIFIERS: alpha.0 + run: | + echo "=== Obliczona wersja przez MinVer ===" + MINVER_VERSION=$(minver --verbosity detailed) + echo "Wersja: $MINVER_VERSION" + + mkdir -p nupkg + + echo "=== Pełniejsze fetch git (tags) ===" + git fetch --prune --tags --force + + echo "=== Dostępne tagi ===" + git tag -l + + echo "=== Aktualny opis commitu ===" + git describe --tags --always --dirty || echo "Brak tagów" + + echo "=== Pakowanie projektów z PackageId ===" + find . -name "*.csproj" -type f | while read -r csproj; do + if grep -q '' "$csproj"; then + PROJECT_NAME=$(basename "$csproj" .csproj) + echo "→ Pakuję $PROJECT_NAME" + dotnet pack "$csproj" \ + --no-restore \ + --configuration Release \ + -o "./nupkg" \ + /p:PackageVersion="$MINVER_VERSION" + else + echo "→ Pomijam $(basename "$csproj" .csproj) – brak PackageId" + fi + done + + ls -la nupkg/ || echo "Brak wygenerowanych pakietów" + + - name: Upload NuGet packages as artifact + uses: actions/upload-artifact@v4 + with: + name: nuget-packages + path: nupkg/*.nupkg + retention-days: 3 + + publish-to-baget: + runs-on: ubuntu-latest + needs: pack-datamodels + steps: + - uses: actions/checkout@v4 # potrzebne tylko jeśli chcesz logować coś z repo + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Download built packages + uses: actions/download-artifact@v4 + with: + name: nuget-packages + path: nupkg/ + + - name: Create custom NuGet.config (allow HTTP) + run: | + cat > NuGet.Config < + + + + + + + + EOF + + - name: Publish packages to BaGet + env: + BAGET_API_KEY: ${{ secrets.BAGET_API_KEY }} + run: | + echo "=== Publikacja do BaGet ===" + find nupkg -name "*.nupkg" -type f | while read -r pkg; do + echo "→ Push $(basename "$pkg")" + dotnet nuget push "$pkg" \ + --source "BaGet" \ + --api-key "$BAGET_API_KEY" \ + --skip-duplicate + done + + build-and-publish-apps: + runs-on: ubuntu-latest + needs: publish-to-baget + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.0.x' + + - name: Restore (with latest DataModels) + run: | + echo "=== Restore z najnowszymi pakietami z BaGet ===" + dotnet restore + + - name: Publish selected applications + run: | + echo "=== Publish aplikacji z DeployToCentral ===" + find . -name "*.csproj" -type f | while read -r csproj; do + PROJECT_NAME=$(basename "$csproj" .csproj) + PROJECT_DIR=$(dirname "$csproj") + + if [[ "$PROJECT_NAME" == *"Api"* ]] || [[ "$PROJECT_NAME" == *"Blazor"* ]] || \ + [[ "$PROJECT_DIR" == *"/Api/"* ]] || [[ "$PROJECT_DIR" == *"/Blazor/"* ]]; then + + DEPLOY_TO_CENTRAL=$(dotnet msbuild "$csproj" -getProperty:DeployToCentral -nologo 2>/dev/null || echo "false") + + if [ "$DEPLOY_TO_CENTRAL" != "true" ]; then + echo "Pomijam $PROJECT_NAME (DeployToCentral ≠ true)" + continue + fi + + echo "→ Publishing $PROJECT_NAME" + dotnet publish "$csproj" \ + --no-restore \ + --configuration Release \ + -o "./publish-$PROJECT_NAME" + + # Tutaj możesz dodać deployment (np. rsync, scp, docker build+push itp.) + # Przykład (zakomentowany): + # rsync -avz --delete ./publish-$PROJECT_NAME/ user@server:/path/to/app/ + else + echo "Pomijam $PROJECT_NAME (nie Api/Blazor)" + fi + done + + echo "Pipeline zakończony" diff --git a/.woodpecker.yml b/.woodpecker.yml index 2b5c959..452eed2 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,10 +1,18 @@ skip_clone: true when: - event: [push, tag, manual] - branch: [master] + event: pull_request + action: + - merge + branch: master steps: + debug-location: + image: alpine + commands: + - pwd # gdzie aktualnie jesteśmy + - ls -la # co jest w bieżącym katalogu + - find /woodpecker -maxdepth 4 -type d 2>/dev/null clone-manual: image: woodpeckerci/plugin-git settings: @@ -17,8 +25,8 @@ steps: commands: - | set -euf - CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB" - cd "$CODE_DIR" + cd "${CI_WORKSPACE}" + echo "Aktualna ścieżka: $(pwd)" echo "=== Restore wszystkich projektów ===" find . -name "*.csproj" -type f -exec dotnet restore "{}" \; @@ -27,8 +35,7 @@ steps: commands: - | set -euf - CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB" - cd "$CODE_DIR" + cd "${CI_WORKSPACE}" echo "=== Uruchamianie testów ===" dotnet test --no-restore --configuration Release --logger "trx" depends_on: [restore] @@ -38,8 +45,28 @@ steps: commands: - | set -euf - CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB" - cd "$CODE_DIR" + cd "${CI_WORKSPACE}" + echo "=== Instalacja MinVer CLI ===" + dotnet tool install --tool-path /tmp/minver minver-cli + echo "=== Obliczona wersja przez MinVer ===" + MINVER_VERSION=$(/tmp/minver/minver \ + --auto-increment patch \ + --minimum-major-minor 2.0 \ + --default-pre-release-identifiers alpha.0 \ + --verbosity info) + + echo "Wersja: $MINVER_VERSION" + + mkdir -p nupkg + echo "=== Pełniejsze fetch git (unshallow + tags) ===" + git fetch --prune --unshallow || echo "Już full clone – OK" + git fetch --tags + + # Diagnostyka – sprawdź czy tag jest widoczny + echo "=== Dostępne tagi ===" + git tag -l + echo "=== Aktualny commit i opis ===" + git describe --tags --always --dirty echo "=== Diagnostyka projektów ===" find . -name "*.csproj" -type f | sort mkdir -p nupkg @@ -48,7 +75,10 @@ steps: if grep -q '' "$csproj"; then PROJECT_NAME=$(basename "$csproj" .csproj) echo "→ Pakuję $PROJECT_NAME ($csproj)" - dotnet pack "$csproj" --configuration Release -o "$CODE_DIR/nupkg" + dotnet pack "$csproj" \ + --configuration Release \ + -o "./nupkg" \ + /p:PackageVersion=$MINVER_VERSION else PROJECT_NAME=$(basename "$csproj" .csproj) echo "→ Pomijam $PROJECT_NAME – brak (nie jest to biblioteka NuGet)" @@ -66,12 +96,9 @@ steps: commands: - | set -euf - CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB" - cd "$CODE_DIR" - + cd "${CI_WORKSPACE}" echo "=== Test połączenia z BaGetter ===" curl -f http://baget:80/v3/index.json || echo "Nie można połączyć się z BaGetter!" - # Tworzymy minimalny NuGet.Config tylko po to, żeby odblokować HTTP dla nazwanego źródła cat < NuGet.Config @@ -83,32 +110,25 @@ steps: EOF - echo "=== Użyty NuGet.Config (tylko do odblokowania HTTP) ===" cat NuGet.Config - echo "=== Publikacja pakietów do BaGetter ===" find ./nupkg -name "*.nupkg" -type f | while read pkg; do echo "→ Push $(basename "$pkg")" dotnet nuget push "$pkg" \ --source "BaGet" \ - --api-key "hfsa853nc9vfap53285ybndfahi58325hie242dsafa954" \ + --api-key "$BAGETTER_API_KEY" \ --skip-duplicate done - echo "Wszystkie pakiety DataModel opublikowane w BaGetter!" depends_on: [pack-datamodels] build-and-publish-apps: image: mcr.microsoft.com/dotnet/sdk:latest - environment: - DEPLOY_SSH_KEY: - from_secret: deploy_ssh_key commands: - | set -euf - CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB" - cd "$CODE_DIR" + cd "${CI_WORKSPACE}" echo "=== Ponowny restore aplikacji (z najnowszymi pakietami z BaGetter) ===" find . -name "*.csproj" -type f -exec dotnet restore "{}" \; echo "=== Publish aplikacji ===" @@ -122,7 +142,7 @@ steps: continue fi echo "→ Publish $PROJECT_NAME ($csproj)" - dotnet publish "$csproj" --no-restore -c Release -o "$CODE_DIR/publish-$PROJECT_NAME" + dotnet publish "$csproj" --no-restore -c Release -o "./publish-$PROJECT_NAME" # ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←← # Tu wstaw swój kod deployu (rsync/ssh itp.) # ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←← @@ -131,4 +151,4 @@ steps: fi done echo "Pipeline zakończony pomyślnie!" - depends_on: [publish-datamodels-to-baget] \ No newline at end of file + depends_on: [publish-datamodels-to-baget] diff --git a/FaKrosnoEfDataModel/FaKrosnoEfDataModel.csproj b/FaKrosnoEfDataModel/FaKrosnoEfDataModel.csproj index ab4a415..d3a217e 100644 --- a/FaKrosnoEfDataModel/FaKrosnoEfDataModel.csproj +++ b/FaKrosnoEfDataModel/FaKrosnoEfDataModel.csproj @@ -10,6 +10,7 @@ enable patch 1.0 + false diff --git a/OrdersManagementDataModel/OrdersManagementDataModel.csproj b/OrdersManagementDataModel/OrdersManagementDataModel.csproj index a159008..3549603 100644 --- a/OrdersManagementDataModel/OrdersManagementDataModel.csproj +++ b/OrdersManagementDataModel/OrdersManagementDataModel.csproj @@ -5,6 +5,13 @@ DataModel enable enable + + OrdersManagementDataModel + Piotr Kus + OrdersManagement Entity Framework Data Model + patch + 1.0 + false diff --git a/SytelineSaAppEfDataModel/SytelineSaAppEfDataModel.csproj b/SytelineSaAppEfDataModel/SytelineSaAppEfDataModel.csproj index 1e23ae8..becf56a 100644 --- a/SytelineSaAppEfDataModel/SytelineSaAppEfDataModel.csproj +++ b/SytelineSaAppEfDataModel/SytelineSaAppEfDataModel.csproj @@ -12,6 +12,7 @@ Syteline Entity Framework Data Model patch 1.0 + false