Skip to content

Commit

Permalink
Add initial release github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Jan 6, 2025
1 parent 30afb01 commit 6965ef4
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: CI
name: Pre-release main branch

on:
push:
branches:
- main
tags:
- "*.*.*"

permissions:
contents: read
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Pre-release main branch

on:
release:
types: [published]

permissions:
contents: read
packages: write

jobs:
containers:
runs-on: ubuntu-latest
outputs:
full-version: ${{ steps.bootstrap.outputs.full-version }}
major-version: ${{ steps.bootstrap.outputs.major-version }}

steps:
- uses: actions/checkout@v4

- name: Bootstrap Action Workspace
id: bootstrap
uses: ./.github/actions/bootstrap

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Publish Containers
run: ./build.sh publishcontainers

release:
needs: [containers]
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
outputs:
full-version: ${{ steps.bootstrap.outputs.full-version }}
major-version: ${{ steps.bootstrap.outputs.major-version }}

steps:
- uses: actions/checkout@v4

- name: Bootstrap Action Workspace
id: bootstrap
uses: ./.github/actions/bootstrap

- name: Publish Binaries
run: ./build.sh publishzip

- name: Attach Distribution to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} .artifacts/publish/docs-builder/release/*.zip
25 changes: 21 additions & 4 deletions build/BuildInformation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module BuildInformation

open System
open System.IO
open System.Runtime.InteropServices
open System.Threading
open System.Xml.Linq
open System.Xml.XPath
Expand Down Expand Up @@ -63,8 +64,24 @@ type OS =
| OSX | Windows | Linux
with
static member Current =
match int Environment.OSVersion.Platform with
| 4 | 128 -> Linux
| 6 -> OSX
| _ -> Windows
match 1 with
| _ when RuntimeInformation.IsOSPlatform OSPlatform.OSX -> OSX
| _ when RuntimeInformation.IsOSPlatform OSPlatform.Windows -> Windows
| _ -> Linux

static member Name =
match OS.Current with
| Linux -> "linux"
| OSX -> "mac"
| Windows -> "win"

static member Arch =
match RuntimeInformation.ProcessArchitecture with
| Architecture.X86 -> "x86"
| Architecture.X64 -> "x64"
| Architecture.Arm -> "arm"
| Architecture.Arm64 -> "arm64"
| _ -> "unknown"



2 changes: 2 additions & 0 deletions build/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Build =
| [<CliPrefix(CliPrefix.None);SubCommand>] Publish
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishBinaries
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishContainers
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PublishZip

| [<CliPrefix(CliPrefix.None);SubCommand>] ReleaseNotes
| [<CliPrefix(CliPrefix.None);SubCommand>] Release
Expand All @@ -51,6 +52,7 @@ with
| PristineCheck
| PublishBinaries
| PublishContainers
| PublishZip
| ValidateLicenses
| ReleaseNotes
| Compile
Expand Down
17 changes: 17 additions & 0 deletions build/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ let private pristineCheck (arguments:ParseResults<Build>) =
let private publishBinaries _ =
exec { run "dotnet" "publish" "src/docs-builder/docs-builder.csproj" }
exec { run "dotnet" "publish" "src/docs-generator/docs-generator.csproj" }
Zip.zip
".artifacts/publish/docs-builder/release"
$"docs-builder-%s{OS.Name}-{OS.Arch}.zip"
[".artifacts/publish/docs-builder/release/docs-builder"]

let private publishZip _ =
exec { run "dotnet" "publish" "src/docs-builder/docs-builder.csproj" }
let binary = match OS.Current with Windows -> "docs-builder.exe" | _ -> "docs-builder"
Zip.zip
".artifacts/publish/docs-builder/release"
$".artifacts/publish/docs-builder/release/docs-builder-%s{OS.Name}-{OS.Arch}.zip"
[
$".artifacts/publish/docs-builder/release/%s{binary}";
".artifacts/publish/docs-builder/release/LICENSE.txt";
".artifacts/publish/docs-builder/release/NOTICE.txt"
]

let private publishContainers _ =

Expand Down Expand Up @@ -155,6 +171,7 @@ let Setup (parsed:ParseResults<Build>) =
| PristineCheck -> Build.Step pristineCheck
| PublishBinaries -> Build.Step publishBinaries
| PublishContainers -> Build.Step publishContainers
| PublishZip -> Build.Step publishZip
| ValidateLicenses -> Build.Step validateLicenses
| ReleaseNotes -> Build.Step generateReleaseNotes

Expand Down
1 change: 1 addition & 0 deletions build/build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="Octokit" Version="13.0.1" />
<PackageReference Include="Proc.Fs" Version="0.9.1" />
<PackageReference Include="Fake.Tools.Git" Version="6.1.3" />
<PackageReference Include="Fake.IO.Zip" Version="6.1.3" />
<PackageReference Remove="FSharp.Core"/>
<PackageReference Include="FSharp.Core" Version="9.0.100" />
</ItemGroup>
Expand Down

0 comments on commit 6965ef4

Please sign in to comment.