Skip to content

Build command clears output directory before building (v0.14) #242

Build command clears output directory before building (v0.14)

Build command clears output directory before building (v0.14) #242

Workflow file for this run

name: .NET Core
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Calculate version
id: version
run: |
# Extract major.minor version from the Tool csproj file
BASE_VERSION=$(grep '<Version.*>' toolsrc/Chloroplast.Tool/Chloroplast.Tool.csproj | sed 's/.*<Version[^>]*>\([^<]*\)<\/Version>.*/\1/' | sed 's/-dev//' | cut -d. -f1,2)
VERSION="$BASE_VERSION.${{ github.run_number }}"
echo "package_version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION (base: $BASE_VERSION)"
- name: Install dependencies
run: dotnet restore toolsrc
- name: Build
run: dotnet build --configuration Release --no-restore toolsrc
- name: Test
run: dotnet test --no-restore --verbosity normal toolsrc
- name: Verify tool by building docs
run: |
cd docs
dotnet ../toolsrc/Chloroplast.Tool/bin/Release/net8.0/Chloroplast.Tool.dll build
echo "Documentation build completed successfully"
- name: Upload Documentation Artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: docs/out
- name: Pack Core
run: dotnet pack toolsrc/Chloroplast.Core/ --configuration Release --no-restore -p:Version=${{ steps.version.outputs.package_version }}
- name: Pack Tool
run: dotnet pack toolsrc/Chloroplast.Tool/ --configuration Release --no-restore -p:Version=${{ steps.version.outputs.package_version }}
- name: List packages
run: |
echo "Core packages:"
ls -la toolsrc/Chloroplast.Core/nupkg/
echo "Tool packages:"
ls -la toolsrc/Chloroplast.Tool/nupkg/
- name: Add private GitHub registry to NuGet
if: github.ref == 'refs/heads/main'
run: dotnet nuget add source https://nuget.pkg.github.com/WildernessLabs/index.json --name "github" --username WildernessLabs --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text
- name: Push Core package to GitHub registry
if: github.ref == 'refs/heads/main'
run: dotnet nuget push toolsrc/Chloroplast.Core/nupkg/*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
- name: Push Tool package to GitHub registry
if: github.ref == 'refs/heads/main'
run: dotnet nuget push toolsrc/Chloroplast.Tool/nupkg/*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
- name: Push Tool package to nuget.org registry
if: github.ref == 'refs/heads/main'
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push toolsrc/Chloroplast.Tool/nupkg/*.nupkg --source "nuget.org" --api-key $NUGET_API_KEY --skip-duplicate
deploy-docs:
if: github.ref == 'refs/heads/main'
needs: build-and-publish
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download Documentation Artifacts
uses: actions/download-artifact@v4
with:
name: documentation
path: ./docs-output
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: ./docs-output
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4