Skip to content

Commit

Permalink
Merge pull request #14 from PinguApps/8-setup-cicd
Browse files Browse the repository at this point in the history
8 setup cicd
  • Loading branch information
pingu2k4 authored Jul 2, 2024
2 parents 52e0c77 + 08d4c75 commit 4e7d179
Show file tree
Hide file tree
Showing 25 changed files with 381 additions and 26 deletions.
33 changes: 33 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
change-template: "- [#$NUMBER] $TITLE - Thanks to @$AUTHOR!"
exclude-labels:
- automated
categories:
- title: "🚀 Features"
labels:
- "feature"
- "enhancement"
- title: "🐛 Bug Fixes"
labels:
- "bug"
- "fix"
- title: "📄 Documentation"
labels:
- "docs"
- "documentation"
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Changes
$CHANGES
94 changes: 94 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Workflow Test

on:
workflow_call:

env:
DOTNET_VERSION: '8.0'

jobs:
build:
name: Build & Test
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
issues: read
checks: write
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4

- name: Setup .NET
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Nuget Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore
run: dotnet restore

- name: Build
run: dotnet build -c Release --no-restore

- name: Test
run: dotnet test -c Release --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage"

- name: Combine Coverage Reports
uses: danielpalme/ReportGenerator-GitHub-Action@4924a48df5dbcdfbcbaef0cc1ad7d65d5aade7dd # 5.3.6
with:
reports: "**/*.cobertura.xml"
targetdir: "${{ github.workspace }}"
reporttypes: "Cobertura"
verbosity: "Info"
title: "Code Coverage"
tag: "${{ github.run_number }}_${{ github.run_id }}"
customSettings: ""
toolpath: "reportgeneratortool"

- name: Upload Combined Coverage XML
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: coverage
path: ${{ github.workspace }}/Cobertura.xml
retention-days: 5

- name: Publish Code Coverage Report
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: "Cobertura.xml"
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: "10 30"

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

- name: Upload Test Result Files
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: test-results
path: ${{ github.workspace }}/**/TestResults/**/*
retention-days: 5

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@30eadd5010312f995f0d3b3cff7fe2984f69409e # v2.16.1
if: always()
with:
trx_files: "${{ github.workspace }}/**/*.trx"
60 changes: 60 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Dev

on:
push:
branches: [ dev ]
release:
types: [ published ]
workflow_dispatch:

jobs:
build:
name: Build & Test
uses: ./.github/workflows/_test.yml
secrets: inherit
permissions:
pull-requests: write
contents: read
issues: read
checks: write

release:
name: Push to main
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
ref: dev

- name: Get Release Version
id: releaseVersion
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION:1}"
echo Clean Version: $VERSION
echo "version=$VERSION" >> ${GITHUB_OUTPUT}
- name: Create Pull Request
id: cpr
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
git fetch origin main
pr_number=$(gh pr create --base main --head dev --assignee pingu2k4 --fill --label automated --label release --title "Merge v${{ steps.releaseVersion.outputs.version }}" | grep -o 'https://github.com/[^/]\+/[^/]\+/pull/\([0-9]\+\)' | awk -F '/' '{print $NF}')
echo PR Number: $pr_number
echo "prNumber=$pr_number" >> ${GITHUB_OUTPUT}
- name: Merge Pull Request
if: ${{ steps.cpr.outputs.prNumber }}
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
gh pr merge ${{ steps.cpr.outputs.prNumber }} --auto --merge
98 changes: 98 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Main

on:
push:
branches: [ main ]
workflow_dispatch:

env:
CLIENT_PROJECT_NAME: PinguApps.Appwrite.Client
SERVER_PROJECT_NAME: PinguApps.Appwrite.Server
DOTNET_VERSION: '8.0'
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_KEY }}

jobs:
build:
name: Build & Test
uses: ./.github/workflows/_test.yml
secrets: inherit
permissions:
pull-requests: write
contents: read
issues: read
checks: write

