From eb0c52f45d0d3fcc219675f89ae2ce57936af8f9 Mon Sep 17 00:00:00 2001 From: Robert Di Pardo Date: Sun, 25 Apr 2021 13:37:16 -0400 Subject: [PATCH] Make type providers usable in *.fsx scripts Package builds now generate a copy of FSharp.Data.DesignTime.dll This avoids the assembly path resolution problems reported in many places, for example: - fsprojects/FSharp.Data/issues/844 - dotnet/netcorecli-fsc/issues/16 - https://stackoverflow.com/q/3102472 Unfortunately we can't use any of the better solutions explained at dotnet/fsharp/issues/3303, since they only apply to full-fledged .NET projects, not scripts --- .gitattributes | 2 + .github/workflows/ci.yml | 9 ++-- .github/workflows/nuget.yml | 74 +++++++++++++++++++--------- .gitmodules | 5 +- CHANGELOG | 7 +++ README.md | 13 +++-- THIRD_PARTY | 5 ++ example/Fornax.Seo.Example/build | 2 +- example/Fornax.Seo.Example/build.cmd | 2 +- scripts/changelog | 5 ++ scripts/ci | 3 +- scripts/ci.cmd | 3 +- scripts/gendocs | 2 +- scripts/gendocs.cmd | 2 +- scripts/pack.cmd | 6 +-- scripts/release-notes.fsx | 2 +- src/FSharp.Data | 1 + src/Fornax.Seo/Directory.Build.props | 5 ++ src/Fornax.Seo/Fornax.Seo.fsproj | 27 +++++++--- 19 files changed, 123 insertions(+), 52 deletions(-) create mode 100755 scripts/changelog create mode 160000 src/FSharp.Data create mode 100644 src/Fornax.Seo/Directory.Build.props diff --git a/.gitattributes b/.gitattributes index f7e376c..16ca86a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,10 @@ * -text **.sln text eol=crlf **.fsproj text eol=crlf +**.props text eol=crlf **.cmd text eol=crlf **.bat text eol=crlf +scripts/changelog text eol=lf scripts/ci text eol=lf scripts/gendocs text eol=lf example/**/build text eol=lf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 326259e..4e8a427 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,8 @@ name: Unit Tests on: - push: - branches: - - !ma* pull_request: branches: - - '**' + - main jobs: unit_tests: runs-on: ubuntu-20.04 @@ -19,12 +16,12 @@ jobs: - name: Pre-test install uses: actions/setup-dotnet@v1.7.2 with: - dotnet-version: '5.0.102' + dotnet-version: '5.0.202' - name: Cache packages uses: actions/cache@v2.1.5 with: path: ~/.nuget/packages - key: ${{ runner.os }}-nuget-${{ hashFiles('test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj') }} + key: ${{ runner.os }}-nuget-${{ hashFiles('src/Fornax.Seo/Directory.Build.props') }} restore-keys: |- ${{ runner.os }}-nuget- ${{ runner.os }}- diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 7ae9168..74c2903 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -1,11 +1,11 @@ name: NuGet on: push: - tags: - - '**' + branches: + - main jobs: - test: - runs-on: ubuntu-20.04 + package: + runs-on: windows-latest env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true @@ -13,24 +13,24 @@ jobs: - uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Pre-test install + - name: Pre-build Install uses: actions/setup-dotnet@v1.7.2 with: - dotnet-version: '5.0.102' - - name: Cache packages - uses: actions/cache@v2.1.5 + dotnet-version: '5.0.202' + - name: Build package + run: scripts\pack + - name: Save package + uses: actions/upload-artifact@v2.2.3 with: - path: ~/.nuget/packages - key: ${{ runner.os }}-nuget-${{ hashFiles('src/Fornax.Seo/Fornax.Seo.fsproj') }} - restore-keys: |- - ${{ runner.os }}-nuget- - ${{ runner.os }}- - - name: Run tests - run: scripts/ci + name: Fornax.Seo.nupkg + path: release/*.nupkg + retention-days: 30 + if-no-files-found: error publish: - needs: test - runs-on: windows-latest + needs: package + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/') env: DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true @@ -38,21 +38,51 @@ jobs: - uses: actions/checkout@v2 with: submodules: 'recursive' + fetch-depth: 0 - name: Pre-build Install uses: actions/setup-dotnet@v1.7.2 with: - dotnet-version: '5.0.102' - - name: Release package + dotnet-version: '5.0.202' + - name: Cache packages + uses: actions/cache@v2.1.5 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('src/Fornax.Seo/Directory.Build.props') }} + restore-keys: |- + ${{ runner.os }}-nuget- + ${{ runner.os }}- + - name: Collect release info + run: |- + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + echo -e $(scripts/changelog) > release_notes.txt + - name: Retrieve package + uses: actions/download-artifact@v2.0.9 + id: fetch + with: + name: Fornax.Seo.nupkg + path: '~/release' + - name: Prepare release + uses: ncipollo/release-action@v1 + with: + artifacts: ${{ steps.fetch.outputs.download-path }}/*.nupkg + bodyFile: release_notes.txt + name: ${{ env.RELEASE_VERSION }} + draft: true + allowUpdates: true + artifactErrorsFailBuild: true + replacesArtifacts: true + token: ${{ secrets.GITHUB_TOKEN }} + - name: Publish release run: |- - scripts\gendocs - scripts\pack - # dotnet nuget push release\*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate + dotnet nuget push release/Fornax.Seo.*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate + scripts/gendocs - name: Publish docs uses: peaceiris/actions-gh-pages@v3.8.0 with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} enable_jekyll: false publish_dir: './output' + publish_branch: docs user_name: 'Fornax.Seo [action]' user_email: 'Fornax.Seo@users.noreply.github.com' commit_message: '${{ github.event.head_commit.message }}' diff --git a/.gitmodules b/.gitmodules index 0f546b6..b931f0d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "src/Fornax"] path = src/Fornax - url = https://github.com/ionide/Fornax.git + url = https://github.com/ionide/Fornax.git +[submodule "src/FSharp.Data"] + path = src/FSharp.Data + url = https://github.com/fsprojects/FSharp.Data.git diff --git a/CHANGELOG b/CHANGELOG index 14744b3..76d5bfe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,2 +1,9 @@ ## 0.1.0 Initial release + +## 0.1.0-a60fd1f +Start bundling FSharp.Data.DesignTime.dll since consuming F# scripts will be broken without it. +See, for example, + +## 0.1.0-d8291ee (DEPRECATED) +Initial preview release diff --git a/README.md b/README.md index 707403c..54f56ea 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![NuGet workflow status][]][NuGet Workflow] [![Test workflow status][]][Test Workflow] -SEO metadata generator for Fornax +A SEO meta tag generator for [Fornax](https://ionide.io/Tools/fornax.html) ## Goals @@ -19,7 +19,7 @@ SEO metadata generator for Fornax ## Usage example -- Install [Fornax](https://ionide.io/Tools/fornax.html) +- [Install Fornax](https://github.com/ionide/Fornax#installation) dotnet tool install fornax -g @@ -182,7 +182,13 @@ let layout (ctx: SiteContents) (active: string) (content: HtmlElement seq) = ## Development -_All platforms need a .NET SDK at version 5.0.102 or later_ +_All platforms need a .NET SDK at version 5.0.200 or later_ + +_Linux users should consider 5.0.202 the [safest minimum version][]_ + +Checkout the source tree and submodules: + + git clone --recursive https://github.com/rdipardo/Fornax.Seo ### Windows @@ -241,6 +247,7 @@ Distributed under the terms of the [Mozilla Public License Version 2.0][]. [structured data]: https://developers.google.com/search/docs/guides/intro-structured-data [absolute URLs]: https://stackoverflow.com/a/64830732 +[safest minimum version]: https://github.com/NuGet/Announcements/issues/56#issue-847215025 [the documentation]: https://heredocs.io/Fornax.Seo [Nuget version]: https://img.shields.io/nuget/vpre/Fornax.Seo?color=blueviolet&logo=nuget diff --git a/THIRD_PARTY b/THIRD_PARTY index 92a7ac0..1b58a48 100644 --- a/THIRD_PARTY +++ b/THIRD_PARTY @@ -5,3 +5,8 @@ Fornax ------ The Fornax CLI tool and libraries are distributed under the terms of the MIT License. More information is available at https://github.com/ionide/Fornax/blob/master/LICENSE.md + +FSharp.Data +------------ +FSharp.Data is distributed under the terms of the Apache License, Version 2.0. +More information is available at https://github.com/fsprojects/FSharp.Data/blob/master/LICENSE.md diff --git a/example/Fornax.Seo.Example/build b/example/Fornax.Seo.Example/build index 0134260..14bbee4 100755 --- a/example/Fornax.Seo.Example/build +++ b/example/Fornax.Seo.Example/build @@ -3,5 +3,5 @@ FORNAX_CMD=build if [ "$1" = "live" ]; then FORNAX_CMD=watch; fi dotnet tool restore --tool-manifest ../../src/Fornax/.config/dotnet-tools.json dotnet build /v:m ../../src/Fornax/src/Fornax/Fornax.fsproj -o ../bin -c Release -dotnet build /v:m -o _lib -c Release +dotnet build /v:m /p:nowarn="3218 3390" -o _lib -c Release dotnet ../bin/Fornax.dll $FORNAX_CMD diff --git a/example/Fornax.Seo.Example/build.cmd b/example/Fornax.Seo.Example/build.cmd index 40a45e7..f235232 100644 --- a/example/Fornax.Seo.Example/build.cmd +++ b/example/Fornax.Seo.Example/build.cmd @@ -4,6 +4,6 @@ SET "FORNAX_CMD=build" IF "%1"=="live" ( SET "FORNAX_CMD=watch" ) dotnet tool restore --tool-manifest ../../src/Fornax/.config/dotnet-tools.json dotnet build /v:m ../../src/Fornax/src/Fornax/Fornax.fsproj -o ../bin -c Release -dotnet build /v:m -o _lib -c Release +dotnet build /v:m /p:nowarn="3218 3390" -o _lib -c Release dotnet ../bin/Fornax.dll %FORNAX_CMD% ENDLOCAL diff --git a/scripts/changelog b/scripts/changelog new file mode 100755 index 0000000..94fc618 --- /dev/null +++ b/scripts/changelog @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +HEAD=$(git describe --always) +PREV_REF=$(git describe --always $HEAD)^ +PREV=$(git describe --always --abbrev=0 ${PREV_REF}) +git log --oneline ${PREV}..${HEAD} | awk '{printf("%s\\n",$0)}' diff --git a/scripts/ci b/scripts/ci index ab8a2b7..b471e87 100755 --- a/scripts/ci +++ b/scripts/ci @@ -1,6 +1,5 @@ #!/usr/bin/env bash -dotnet tool restore --tool-manifest src/Fornax/.config/dotnet-tools.json -dotnet test /v:m test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj +dotnet test /v:m /p:nowarn="3218 3390" test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj cd example/Fornax.Seo.Example ./build $1 cd ../.. diff --git a/scripts/ci.cmd b/scripts/ci.cmd index 9ae79a4..7e99036 100644 --- a/scripts/ci.cmd +++ b/scripts/ci.cmd @@ -1,6 +1,5 @@ @echo off -dotnet tool restore --tool-manifest src/Fornax/.config/dotnet-tools.json -dotnet test /v:m test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj +dotnet test /v:m /p:nowarn="3218 3390" test/Fornax.Seo.Tests/Fornax.Seo.Tests.fsproj cd example\Fornax.Seo.Example build %1 cd ..\.. diff --git a/scripts/gendocs b/scripts/gendocs index 426b206..0790f8a 100755 --- a/scripts/gendocs +++ b/scripts/gendocs @@ -6,7 +6,7 @@ if [ "$1" = "live" ]; then SITE_ROOT= fi dotnet tool restore -dotnet build src/Fornax.Seo/Fornax.Seo.fsproj -c Release +dotnet build /v:m /p:nowarn="3218 3390" src/Fornax.Seo/Fornax.Seo.fsproj -c Release cp ./README.md docs/index.md dotnet fsdocs $FORNAX_CMD --projects $(pwd)/src/Fornax.Seo/Fornax.Seo.fsproj \ diff --git a/scripts/gendocs.cmd b/scripts/gendocs.cmd index 03fa42b..2a0c0ff 100644 --- a/scripts/gendocs.cmd +++ b/scripts/gendocs.cmd @@ -7,7 +7,7 @@ IF "%1"=="live" ( SET SITE_ROOT= ) dotnet tool restore -dotnet build src/Fornax.Seo/Fornax.Seo.fsproj -c Release +dotnet build /v:m /p:nowarn="3218 3390" src/Fornax.Seo/Fornax.Seo.fsproj -c Release copy README.md docs\index.md dotnet fsdocs %FSDOCS_CMD% --projects %CD%/src/Fornax.Seo/Fornax.Seo.fsproj ^ diff --git a/scripts/pack.cmd b/scripts/pack.cmd index 69e5342..52aa953 100644 --- a/scripts/pack.cmd +++ b/scripts/pack.cmd @@ -13,17 +13,15 @@ FOR /F "tokens=* USEBACKQ" %%F IN (`type release\notes.txt`) DO ( SET "PackageReleaseNotes=%%F" ) -git describe >NUL +git describe --tags >NUL IF NOT %ERRORLEVEL% == 0 ( FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --short HEAD`) DO ( SET "BUILD_NUMBER=--version-suffix %%F" ) ) -dotnet tool restore --tool-manifest src/Fornax/.config/dotnet-tools.json dotnet restore src/Fornax.Seo/Fornax.Seo.fsproj -dotnet build --no-restore src/Fornax.Seo/Fornax.Seo.fsproj -c Release -o release -dotnet pack src/Fornax.Seo/Fornax.Seo.fsproj -c Release -o release %BUILD_NUMBER% +dotnet pack /v:m /p:nowarn="3218 3390" src/Fornax.Seo/Fornax.Seo.fsproj -c Release -o release %BUILD_NUMBER% :END ENDLOCAL diff --git a/scripts/release-notes.fsx b/scripts/release-notes.fsx index 08f8f1e..b4ab19a 100644 --- a/scripts/release-notes.fsx +++ b/scripts/release-notes.fsx @@ -19,5 +19,5 @@ try FileInfo(noteText).Directory.Create() File.WriteAllText(noteText, notes) - printfn "---\n%s\n---" <| (File.ReadAllText(noteText)).Replace("!NL!", "\n") + printfn "---\n%s\n---" <| (File.ReadAllText(noteText)).Replace("!NL!", Environment.NewLine) with exc -> printfn "%s" <| (sprintf "%s: %s" <| exc.GetType().Name <| exc.Message) diff --git a/src/FSharp.Data b/src/FSharp.Data new file mode 160000 index 0000000..311fa4b --- /dev/null +++ b/src/FSharp.Data @@ -0,0 +1 @@ +Subproject commit 311fa4bfce64dc4616813c8842c4d46f96802f08 diff --git a/src/Fornax.Seo/Directory.Build.props b/src/Fornax.Seo/Directory.Build.props new file mode 100644 index 0000000..7a9aaf1 --- /dev/null +++ b/src/Fornax.Seo/Directory.Build.props @@ -0,0 +1,5 @@ + + + 4.1.0 + + diff --git a/src/Fornax.Seo/Fornax.Seo.fsproj b/src/Fornax.Seo/Fornax.Seo.fsproj index 506b62e..145d29b 100644 --- a/src/Fornax.Seo/Fornax.Seo.fsproj +++ b/src/Fornax.Seo/Fornax.Seo.fsproj @@ -1,10 +1,10 @@ - + 0.1.0 alpha Robert Di Pardo Copyright (c) 2021 Robert Di Pardo and Contributors - SEO metadata generator for Fornax + A SEO meta tag generator for Fornax (https://ionide.io/Tools/fornax.html) https://github.com/rdipardo/Fornax.Seo git MPL-2.0 @@ -22,8 +22,8 @@ - - + + @@ -31,15 +31,28 @@ Fornax.Core.dll + + + true + FSharp.Data.DesignTime.dll + + $(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage - - 4 - + + + + + + + + + +