Skip to content

Commit

Permalink
chore: migrate build to GitHub Actions (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender authored Nov 9, 2023
1 parent 8589edc commit 24d4e8a
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 114 deletions.
105 changes: 0 additions & 105 deletions .github/build.main.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
name: "CodeQL"
name: "build"
run-name: Test CodeQL

on:
push:
branches: ["main"]
paths:
- 'src/**'
- 'tests/**'

pull_request:
branches: ["main"]
paths:
- 'src/**'
- 'tests/**'
- ".github/workflows/build-codeql.yml"

schedule:
- cron: "16 12 * * 3"

jobs:
analyze:
name: analyze
name: CodeQL
runs-on: ubuntu-latest
permissions:
actions: read
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/build-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "build"
run-name: Build examples

on:
push:
branches: ["main"]
paths:
- docs/examples/**

pull_request:
branches: ["main"]
paths:
- docs/examples/**
- ".github/workflows/build-examples.yml"

jobs:
build:
name: examples
runs-on: ubuntu-latest

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

- name: Build examples
run: >
dotnet build docs/examples/Examples.sln
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
80 changes: 80 additions & 0 deletions .github/workflows/build-indicators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: "build"
run-name: Test indicators

on:
push:
branches: ["main"]
paths:
- "src/**"

pull_request:
branches: ["main"]
paths:
- "src/**"
- ".github/workflows/build-indicators.yml"

jobs:

testing:
name: test indicators
runs-on: ubuntu-latest

steps:

- name: Clean workspace
run: |
rm -rf ./* || true
rm -rf ./.??* || true
- name: Checkout repository
uses: actions/checkout@v4

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"

- name: Build solution
run: >
dotnet build
--configuration Release
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Test indicators
run: >
dotnet test tests/indicators/Tests.Indicators.csproj
--configuration Release
--no-build
--verbosity normal
--logger trx
--collect:"XPlat Code Coverage"
--results-directory ./test-indicators
- name: Test other items
run: >
dotnet test tests/other/Tests.Other.csproj
--configuration Release
--no-build
--verbosity normal
--logger trx
--results-directory ./test-other
- name: Update tests summary
uses: bibipkins/[email protected]
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-title: ""
results-path: ./test-indicators/**/*.trx
coverage-path: ./test-indicators/**/coverage.cobertura.xml
coverage-type: cobertura
coverage-threshold: 95

- name: Save test results
uses: actions/upload-artifact@v3
with:
name: test-results
path: ./test-indicators
if: ${{ always() }}
109 changes: 109 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: "deploy"
run-name: Deploy to staging

concurrency:
group: staging
cancel-in-progress: true

on: [workflow_dispatch]

jobs:
build:
runs-on: ubuntu-latest
outputs:
nuget-version: "${{ steps.gitversion.outputs.nuGetVersion }}"
filename-nupkg: "Skender.Stock.Indicators.${{ steps.gitversion.outputs.nuGetVersion }}.nupkg"
filename-snupkg: "Skender.Stock.Indicators.${{ steps.gitversion.outputs.nuGetVersion }}.snupkg"

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

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: "5.x"
preferLatestVersion: true

- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
updateAssemblyInfo: true
useConfigFile: true
configFilePath: gitversion.yml

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-quality: "ga"

- name: Build library
run: >
dotnet build src/Indicators.csproj
--configuration Release
--property:Version=${{ steps.gitversion.outputs.nuGetVersion }}
--property:ContinuousIntegrationBuild=true
-warnAsError
- name: Pack for NuGet
run: >
dotnet pack src/Indicators.csproj
--configuration Release
--no-build
--include-symbols
--output NuGet
-p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersion }}
- name: Save NuGet package
uses: actions/upload-artifact@v3
with:
name: packages
path: NuGet

- name: Show version
run: |
{
echo "### Identified semantic version"
echo "| Variable | Value |"
echo "| --------------- | ----------------------------------------------- |"
echo "| Major | ${{ steps.gitversion.outputs.major }} |"
echo "| Minor | ${{ steps.gitversion.outputs.minor }} |"
echo "| Patch | ${{ steps.gitversion.outputs.patch }} |"
echo "| PreReleaseTag | ${{ steps.gitversion.outputs.preReleaseTag }} |"
echo "| MajorMinorPatch | ${{ steps.gitversion.outputs.majorMinorPatch }} |"
echo "| SemVer | ${{ steps.gitversion.outputs.semVer }} |"
echo "| NuGetVersion | ${{ steps.gitversion.outputs.nuGetVersion }} |"
} >> $GITHUB_STEP_SUMMARY
deploy:
needs: build
runs-on: ubuntu-latest

environment:
name: staging
url: "${{ vars.NUGET_DOWNLOAD_PREFIX }}${{ needs.build.outputs.nuget-version }}"

steps:
- uses: actions/setup-dotnet@v3
with:
source-url: ${{ vars.NUGET_PUBLISH_URL }}
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_TOKEN}}

- name: Download NuGet package
uses: actions/download-artifact@v3
with:
name: packages
path: NuGet

- name: Show publish preview
run: |
echo ${{ vars.NUGET_PUBLISH_URL }}
echo ${{ vars.NUGET_DOWNLOAD_PREFIX }}
echo "dotnet nuget push NuGet/*.nupkg"
echo ${{ needs.build.outputs.filename-nupkg }}
echo ${{ needs.build.outputs.filename-snupkg }}
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: test docs
name: docs
run-name: Test doc site a11y

on:
pull_request:
branches: [main]
paths:
- 'docs/**'
- ".github/workflows/docs-test-a11y.yml"

env:
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
testing:
name: a11y
name: test a11y
runs-on: ubuntu-latest

steps:
Expand Down
Loading

0 comments on commit 24d4e8a

Please sign in to comment.