Skip to content

Commit 42871ed

Browse files
authored
Merge pull request #5 from dotnetprog/feature/AddReleaseOnTagWorkflow
gh actions refacto
2 parents d226b6e + ce0941e commit 42871ed

File tree

6 files changed

+299
-69
lines changed

6 files changed

+299
-69
lines changed

.github/workflows/buildjs.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: buildjs
5+
on:
6+
workflow_call:
7+
inputs:
8+
projectdirectory:
9+
required: true
10+
type: string
11+
componentName:
12+
required: true
13+
type: string
14+
publishArtifact:
15+
required: true
16+
type: boolean
17+
testCommand:
18+
required: true
19+
type: string
20+
publishCodeCov:
21+
required: true
22+
type: boolean
23+
artifactlocation:
24+
required: false
25+
type: string
26+
secrets:
27+
CODECOV_TOKEN:
28+
required: false
29+
jobs:
30+
buildJS:
31+
name: Build ${{ inputs.componentName }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Install dependencies
36+
run: npm ci
37+
working-directory: ${{ inputs.projectdirectory }}
38+
- name: build
39+
run: npm run build
40+
working-directory: ${{ inputs.projectdirectory }}
41+
- name: Run tests
42+
run: npm run ${{ inputs.testCommand }}
43+
working-directory: ${{ inputs.projectdirectory }}
44+
- name: Publish Test Report
45+
uses: phoenix-actions/test-reporting@v8
46+
id: test-report # Set ID reference for step
47+
if: ${{ (success() || failure()) && inputs.publishCodeCov }} # run this step even if previous step failed
48+
with:
49+
name: JEST Tests # Name of the check run which will be created
50+
path: ${{ inputs.projectdirectory }}/*-junit.xml # Path to test results
51+
reporter: jest-junit # Format of test results
52+
- name: Publish Tests Results to CodeCov
53+
uses: codecov/test-results-action@v1
54+
if: ${{ (success() || failure()) && inputs.publishCodeCov }}
55+
with:
56+
fail_ci_if_error: true # optional (default = false)
57+
disable_search: true
58+
files: ./${{ inputs.projectdirectory }}/vitest-junit.xml # optional
59+
flags: broadcast # optional
60+
name: ${{ inputs.componentName }}-tests # optional
61+
token: ${{ secrets.CODECOV_TOKEN }} # required
62+
verbose: true # optional (default = false)
63+
- name: Publish Coverage to CodeCov
64+
uses: codecov/codecov-action@v5
65+
if: ${{ (success() || failure()) && inputs.publishCodeCov }}
66+
with:
67+
fail_ci_if_error: true # optional (default = false)
68+
disable_search: true
69+
files: ./${{ inputs.projectdirectory }}/coverage/lcov.info # optional
70+
flags: broadcast # optional
71+
name: ${{ inputs.componentName }}-coverage # optional
72+
token: ${{ secrets.CODECOV_TOKEN }}
73+
verbose: true # optional (default = false)
74+
- name: Create destination folder
75+
if: ${{ success() && inputs.publishArtifact }}
76+
run: mkdir -p ${{inputs.artifactlocation}}
77+
- name: Copy file outputjs into staging directory
78+
if: ${{ success() && inputs.publishArtifact }}
79+
run: cp ${{ inputs.projectdirectory }}/dist/broadcast.js ${{inputs.artifactlocation}}
80+
- name: Upload ${{ inputs.componentName }} artifact
81+
if: ${{ success() && inputs.publishArtifact }}
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: ${{ inputs.componentName }}
85+
path: ${{inputs.artifactlocation}}
86+
87+
88+
89+
90+
91+
92+

.github/workflows/buildpcf.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow will build a .NET project
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
3+
4+
name: buildPCF
5+
on:
6+
workflow_call:
7+
inputs:
8+
pcfdirectory:
9+
required: true
10+
type: string
11+
publishArtifact:
12+
required: true
13+
type: boolean
14+
componentName:
15+
required: true
16+
type: string
17+
artifactlocation:
18+
required: false
19+
type: string
20+
jobs:
21+
buildPCF:
22+
name: Build ${{ inputs.componentName }}
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Install dependencies
27+
run: npm ci
28+
working-directory: ${{ inputs.pcfdirectory }}
29+
- name: build
30+
run: npm run build
31+
working-directory: ${{ inputs.pcfdirectory }}
32+
- name: Create destination folder
33+
if: ${{ success() && inputs.publishArtifact }}
34+
run: mkdir -p ${{inputs.artifactlocation}}
35+
- name: Copy file output pcf bundle into staging directory
36+
if: ${{ success() && inputs.publishArtifact }}
37+
run: cp ${{ inputs.pcfdirectory }}/out/controls/${{ inputs.componentName }}/* ${{inputs.artifactlocation}}
38+
- name: Upload ${{ inputs.componentName }} artifact
39+
if: ${{ success() && inputs.publishArtifact }}
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: ${{ inputs.componentName }}
43+
path: ${{inputs.artifactlocation}}
44+
45+
46+
47+
48+
49+
50+
51+

.github/workflows/ci-validation.yml

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -30,73 +30,22 @@ jobs:
3030
solution-file: artifactlocation/broadcast_solution.zip
3131
solution-type: Unmanaged
3232
buildBroadCastJs:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v4
36-
- name: Install dependencies
37-
run: npm ci
38-
working-directory: ${{ env.broadcastjsWorkingDirectory }}
39-
- name: build
40-
run: npm run build
41-
working-directory: ${{ env.broadcastjsWorkingDirectory }}
42-
- name: Run tests
43-
run: npm run test:ci
44-
working-directory: ${{ env.broadcastjsWorkingDirectory }}
45-
- name: Publish Test Report
46-
uses: phoenix-actions/test-reporting@v8
47-
id: test-report # Set ID reference for step
48-
if: ${{ (success() || failure()) && (github.event_name == 'pull_request') }} # run this step even if previous step failed
49-
with:
50-
name: JEST Tests # Name of the check run which will be created
51-
path: ${{ env.broadcastjsWorkingDirectory }}/*-junit.xml # Path to test results
52-
reporter: jest-junit # Format of test results
53-
- name: Publish Tests Results to CodeCov
54-
uses: codecov/test-results-action@v1
55-
with:
56-
fail_ci_if_error: true # optional (default = false)
57-
disable_search: true
58-
files: ./${{ env.broadcastjsWorkingDirectory }}/vitest-junit.xml # optional
59-
flags: broadcast # optional
60-
name: broadcastjs-tests # optional
61-
token: ${{ secrets.CODECOV_TOKEN }} # required
62-
verbose: true # optional (default = false)
63-
- name: Publish Coverage to CodeCov
64-
uses: codecov/codecov-action@v5
65-
with:
66-
fail_ci_if_error: true # optional (default = false)
67-
disable_search: true
68-
files: ./${{ env.broadcastjsWorkingDirectory }}/coverage/lcov.info # optional
69-
flags: broadcast # optional
70-
name: broadcastjs-coverage # optional
71-
token: ${{ secrets.CODECOV_TOKEN }}
72-
verbose: true # optional (default = false)
73-
- name: Create destination folder
74-
run: mkdir -p ${{env.artifactlocation}}
75-
- name: Copy file outputjs into staging directory
76-
run: cp ${{ env.broadcastjsWorkingDirectory }}/dist/broadcast.js ${{env.artifactlocation}}
77-
- name: Upload broadcastjs artifact
78-
if: ${{ success() && (github.event_name == 'push') }}
79-
uses: actions/upload-artifact@v4
80-
with:
81-
name: broadcastjs
82-
path: ${{env.artifactlocation}}
33+
uses: ./.github/workflows/buildjs.yml
34+
with:
35+
projectdirectory: 'src/broadcast-typescript'
36+
componentName: broadcastjs
37+
publishArtifact: false
38+
testCommand: 'test:ci'
39+
publishCodeCov: true
40+
artifactlocation: '${{ github.workspace }}/dist'
41+
secrets:
42+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
43+
44+
45+
8346
buildAppModulePickerPCF:
84-
runs-on: ubuntu-latest
85-
steps:
86-
- uses: actions/checkout@v4
87-
- name: Install dependencies
88-
run: npm ci
89-
working-directory: ${{ env.pcfWorkkingDirectory }}
90-
- name: build
91-
run: npm run build
92-
working-directory: ${{ env.pcfWorkkingDirectory }}
93-
- name: Create destination folder
94-
run: mkdir -p ${{env.artifactlocation}}
95-
- name: Copy file output pcf bundle into staging directory
96-
run: cp ${{ env.pcfWorkkingDirectory }}/out/controls/AppModulePicker/* ${{env.artifactlocation}}
97-
- name: Upload AppModulePicker artifact
98-
if: ${{ success() && (github.event_name == 'push') }}
99-
uses: actions/upload-artifact@v4
100-
with:
101-
name: AppModulePicker
102-
path: ${{env.artifactlocation}}
47+
uses: ./.github/workflows/buildpcf.yml
48+
with:
49+
pcfdirectory: 'src/broadcast-pcf/appmodulepicker'
50+
publishArtifact: false
51+
componentName: AppModulePicker
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Create Release on Tag
2+
run-name: BuildTag ${{ github.ref }}
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
10+
env:
11+
pcfWorkkingDirectory: 'src/broadcast-pcf/appmodulepicker'
12+
broadcastjsWorkingDirectory: 'src/broadcast-typescript'
13+
solutionDirectory: 'src/broadcast-solution'
14+
artifactlocation: '${{ github.workspace }}/dist'
15+
jobs:
16+
buildBroadCastJs:
17+
uses: ./.github/workflows/buildjs.yml
18+
with:
19+
projectdirectory: 'src/broadcast-typescript'
20+
componentName: broadcastjs
21+
publishArtifact: true
22+
testCommand: 'test:ci'
23+
publishCodeCov: false
24+
artifactlocation: '${{ github.workspace }}/dist'
25+
secrets:
26+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
27+
28+
29+
30+
buildAppModulePickerPCF:
31+
uses: ./.github/workflows/buildpcf.yml
32+
with:
33+
pcfdirectory: 'src/broadcast-pcf/appmodulepicker'
34+
publishArtifact: true
35+
componentName: AppModulePicker
36+
artifactlocation: '${{ github.workspace }}/dist'
37+
release:
38+
name: Create Release from tag
39+
needs: [ buildAppModulePickerPCF, buildBroadCastJs]
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
- name: Install Power Platform Tools
46+
uses: microsoft/powerplatform-actions/actions-install@v1
47+
- name: Install GitVersion
48+
uses: gittools/actions/gitversion/[email protected]
49+
with:
50+
versionSpec: '6.3.x'
51+
- name: Determine Version
52+
id: gitversion # step id used as reference for output values
53+
uses: gittools/actions/gitversion/[email protected]
54+
55+
- name: Download broadcastjs artifact
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: broadcastjs
59+
path: '${{ github.workspace }}/broadcastjs'
60+
- name: Download AppModulePicker artifact
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: AppModulePicker
64+
path: '${{ github.workspace }}/AppModulePicker'
65+
- name: Rename broadcastjs/bundle.js into bbundle.js
66+
run: bundle.js bbundle.js
67+
working-directory: ${{ github.workspace }}/AppModulePicker
68+
- name: Update PCF control version with ${{ github.ref }}
69+
uses: Mudlet/[email protected]
70+
with:
71+
args: >-
72+
ed -L --update "/manifest/control/@version"
73+
-v "${{ steps.gitversion.outputs.majorMinorPatch }}"
74+
${{ github.workspace }}/AppModulePicker/ControlManifest.xml
75+
- name: Update Solution.xml Version with semver
76+
uses: Mudlet/[email protected]
77+
with:
78+
args: >-
79+
ed -L --update "/ImportExportXml/SolutionManifest/Version"
80+
-v "${{ steps.gitversion.outputs.assemblySemVer }}"
81+
${{ github.workspace }}/src/broadcast-solution/Other/Solution.xml
82+
- name: delete bundle.js from the solution directory
83+
run: |
84+
rm src/broadcast-solution/Controls/fdn_Broadcast.AppModulePicker/bundle.js
85+
- name: Pack solution
86+
uses: microsoft/powerplatform-actions/pack-solution@v1
87+
with:
88+
solution-folder: src/broadcast-solution
89+
map-file: src/solution-mapping-pack.xml
90+
solution-file: BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}.zip
91+
solution-type: Both
92+
- name: Create Release
93+
id: create_release
94+
uses: actions/create-release@v1
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
with:
98+
tag_name: ${{ github.ref }}
99+
release_name: Release ${{ github.ref }}
100+
draft: false
101+
prerelease: false
102+
- name: Upload Unmanaged Release Solution
103+
id: upload-release-asset
104+
uses: actions/upload-release-asset@v1
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
upload_url: ${{ steps.create_release.outputs.upload_url }}
109+
asset_path: ./BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}.zip
110+
asset_name: BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}.zip
111+
asset_content_type: application/zip
112+
- name: Upload Managed Release Solution
113+
id: upload-release-managed-asset
114+
uses: actions/upload-release-asset@v1
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
with:
118+
upload_url: ${{ steps.create_release.outputs.upload_url }}
119+
asset_path: ./BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}_Managed.zip
120+
asset_name: BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}_Managed.zip
121+
asset_content_type: application/zip
122+
123+
124+
125+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,8 @@ vite.config.ts.timestamp-*
140140
src/broadcast-pcf/appmodulepicker/push.bat
141141
export-solution.ps1
142142
/.vs
143+
pack-solution.ps1
144+
BroadcastSolution_managed.zip
145+
.gitignore
146+
BroadcastSolution.zip
147+
src/solution-mapping-pack.local.xml

src/solution-mapping-pack.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Mapping>
3+
<!-- Match specific named files to an alternate folder -->
4+
<FileToFile map="broadcast.js" to="../../broadcastjs/broadcast.js" />
5+
<!-- you have to rename broadcast-pcf/appmodulepicker/out/controls/AppModulePicker/bundle.js with bbundle.js -->
6+
<!-- and delete Controls/fdn_Broadcast.AppModulePicker/bundle.js for it to work properly -->
7+
<FileToPath map="Controls/fdn_Broadcast.AppModulePicker/*.*" to="../../AppModulePicker/**" />
8+
</Mapping>

0 commit comments

Comments
 (0)