Skip to content

Commit

Permalink
#100 restructuring pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
maythamfahmi committed Nov 3, 2024
1 parent fc68487 commit 03e5f91
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 123 deletions.
72 changes: 45 additions & 27 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,54 @@ name: "2. Continuous Deployment"

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
branches:
- "main"
- "version3"
- "feature/*"
- "bugfix/*"
- "hotfix/*"
- "!feature/ci*"
paths-ignore:
- "**/README.md"
pull_request:
branches:
- "main"
- "version3"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
NAME: "DContinuous Deployment"

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Verify commit exists in origin/main
run: git branch --remote --contains | grep origin/main
- name: Extract release notes
run: |
git log --pretty=format:'%d %s' ${GITHUB_REF} | perl -pe 's| \(.*tag: v(\d+.\d+.\d+(-preview\d{3})?)(, .*?)*\)|\n## \1\n|g' > RELEASE-NOTES
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Set VERSION variable from tag
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
- name: Build
run: dotnet build --configuration Release /p:Version=${VERSION}
- name: Test
run: dotnet test --configuration Release /p:Version=${VERSION} --no-build
- name: Pack
run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output .
- name: Push
run: dotnet nuget push CryptoNet.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_TOKEN}
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
- name: bash-version
run: echo "::add-mask::$NAME"

# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Verify commit exists in origin/main
# run: git branch --remote --contains | grep origin/main
# - name: Extract release notes
# run: |
# git log --pretty=format:'%d %s' ${GITHUB_REF} | perl -pe 's| \(.*tag: v(\d+.\d+.\d+(-preview\d{3})?)(, .*?)*\)|\n## \1\n|g' > RELEASE-NOTES
# - name: Setup .NET
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: 8.0.x
# - name: Set VERSION variable from tag
# run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV
# - name: Build
# run: dotnet build --configuration Release /p:Version=${VERSION}
# - name: Test
# run: dotnet test --configuration Release /p:Version=${VERSION} --no-build
# - name: Pack
# run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output .
# - name: Push
# run: dotnet nuget push CryptoNet.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_TOKEN}
# env:
# NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
31 changes: 19 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
pull_request:
branches:
- "main"
- "version3"
workflow_dispatch:

jobs:
build:
Expand All @@ -24,20 +26,25 @@ jobs:
runs-on: ${{ matrix.os }}

timeout-minutes: 15
env:
NAME: "Continuous Integration"

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: bash-version
run: echo "::add-mask::$NAME"

# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# - name: Setup .NET
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: 8.0.x

- name: Build
run: dotnet build --configuration Release
# - name: Build
# run: dotnet build --configuration Release

- name: Test
run: dotnet test --configuration Release --no-build
# - name: Test
# run: dotnet test --configuration Release --no-build
117 changes: 65 additions & 52 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,75 @@ on:
- "feature/*"
- "bugfix/*"
- "hotfix/*"
- "!feature/ci*"
paths-ignore:
- "**/README.md"
pull_request:
branches:
- "main"
- "version3"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

env:
NAME: "Code Coverage"

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Install ReportGenerator tool
run: dotnet tool install --global dotnet-reportgenerator-globaltool

- name: Restore dependencies
run: dotnet restore

- name: Build the solution
run: dotnet build --no-restore

- name: Run tests and collect code coverage
run: dotnet test --no-build --collect:"XPlat Code Coverage"

- name: Generate code coverage report
run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:"HtmlInline_AzurePipelines;Badges"

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: coverage

- name: Upload coverage badge
uses: actions/upload-artifact@v4
with:
name: code-coverage-badge
path: coverage/badge_linecoverage.svg

- name: Create coverage badge
run: cp coverage/badge_linecoverage.svg ./coverage-badge.svg

- name: Print Directory Structure
uses: FiorelaCiroku/XDTesting-Print-Directory-Structure@v1.0.2

- name: Commit coverage badge
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add coverage-badge.svg
if git diff-index --cached --name-only HEAD | grep -vsxF coverage-badge.svg; then
git commit -m 'Update coverage badge'
git push
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: bash-version
run: echo "::add-mask::$NAME"

# - name: Checkout repository
# uses: actions/checkout@v4

# - name: Setup .NET
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: 8.0.x

# - name: Install ReportGenerator tool
# run: dotnet tool install --global dotnet-reportgenerator-globaltool

# - name: Restore dependencies
# run: dotnet restore

# - name: Build the solution
# run: dotnet build --no-restore

# - name: Run tests and collect code coverage
# run: dotnet test --no-build --collect:"XPlat Code Coverage"

# - name: Generate code coverage report
# run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage" -reporttypes:"HtmlInline_AzurePipelines;Badges"

# - name: Upload coverage report
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-report
# path: coverage

# - name: Upload coverage badge
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-badge
# path: coverage/badge_linecoverage.svg

# - name: Create coverage badge
# run: cp coverage/badge_linecoverage.svg ./coverage-badge.svg

# - name: Print Directory Structure
# uses: FiorelaCiroku/XDTesting-Print-Directory-Structure@v1.0.2

# - name: Commit coverage badge
# run: |
# git config --global user.name 'github-actions[bot]'
# git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# git add coverage-badge.svg
# if git diff-index --cached --name-only HEAD | grep -vsxF coverage-badge.svg; then
# git commit -m 'Update coverage badge'
# git push
# fi
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79 changes: 47 additions & 32 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
name: "5. Deploy static content to Pages"

on:
# Runs on pushes targeting the default branch
push:
branches: ["main", "version3"]

# Allows you to run this workflow manually from the Actions tab
branches:
- "main"
- "version3"
- "feature/*"
- "bugfix/*"
- "hotfix/*"
- "!feature/ci*"
paths-ignore:
- "**/README.md"
pull_request:
branches:
- "main"
- "version3"
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand All @@ -28,32 +37,38 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

env:
NAME: "Deploy static content to Pages"

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"

- name: Install DocFX
run: dotnet tool install -g docfx

- name: Build DocFX Documentation
run: |
docfx metadata
docfx build docfx.json -o _site
- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: "./_site"

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: bash-version
run: echo "::add-mask::$NAME"

# - name: Checkout
# uses: actions/checkout@v4

# - name: Setup .NET
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: "8.0.x"

# - name: Install DocFX
# run: dotnet tool install -g docfx

# - name: Build DocFX Documentation
# run: |
# docfx metadata
# docfx build docfx.json -o _site

# - name: Setup Pages
# uses: actions/configure-pages@v5

# - name: Upload artifact
# uses: actions/upload-pages-artifact@v3
# with:
# # Upload entire repository
# path: "./_site"

# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v4

0 comments on commit 03e5f91

Please sign in to comment.