Skip to content

Commit

Permalink
Add Github Actions automations (#4405)
Browse files Browse the repository at this point in the history
* Add Github Actions automations

- labeler: used for versions and marking commits as Infra
- backport: we can now apply labels `backport $branch` and on PR close
this will automatically open up the appropiate backport PR's

If you call the release target e.g

$ ./build.sh release 8.0.0-alpha2

This will now bump the version in both global.json as well as the
autolabel.json

* fix casing on label

(cherry picked from commit f0ee705)
  • Loading branch information
Mpdreamz committed Feb 21, 2020
1 parent afa9791 commit 9a08447
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 50 deletions.
6 changes: 6 additions & 0 deletions .github/auto-label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
"Infra": [".ci/**/*", ".github/**/*","build/**/*"],
"v8.0.0-alpha1": "**/*"
}
}
14 changes: 14 additions & 0 deletions .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Auto Label
on:
pull_request:
types: [opened, synchronize]

jobs:
auto-label:
name: Auto Label
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: banyan/auto-label@1.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Backport
on:
pull_request:
types:
- closed
- labeled

jobs:
backport:
runs-on: ubuntu-18.04
name: Backport
steps:
- name: Backport
uses: tibdex/backport@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
47 changes: 0 additions & 47 deletions .github/workflows/yaml-runner.yml

This file was deleted.

14 changes: 14 additions & 0 deletions build/scripts/Versioning.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open System.Diagnostics
open System.IO
open Commandline
open Fake.Core
open Fake.Core
open Fake.IO
open Fake.IO.Globbing.Operators
open Newtonsoft.Json
Expand All @@ -25,6 +26,18 @@ module Versioning =
let jsonString = File.ReadAllText "global.json"
JsonConvert.DeserializeObject<GlobalJson>(jsonString)

let writeVersionIntoAutoLabel oldVersion newVersion =
let path = Path.Join(".github","auto-label.json")
let text = File.ReadAllText(path)
let oldV = sprintf "v%s" oldVersion
let newV = sprintf "v%s" newVersion
if not(text.Contains(oldV)) then
failwithf "auto-label.json does not contain %s" oldV

let replaced = String.replace oldV newV text
File.WriteAllText(path, replaced)


let writeVersionIntoGlobalJson version =
let globalJson = globalJson ()
let doc_current =
Expand Down Expand Up @@ -88,6 +101,7 @@ module Versioning =
if (currentVersion > newVersion) then
failwithf "Can not release %O as it's lower then current %O" newVersion.Full currentVersion.Full
writeVersionIntoGlobalJson newVersion.Full
writeVersionIntoAutoLabel (currentVersion.Full.ToString()) (newVersion.Full.ToString())
| _ -> ignore()

let ArtifactsVersion buildVersions =
Expand Down
10 changes: 8 additions & 2 deletions build/scripts/scripts.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
<Content Include="..\..\build.bat"><Link>build.bat</Link></Content>
<Content Include="..\..\appveyor.yml"><Link>appveyor.yml</Link></Content>
<Content Include="..\..\azure-pipelines.yml"><Link>azure-pipelines.yml</Link></Content>
<Content Include="..\..\.github\workflows\yaml-runner.yml">
<Link>yaml-runner.yml</Link>
<Content Include="..\..\.github\workflows\auto-label.yml">
<Link>auto-label.yml</Link>
</Content>
<Content Include="..\..\.github\workflows\backport.yml">
<Link>backport.yml</Link>
</Content>
<Content Include="..\..\.github\auto-label.json">
<Link>auto-label.json</Link>
</Content>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"version": "7.5.0",
"doc_current": "7.5",
"doc_branch": "7.x"
}
}

0 comments on commit 9a08447

Please sign in to comment.