push-nugets:
needs: build
name: Push Nuget's
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Setup .NET
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Get PR title
id: pr-title
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
PR_NUMBER=$(gh pr list --base main --state merged --limit 1 --json number --jq '.[0].number')
echo "PR Number: ${PR_NUMBER}"
PR_TITLE=$(gh pr view $PR_NUMBER --json title --jq '.title')
echo "PR Title: ${PR_TITLE}"
echo "PR_TITLE=${PR_TITLE}" >> $GITHUB_ENV
- name: Extract version from PR title
id: extract-version
run: |
VERSION=$(echo "${PR_TITLE}" | grep -oP 'v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?')
echo "Version: ${VERSION}"
VERSION_WITHOUT_V=${VERSION#v}
echo "Version -v: ${VERSION_WITHOUT_V}"
echo "VERSION=${VERSION_WITHOUT_V}" >> $GITHUB_ENV
- name: Create Nuget Packages
run: |
dotnet pack -c Release --verbosity normal --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$CLIENT_PROJECT_NAME/$CLIENT_PROJECT_NAME.csproj
dotnet pack -c Release --verbosity normal --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$SERVER_PROJECT_NAME/$SERVER_PROJECT_NAME.csproj
- name: Push to NuGet Feed
run: dotnet nuget push ./nupkg/*.{nupkg,snupkg} --source $NUGET_FEED --api-key $NUGET_KEY --skip-duplicate

sync:
name: Sync back to dev
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
ref: main

- name: Create Pull Request
id: cpr
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
git fetch origin dev
pr_number=$(gh pr create --base dev --head main --assignee pingu2k4 --fill --label automated --label sync | grep -o 'https://github.com/[^/]\+/[^/]\+/pull/\([0-9]\+\)' | awk -F '/' '{print $NF}')
echo PR Number: $pr_number
echo "prNumber=$pr_number" >> ${GITHUB_OUTPUT}
- name: Merge Pull Request
if: ${{ steps.cpr.outputs.prNumber }}
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
gh pr merge ${{ steps.cpr.outputs.prNumber }} --auto --merge
17 changes: 17 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PR

on:
pull_request:
branches:
- dev

jobs:
build:
name: Build & Test
uses: ./.github/workflows/_test.yml
secrets: inherit
permissions:
pull-requests: write
contents: read
issues: read
checks: write
17 changes: 17 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release Drafter

on:
push:
branches: [ dev ]

permissions:
contents: write
pull-requests: write

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 5 additions & 6 deletions PinguApps.Appwrite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6F37E87C-BABE-4727-ADF5-157E65C583ED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Client", "src\Appwrite.Client\PinguApps.Appwrite.Client.csproj", "{0B05C1CC-1D37-4BAB-B133-E8638F6C6439}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Client", "src\PinguApps.Appwrite.Client\PinguApps.Appwrite.Client.csproj", "{0B05C1CC-1D37-4BAB-B133-E8638F6C6439}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Playground", "src\Appwrite.Playground\PinguApps.Appwrite.Playground.csproj", "{EEB648E0-2054-4204-A0C1-CDC29FC63F4B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Playground", "src\PinguApps.Appwrite.Playground\PinguApps.Appwrite.Playground.csproj", "{EEB648E0-2054-4204-A0C1-CDC29FC63F4B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Server", "src\PinguApps.Appwrite.Server\PinguApps.Appwrite.Server.csproj", "{1E8A9E01-1E1A-4FA6-93AB-E1FA31500DF6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Shared", "src\PinguApps.Appwrite.Common\PinguApps.Appwrite.Shared.csproj", "{C02515BD-4CD9-4E0F-8831-A3AB0291AD1A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{187EBB4D-6799-492C-AAA7-518B2811D800}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PinguApps.Appwrite.Server.Tests", "tests\PinguApps.Appwrite.Server.Tests\PinguApps.Appwrite.Server.Tests.csproj", "{11D16276-FCD0-404D-BA8A-5CBEAF494CB0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Server.Tests", "tests\PinguApps.Appwrite.Server.Tests\PinguApps.Appwrite.Server.Tests.csproj", "{11D16276-FCD0-404D-BA8A-5CBEAF494CB0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PinguApps.Appwrite.Client.Tests", "tests\PinguApps.Appwrite.Client.Tests\PinguApps.Appwrite.Client.Tests.csproj", "{71C1431E-8098-4B9B-9CFA-A49F77242C79}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Client.Tests", "tests\PinguApps.Appwrite.Client.Tests\PinguApps.Appwrite.Client.Tests.csproj", "{71C1431E-8098-4B9B-9CFA-A49F77242C79}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PinguApps.Appwrite.Tests.Shared", "tests\PinguApps.Appwrite.Tests.Shared\PinguApps.Appwrite.Tests.Shared.csproj", "{5AED345C-1E3E-4397-807C-8EFC22B786FA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PinguApps.Appwrite.Tests.Shared", "tests\PinguApps.Appwrite.Tests.Shared\PinguApps.Appwrite.Tests.Shared.csproj", "{5AED345C-1E3E-4397-807C-8EFC22B786FA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -34,7 +34,6 @@ Global
{EEB648E0-2054-4204-A0C1-CDC29FC63F4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEB648E0-2054-4204-A0C1-CDC29FC63F4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEB648E0-2054-4204-A0C1-CDC29FC63F4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEB648E0-2054-4204-A0C1-CDC29FC63F4B}.Release|Any CPU.Build.0 = Release|Any CPU
{1E8A9E01-1E1A-4FA6-93AB-E1FA31500DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E8A9E01-1E1A-4FA6-93AB-E1FA31500DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E8A9E01-1E1A-4FA6-93AB-E1FA31500DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 0 additions & 18 deletions src/Appwrite.Client/PinguApps.Appwrite.Client.csproj

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 4e7d179

Please sign in to comment.