Skip to content

Improved setup docs (#116) #937

Improved setup docs (#116)

Improved setup docs (#116) #937

Workflow file for this run

name: .NET Core
on: [push, pull_request]
jobs:
build:
# This obtained from: https://docs.github.com/en/free-pro-team@latest/actions/guides/creating-postgresql-service-containers
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
permissions:
packages: write
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Add mapping of port 5432 --> 5432... Is this all we need?
- 5432:5432
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
# As usual, obtained from: https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/5.0/releases.json
dotnet-version: "6.0.100"
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
# As usual, obtained from: https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/5.0/releases.json
dotnet-version: "3.1.404"
- name: Setup PostgreSQL DB Test Connection String
run: dotnet user-secrets set "ConnectionStrings:Test" "User ID=postgres;Password=postgres;Host=127.0.0.1;Port=5432;" --project "./src/Hive"
- name: Log in to package source
shell: pwsh
env:
REPO_OWNER: ${{ github.repository_owner }}
run: |
dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} `
--store-password-in-clear-text --name github "https://nuget.pkg.github.com/$($env:REPO_OWNER)/index.json"
- name: Install dependencies
run: dotnet restore -p:Configuration=Release -clp:NoSummary
- name: Build
run: dotnet build --no-restore -c Release -clp:NoSummary
- name: Test
run: dotnet test --no-restore -c Release -clp:NoSummary
- name: Pack
id: pack
shell: pwsh
env:
CURRENT_BRANCH: ${{ steps.branch-name.outputs.current_branch }}
GH_RUN_ID: ${{ github.run_number }}.${{ github.run_attempt }}
run: |
$branch_name = $env:CURRENT_BRANCH -replace "/", "."
$is_pr = "${{ steps.branch-name.outputs.is_default != 'true' }}" -eq "true"
$is_master = $branch_name -eq "master"
if ($is_pr) {
$branch_name = ".pr.$branch_name"
echo "::set-output name=push::true"
} elseif ($is_master) {
$branch_name = ""
echo "::set-output name=push::true"
} else {
$branch_name = ".$branch_name"
echo "::set-output name=push::false"
}
.\buildPackages.ps1 -c Release "-clp:NoSummary" "-p:IncludeSymbols=true" "-p:BuildRelease=true" `
"-p:VersionSuffix=gh$($env:GH_RUN_ID)$($branch_name)+$(git rev-parse --short "$env:GITHUB_SHA")"
- name: Push packages
if: steps.pack.outputs.push == 'true' # runs only when pack says to
shell: pwsh
run: dotnet nuget push "artifacts/packages/Release/*.nupkg" --source "github" --api-key ${{ secrets.GITHUB_TOKEN }}