Skip to content

Commit 362cf03

Browse files
authored
Add initial release github action (#133)
1 parent 71900b7 commit 362cf03

File tree

6 files changed

+101
-7
lines changed

6 files changed

+101
-7
lines changed

.github/workflows/ci.yml renamed to .github/workflows/prerelease.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
name: CI
1+
name: Pre-release main branch
22

33
on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- "*.*.*"
97

108
permissions:
119
contents: read

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Pre-release main branch
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
packages: write
10+
11+
jobs:
12+
containers:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
full-version: ${{ steps.bootstrap.outputs.full-version }}
16+
major-version: ${{ steps.bootstrap.outputs.major-version }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Bootstrap Action Workspace
22+
id: bootstrap
23+
uses: ./.github/actions/bootstrap
24+
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
33+
- name: Publish Containers
34+
run: ./build.sh publishcontainers
35+
36+
release:
37+
needs: [containers]
38+
strategy:
39+
matrix:
40+
os: [ ubuntu-latest, windows-latest, macos-latest ]
41+
runs-on: ${{ matrix.os }}
42+
outputs:
43+
full-version: ${{ steps.bootstrap.outputs.full-version }}
44+
major-version: ${{ steps.bootstrap.outputs.major-version }}
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Bootstrap Action Workspace
50+
id: bootstrap
51+
uses: ./.github/actions/bootstrap
52+
53+
- name: Publish Binaries
54+
run: ./build.sh publishzip
55+
56+
- name: Attach Distribution to release
57+
env:
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: gh release upload ${{ github.ref_name }} .artifacts/publish/docs-builder/release/*.zip

build/BuildInformation.fs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module BuildInformation
66

77
open System
88
open System.IO
9+
open System.Runtime.InteropServices
910
open System.Threading
1011
open System.Xml.Linq
1112
open System.Xml.XPath
@@ -63,8 +64,24 @@ type OS =
6364
| OSX | Windows | Linux
6465
with
6566
static member Current =
66-
match int Environment.OSVersion.Platform with
67-
| 4 | 128 -> Linux
68-
| 6 -> OSX
69-
| _ -> Windows
67+
match 1 with
68+
| _ when RuntimeInformation.IsOSPlatform OSPlatform.OSX -> OSX
69+
| _ when RuntimeInformation.IsOSPlatform OSPlatform.Windows -> Windows
70+
| _ -> Linux
71+
72+
static member Name =
73+
match OS.Current with
74+
| Linux -> "linux"
75+
| OSX -> "mac"
76+
| Windows -> "win"
77+
78+
static member Arch =
79+
match RuntimeInformation.ProcessArchitecture with
80+
| Architecture.X86 -> "x86"
81+
| Architecture.X64 -> "x64"
82+
| Architecture.Arm -> "arm"
83+
| Architecture.Arm64 -> "arm64"
84+
| _ -> "unknown"
85+
86+
7087

build/CommandLine.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Build =
2525
| [<CliPrefix(CliPrefix.None);SubCommand>] Publish
2626
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishBinaries
2727
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishContainers
28+
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishZip
2829

2930
| [<CliPrefix(CliPrefix.None);SubCommand>] ReleaseNotes
3031
| [<CliPrefix(CliPrefix.None);SubCommand>] Release
@@ -51,6 +52,7 @@ with
5152
| PristineCheck
5253
| PublishBinaries
5354
| PublishContainers
55+
| PublishZip
5456
| ValidateLicenses
5557
| ReleaseNotes
5658
| Compile

build/Targets.fs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ let private pristineCheck (arguments:ParseResults<Build>) =
5757
let private publishBinaries _ =
5858
exec { run "dotnet" "publish" "src/docs-builder/docs-builder.csproj" }
5959
exec { run "dotnet" "publish" "src/docs-generator/docs-generator.csproj" }
60+
Zip.zip
61+
".artifacts/publish/docs-builder/release"
62+
$"docs-builder-%s{OS.Name}-{OS.Arch}.zip"
63+
[".artifacts/publish/docs-builder/release/docs-builder"]
64+
65+
let private publishZip _ =
66+
exec { run "dotnet" "publish" "src/docs-builder/docs-builder.csproj" }
67+
let binary = match OS.Current with Windows -> "docs-builder.exe" | _ -> "docs-builder"
68+
Zip.zip
69+
".artifacts/publish/docs-builder/release"
70+
$".artifacts/publish/docs-builder/release/docs-builder-%s{OS.Name}-{OS.Arch}.zip"
71+
[
72+
$".artifacts/publish/docs-builder/release/%s{binary}";
73+
".artifacts/publish/docs-builder/release/LICENSE.txt";
74+
".artifacts/publish/docs-builder/release/NOTICE.txt"
75+
]
6076

6177
let private publishContainers _ =
6278

@@ -155,6 +171,7 @@ let Setup (parsed:ParseResults<Build>) =
155171
| PristineCheck -> Build.Step pristineCheck
156172
| PublishBinaries -> Build.Step publishBinaries
157173
| PublishContainers -> Build.Step publishContainers
174+
| PublishZip -> Build.Step publishZip
158175
| ValidateLicenses -> Build.Step validateLicenses
159176
| ReleaseNotes -> Build.Step generateReleaseNotes
160177

build/build.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageReference Include="Octokit" Version="13.0.1" />
1212
<PackageReference Include="Proc.Fs" Version="0.9.1" />
1313
<PackageReference Include="Fake.Tools.Git" Version="6.1.3" />
14+
<PackageReference Include="Fake.IO.Zip" Version="6.1.3" />
1415
<PackageReference Remove="FSharp.Core"/>
1516
<PackageReference Include="FSharp.Core" Version="9.0.100" />
1617
</ItemGroup>

0 commit comments

Comments
 (0)