Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 43 additions & 18 deletions .github/workflows/build-snow.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,58 @@
name: Build Snow
# compile Sandra.Snow binary in release mode and publish as artifact "Snow"

on:
push:
branches: [ "master" ]
paths:
- 'src/**'
- '.github/workflows/build-snow.yml'
pull_request:
branches: [ "master" ]
workflow_dispatch:

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: 1

jobs:
build:

runs-on: windows-latest
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
include:
- os: windows-latest
runtime: win-x64
- os: ubuntu-latest
runtime: linux-x64
- os: macos-latest
runtime: osx-arm64
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.5
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1.1
- name: Restore Packages
run: nuget restore src/Sandra.Snow.sln
- name: Build solution
run: msbuild src/Sandra.Snow.sln -t:rebuild -property:Configuration=Release
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3.1.3
- uses: actions/checkout@v4

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

- name: Restore dependencies
run: dotnet restore Sandra.Snow.sln

- name: Build
run: dotnet build Sandra.Snow.sln --configuration Release --no-restore

- name: Run tests
run: dotnet test Sandra.Snow.sln --configuration Release --no-build --verbosity normal

- name: Publish CLI
run: dotnet publish src/Snow.Cli/Snow.Cli.csproj --configuration Release --runtime ${{ matrix.runtime }} -o ./publish/${{ matrix.runtime }}

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: Snow
# A file, directory or wildcard pattern that describes what to upload
path: src/Snow/bin/Release
name: Snow-${{ matrix.runtime }}
path: ./publish/${{ matrix.runtime }}
95 changes: 53 additions & 42 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Publish Website
# publish SnowSite to the repo set in vars.WEBSITE_REPO, using the pat defined in secrets.WEBSITE_PAT
# note that this action overrides the output paths set in the snow config file

on:
on:
push:
paths:
- 'SnowSite/**'
Expand All @@ -17,78 +15,91 @@ env:
YAML_PATH: .github/workflows/publish-website.yml
IS_WEBSITE_REPO_SET: ${{ vars.WEBSITE_REPO != null }}
IS_WEBSITE_PAT_SET: ${{ secrets.WEBSITE_PAT != null }}

jobs:
publish:
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Check WEBSITE_REPO var
if: ${{ env.IS_WEBSITE_REPO_SET == 'false' }}
shell: pwsh
shell: bash
run: |
"::warning file=$env:YAML_PATH::Mandatory repo variable WEBSITE_REPO is not set."
echo "::warning file=$YAML_PATH::Mandatory repo variable WEBSITE_REPO is not set."

- name: Check WEBSITE_PAT secret
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' && env.IS_WEBSITE_PAT_SET == 'false' }}
shell: pwsh
shell: bash
run: |
"::error file=$env:YAML_PATH::Mandatory repo secret WEBSITE_PAT is not set."
echo "::error file=$YAML_PATH::Mandatory repo secret WEBSITE_PAT is not set."

- name: Checkout SnowSite
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
sparse-checkout: SnowSite
path: doc

- name: Checkout Website
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ vars.WEBSITE_REPO }}
path: website
token: ${{ secrets.WEBSITE_PAT }}


- name: Setup .NET
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'

- name: Download Snow artifact
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }}
uses: dawidd6/action-download-artifact@v2
uses: dawidd6/action-download-artifact@v6
with:
workflow: build-snow.yml

- name: run Snow
name: Snow-linux-x64
path: Snow

- name: Run Snow
if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }}
shell: pwsh
shell: bash
run: |
$ErrorActionPreference = 'Stop'
$blogDir = (mkdir ".\website" -force).FullName
$docDir = ".\doc\SnowSite"
set -e
blogDir=$(mkdir -p ./website && cd ./website && pwd)
docDir="./doc/SnowSite"

"Configuring git..."
echo "Configuring git..."

pushd $docDir
$lastMessage = git log -1 --pretty=%B | Select-Object -First 1
$lastUserName = git log -1 --pretty=format:'%an' | Select-Object -First 1
$lastUserEamil = git log -1 --pretty=format:'%ae' | Select-Object -First 1
cd "$docDir"
lastMessage=$(git log -1 --pretty=%B | head -1)
lastUserName=$(git log -1 --pretty=format:'%an' | head -1)
lastUserEmail=$(git log -1 --pretty=format:'%ae' | head -1)

git config --global user.name "github actions bot (on behalf of $lastUserName)"
git config --global user.email $lastUserEamil
git config --global user.email "$lastUserEmail"
git config --global core.autocrlf false
popd
cd -

"Overriding output dirs to $blogDir"
$configPath = "$docDir\Snow\Snow.config.json"
$config = Get-Content $configPath | ConvertFrom-Json
$config.postsOutput = $blogDir
$config.pagesOutput = $blogDir
$config | ConvertTo-Json | Out-File $configPath
echo "Overriding output dirs to $blogDir"
configPath="$docDir/Snow/sandra.json"

# Update config with jq if available, otherwise use sed
if command -v jq &> /dev/null; then
jq --arg dir "$blogDir" '.postsOutput = $dir | .pagesOutput = $dir' "$configPath" > tmp.json && mv tmp.json "$configPath"
else
sed -i "s|\"postsOutput\":.*|\"postsOutput\": \"$blogDir\",|" "$configPath"
sed -i "s|\"pagesOutput\":.*|\"pagesOutput\": \"$blogDir\",|" "$configPath"
fi

"Running Snow..."
& Snow\Snow.exe "config=$configPath"
echo "Running Snow..."
chmod +x Snow/sandra
Snow/sandra build --path "$docDir/Snow"

Write-Output "Updating $blogdir..."
cd $blogdir
Get-Location #DEBUG
echo "Updating $blogDir..."
cd "$blogDir"
pwd

git add .
git commit -m "Publish: $lastMessage"
git push
git commit -m "Publish: $lastMessage" || echo "No changes to commit"
git push
66 changes: 42 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
*.[Cc]ache
# Build outputs
bin/
obj/
dist/
published/
build/

# IDE
.idea/
.vs/
*.user
*.suo
*.csproj.user
*.[Rr]e[Ss]harper*
*.sln.cache
*.suo
*.user
*.orig
*.pidb
*.userprefs

# OS
.DS_Store
deploy/
build/
[Bb]in/
[Dd]ebug/
[Oo]bj/
[Rr]elease/
Thumbs.db

# .NET
*.cache
*.log
packages/

# Test results
TestResults/
*.trx

# NuGet
*.nupkg

# Resharper
*.[Rr]e[Ss]harper*
_[Rr]e[Ss]harper.*/
*.docstates
*.tss

# NCrunch
*.ncrunchproject
*.ncrunchsolution

# dotCover
*.dotCover
Thumbs.db
.idea
Website/
packages/
SnowSite/Snow/Images/original-images/
SnowSite/Snow/_ignore/
*.log
src/Barbato/Snow/
.vs

# Other
*.orig
*.pidb
*.userprefs
*.docstates
*.tss
deploy/
Loading