Skip to content

Commit 4c8d011

Browse files
committed
Add CI workflow for openHAB build process and update openhab.yml formatting
Signed-off-by: Christoph Hofmann <[email protected]>
1 parent 075ad6d commit 4c8d011

File tree

2 files changed

+81
-13
lines changed

2 files changed

+81
-13
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 'openHAB Build CI Build'
2+
run-name: app-ci-${{github.run_id }}
3+
4+
env:
5+
BuildDirectory: '${{github.workspace}}\build'
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
configure:
14+
name: Configure Build
15+
runs-on: ubuntu-latest
16+
outputs:
17+
buildConfiguration: ${{ steps.configuration.outputs.BuildConfiguration }}
18+
bundlePlatforms: ${{ steps.configuration.outputs.BundlePlatforms }}
19+
buildNumber: ${{ steps.buildnumber.outputs.BUILD_NUMBER }}
20+
releaseName: ${{ steps.buildnumber.outputs.RELEASE_NAME }}
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v2
24+
25+
- name: Detect Build Configuration
26+
id: configuration
27+
shell: pwsh
28+
run: |
29+
if ($env:github.ref -eq 'refs/heads/main') {
30+
Write-Host "Set build configuration to release"
31+
32+
Write-Output "BuildConfiguration=release" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
33+
Write-Output "BundlePlatforms=x86|x64|ARM" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
34+
} else {
35+
Write-Host "Set build configuration to debug"
36+
37+
Write-Output "BuildConfiguration=debug" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
38+
Write-Output "BundlePlatforms=x86" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
39+
}
40+
41+
- name: Set build number and release name
42+
id: buildnumber
43+
shell: pwsh
44+
run: |
45+
$CURRENTDATE = Get-Date -Format "yyyy.MM.dd"
46+
Write-Output "BUILD_NUMBER=$CURRENTDATE" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
47+
48+
$IS_BETA_RELEASE = '${{ inputs.IsBetaRelease }}'
49+
if ($IS_BETA_RELEASE -eq 'true') {
50+
Write-Host "Set release name to Beta:$CURRENTDATE.${{github.run_number}}"
51+
Write-Output "RELEASE_NAME=Beta:$CURRENTDATE.${{github.run_number}}" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
52+
} else {
53+
Write-Host "Set release name to $CURRENTDATE"
54+
Write-Output "RELEASE_NAME=$CURRENTDATE" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
55+
}
56+
57+
build:
58+
uses: ./.github/workflows/build.yml
59+
name: Build
60+
needs: configure
61+
with:
62+
build_configuration: ${{needs.configure.outputs.buildConfiguration}}
63+
bundle_Platforms: ${{ needs.configure.outputs.bundlePlatforms}}
64+
build_number: ${{ needs.configure.outputs.buildNumber}}
65+
secrets: inherit

.github/workflows/openhab.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
name: 'openHAB Build and Release app'
1+
name: "openHAB Build and Release app"
22
run-name: app-${{github.run_id }}
33

44
env:
55
BuildDirectory: '${{github.workspace}}\build'
66
ACTIONS_RUNNER_DEBUG: true
77

88
on:
9+
push:
10+
branches:
11+
- main
912
workflow_dispatch:
1013
inputs:
1114
BuildConfiguration:
12-
description: 'Specifices if a release or debug package should be created.'
15+
description: "Specifices if a release or debug package should be created."
1316
type: choice
14-
options: ['release', 'debug']
15-
default: 'release'
17+
options: ["release", "debug"]
18+
default: "release"
1619
IsBetaRelease:
17-
description: 'Specifices if a beta release should be created.'
18-
type: 'boolean'
20+
description: "Specifices if a beta release should be created."
21+
type: "boolean"
1922
default: false
2023

2124
jobs:
@@ -46,7 +49,7 @@ jobs:
4649
Write-Output "BuildConfiguration=debug" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
4750
Write-Output "BundlePlatforms=x86" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
4851
}
49-
52+
5053
- name: Set build number and release name
5154
id: buildnumber
5255
shell: pwsh
@@ -62,7 +65,7 @@ jobs:
6265
Write-Host "Set release name to $CURRENTDATE"
6366
Write-Output "RELEASE_NAME=$CURRENTDATE" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
6467
}
65-
68+
6669
build:
6770
uses: ./.github/workflows/build.yml
6871
name: Build
@@ -75,16 +78,16 @@ jobs:
7578

7679
create_release:
7780
uses: ./.github/workflows/release.yml
78-
needs:
81+
needs:
7982
- build
8083
- configure
8184
with:
8285
beta_release: ${{ inputs.IsBetaRelease }}
8386
build_number: ${{ needs.configure.outputs.buildNumber }}
84-
87+
8588
# publish_beta:
8689
# uses: ./.github/workflows/publish.yml
87-
# needs:
90+
# needs:
8891
# - build
8992
# - configure
9093
# with:
@@ -94,10 +97,10 @@ jobs:
9497

9598
# publish_prod:
9699
# uses: ./.github/workflows/publish.yml
97-
# needs:
100+
# needs:
98101
# - publish_beta
99102
# - configure
100103
# with:
101104
# environment: PROD
102105
# package_name: "openHAB.Windows_${{needs.configure.outputs.buildNumber}}_x86_x64_arm_bundle"
103-
# secrets: inherit
106+
# secrets: inherit

0 commit comments

Comments
 (0)