Skip to content
This repository was archived by the owner on Apr 14, 2023. It is now read-only.

Commit ccfb551

Browse files
committedAug 7, 2022
Auto-update year and package version
1 parent 83ca162 commit ccfb551

File tree

5 files changed

+102
-3
lines changed

5 files changed

+102
-3
lines changed
 

‎.github/workflows/build.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build Documentation
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
working-directory: ./Documentation
17+
18+
steps:
19+
- uses: actions/checkout@v1
20+
- uses: actions/setup-dotnet@v1
21+
- name: Build
22+
run: dotnet fsi build.fsx
23+
- name: Upload GitHub Pages Artifact
24+
uses: actions/upload-pages-artifact@v1
25+
26+
deploy_pages:
27+
needs: build
28+
if: github.ref_name == 'main'
29+
30+
permissions:
31+
pages: write
32+
id-token: write
33+
34+
environment:
35+
name: github-pages
36+
url: ${{ steps.deployment.outputs.page_url }}
37+
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v1

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/_site

‎build.fsx

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
open System.IO
2+
open System.Net.Http
3+
open System.Net.Http.Json
4+
open System.Text.Json
5+
open System
6+
7+
let outputDirectory = "_site"
8+
let indexHtml = "index.html"
9+
10+
let getLatestPackageVersion package =
11+
async {
12+
use httpClient = new HttpClient()
13+
let! document = httpClient.GetFromJsonAsync<JsonDocument>($"https://api-v2v3search-0.nuget.org/query?q={package}&skip=0&take=1&prerelease=false&semVerLevel=2.0.0") |> Async.AwaitTask
14+
return (document.RootElement.GetProperty("data")[0]).GetProperty("version").GetString()
15+
}
16+
17+
let getLatestFunckyVersion() = getLatestPackageVersion "Funcky"
18+
19+
let renderIndexHtml (template: string, packageVersion, year) =
20+
template
21+
.Replace("{{PackageVersion}}", packageVersion)
22+
.Replace("{{Year}}", year.ToString())
23+
24+
let writeIndexHtml() =
25+
let version = getLatestFunckyVersion() |> Async.RunSynchronously
26+
let indexHtmlContents = renderIndexHtml(File.ReadAllText(indexHtml), version, DateTime.Today.Year)
27+
File.WriteAllText(Path.Combine(outputDirectory, indexHtml), contents = indexHtmlContents)
28+
29+
let copyFileToOutput source =
30+
let relativePath = Path.GetRelativePath(relativeTo = Environment.CurrentDirectory, path = source)
31+
let target = Path.Combine(outputDirectory, relativePath)
32+
Directory.CreateDirectory(Path.GetDirectoryName(target)) |> ignore
33+
File.Copy(source, target, overwrite = true)
34+
35+
let isFileInOutputDirectory path =
36+
let absoluteTargetPath = Path.GetFullPath(outputDirectory) + Path.DirectorySeparatorChar.ToString()
37+
let absolutePath = Path.GetFullPath(path)
38+
absolutePath.StartsWith(absoluteTargetPath)
39+
40+
let copyToOutput (pattern) =
41+
Directory.GetFiles(Environment.CurrentDirectory, searchPattern = pattern, searchOption = SearchOption.AllDirectories)
42+
|> Seq.where (fun p -> not (isFileInOutputDirectory p))
43+
|> Seq.iter copyFileToOutput
44+
45+
Directory.CreateDirectory(outputDirectory)
46+
writeIndexHtml()
47+
copyToOutput("fonts/*.woff2")
48+
copyToOutput("icons/*.svg")
49+
copyToOutput("*.css")
50+
copyToOutput("*.js")

‎global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "7.0.100-preview.6.22352.1",
4+
"rollForward": "feature"
5+
}
6+
}

‎index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ <h2>Getting started</h2>
8686
</ul>
8787

8888
<div id="panel-dotnet-cli" role="tabpanel" aria-labelledby="tab-dotnet-cli" class="panel">
89-
<code>dotnet add package Funcky --version 2.7.1</code>
89+
<code>dotnet add package Funcky --version {{PackageVersion}}</code>
9090
</div>
9191

9292
<div id="panel-package-refererence" role="tabpanel" aria-labelledby="tab-package-refererence" class="panel">
93-
<code>&lt;PackageReference Include="Funcky" Version="2.7.1" /&gt;</code>
93+
<code>&lt;PackageReference Include="Funcky" Version="{{PackageVersion}}" /&gt;</code>
9494
</div>
9595
</div>
9696
</div>
9797
</section>
9898
</main>
9999
<footer>
100-
<div class="_container">© 2022 Polyadic.</div>
100+
<div class="_container">© {{Year}} Polyadic.</div>
101101
</footer>
102102
<script type="module" src="tabs.js"></script>
103103
</body>

0 commit comments

Comments
 (0)
This repository has been archived.