diff --git a/.github/workflows/buildjs.yml b/.github/workflows/buildjs.yml new file mode 100644 index 0000000..5796e82 --- /dev/null +++ b/.github/workflows/buildjs.yml @@ -0,0 +1,92 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: buildjs +on: + workflow_call: + inputs: + projectdirectory: + required: true + type: string + componentName: + required: true + type: string + publishArtifact: + required: true + type: boolean + testCommand: + required: true + type: string + publishCodeCov: + required: true + type: boolean + artifactlocation: + required: false + type: string + secrets: + CODECOV_TOKEN: + required: false +jobs: + buildJS: + name: Build ${{ inputs.componentName }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: npm ci + working-directory: ${{ inputs.projectdirectory }} + - name: build + run: npm run build + working-directory: ${{ inputs.projectdirectory }} + - name: Run tests + run: npm run ${{ inputs.testCommand }} + working-directory: ${{ inputs.projectdirectory }} + - name: Publish Test Report + uses: phoenix-actions/test-reporting@v8 + id: test-report # Set ID reference for step + if: ${{ (success() || failure()) && inputs.publishCodeCov }} # run this step even if previous step failed + with: + name: JEST Tests # Name of the check run which will be created + path: ${{ inputs.projectdirectory }}/*-junit.xml # Path to test results + reporter: jest-junit # Format of test results + - name: Publish Tests Results to CodeCov + uses: codecov/test-results-action@v1 + if: ${{ (success() || failure()) && inputs.publishCodeCov }} + with: + fail_ci_if_error: true # optional (default = false) + disable_search: true + files: ./${{ inputs.projectdirectory }}/vitest-junit.xml # optional + flags: broadcast # optional + name: ${{ inputs.componentName }}-tests # optional + token: ${{ secrets.CODECOV_TOKEN }} # required + verbose: true # optional (default = false) + - name: Publish Coverage to CodeCov + uses: codecov/codecov-action@v5 + if: ${{ (success() || failure()) && inputs.publishCodeCov }} + with: + fail_ci_if_error: true # optional (default = false) + disable_search: true + files: ./${{ inputs.projectdirectory }}/coverage/lcov.info # optional + flags: broadcast # optional + name: ${{ inputs.componentName }}-coverage # optional + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true # optional (default = false) + - name: Create destination folder + if: ${{ success() && inputs.publishArtifact }} + run: mkdir -p ${{inputs.artifactlocation}} + - name: Copy file outputjs into staging directory + if: ${{ success() && inputs.publishArtifact }} + run: cp ${{ inputs.projectdirectory }}/dist/broadcast.js ${{inputs.artifactlocation}} + - name: Upload ${{ inputs.componentName }} artifact + if: ${{ success() && inputs.publishArtifact }} + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.componentName }} + path: ${{inputs.artifactlocation}} + + + + + + + \ No newline at end of file diff --git a/.github/workflows/buildpcf.yml b/.github/workflows/buildpcf.yml new file mode 100644 index 0000000..ca856fe --- /dev/null +++ b/.github/workflows/buildpcf.yml @@ -0,0 +1,51 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: buildPCF +on: + workflow_call: + inputs: + pcfdirectory: + required: true + type: string + publishArtifact: + required: true + type: boolean + componentName: + required: true + type: string + artifactlocation: + required: false + type: string +jobs: + buildPCF: + name: Build ${{ inputs.componentName }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: npm ci + working-directory: ${{ inputs.pcfdirectory }} + - name: build + run: npm run build + working-directory: ${{ inputs.pcfdirectory }} + - name: Create destination folder + if: ${{ success() && inputs.publishArtifact }} + run: mkdir -p ${{inputs.artifactlocation}} + - name: Copy file output pcf bundle into staging directory + if: ${{ success() && inputs.publishArtifact }} + run: cp ${{ inputs.pcfdirectory }}/out/controls/${{ inputs.componentName }}/* ${{inputs.artifactlocation}} + - name: Upload ${{ inputs.componentName }} artifact + if: ${{ success() && inputs.publishArtifact }} + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.componentName }} + path: ${{inputs.artifactlocation}} + + + + + + + + \ No newline at end of file diff --git a/.github/workflows/ci-validation.yml b/.github/workflows/ci-validation.yml index 90bd541..ccae586 100644 --- a/.github/workflows/ci-validation.yml +++ b/.github/workflows/ci-validation.yml @@ -30,73 +30,22 @@ jobs: solution-file: artifactlocation/broadcast_solution.zip solution-type: Unmanaged buildBroadCastJs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: npm ci - working-directory: ${{ env.broadcastjsWorkingDirectory }} - - name: build - run: npm run build - working-directory: ${{ env.broadcastjsWorkingDirectory }} - - name: Run tests - run: npm run test:ci - working-directory: ${{ env.broadcastjsWorkingDirectory }} - - name: Publish Test Report - uses: phoenix-actions/test-reporting@v8 - id: test-report # Set ID reference for step - if: ${{ (success() || failure()) && (github.event_name == 'pull_request') }} # run this step even if previous step failed - with: - name: JEST Tests # Name of the check run which will be created - path: ${{ env.broadcastjsWorkingDirectory }}/*-junit.xml # Path to test results - reporter: jest-junit # Format of test results - - name: Publish Tests Results to CodeCov - uses: codecov/test-results-action@v1 - with: - fail_ci_if_error: true # optional (default = false) - disable_search: true - files: ./${{ env.broadcastjsWorkingDirectory }}/vitest-junit.xml # optional - flags: broadcast # optional - name: broadcastjs-tests # optional - token: ${{ secrets.CODECOV_TOKEN }} # required - verbose: true # optional (default = false) - - name: Publish Coverage to CodeCov - uses: codecov/codecov-action@v5 - with: - fail_ci_if_error: true # optional (default = false) - disable_search: true - files: ./${{ env.broadcastjsWorkingDirectory }}/coverage/lcov.info # optional - flags: broadcast # optional - name: broadcastjs-coverage # optional - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true # optional (default = false) - - name: Create destination folder - run: mkdir -p ${{env.artifactlocation}} - - name: Copy file outputjs into staging directory - run: cp ${{ env.broadcastjsWorkingDirectory }}/dist/broadcast.js ${{env.artifactlocation}} - - name: Upload broadcastjs artifact - if: ${{ success() && (github.event_name == 'push') }} - uses: actions/upload-artifact@v4 - with: - name: broadcastjs - path: ${{env.artifactlocation}} + uses: ./.github/workflows/buildjs.yml + with: + projectdirectory: 'src/broadcast-typescript' + componentName: broadcastjs + publishArtifact: false + testCommand: 'test:ci' + publishCodeCov: true + artifactlocation: '${{ github.workspace }}/dist' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + + buildAppModulePickerPCF: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: npm ci - working-directory: ${{ env.pcfWorkkingDirectory }} - - name: build - run: npm run build - working-directory: ${{ env.pcfWorkkingDirectory }} - - name: Create destination folder - run: mkdir -p ${{env.artifactlocation}} - - name: Copy file output pcf bundle into staging directory - run: cp ${{ env.pcfWorkkingDirectory }}/out/controls/AppModulePicker/* ${{env.artifactlocation}} - - name: Upload AppModulePicker artifact - if: ${{ success() && (github.event_name == 'push') }} - uses: actions/upload-artifact@v4 - with: - name: AppModulePicker - path: ${{env.artifactlocation}} \ No newline at end of file + uses: ./.github/workflows/buildpcf.yml + with: + pcfdirectory: 'src/broadcast-pcf/appmodulepicker' + publishArtifact: false + componentName: AppModulePicker \ No newline at end of file diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml new file mode 100644 index 0000000..10b64d3 --- /dev/null +++ b/.github/workflows/release-on-tag.yml @@ -0,0 +1,125 @@ +name: Create Release on Tag +run-name: BuildTag ${{ github.ref }} +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + + +env: + pcfWorkkingDirectory: 'src/broadcast-pcf/appmodulepicker' + broadcastjsWorkingDirectory: 'src/broadcast-typescript' + solutionDirectory: 'src/broadcast-solution' + artifactlocation: '${{ github.workspace }}/dist' +jobs: + buildBroadCastJs: + uses: ./.github/workflows/buildjs.yml + with: + projectdirectory: 'src/broadcast-typescript' + componentName: broadcastjs + publishArtifact: true + testCommand: 'test:ci' + publishCodeCov: false + artifactlocation: '${{ github.workspace }}/dist' + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + + + buildAppModulePickerPCF: + uses: ./.github/workflows/buildpcf.yml + with: + pcfdirectory: 'src/broadcast-pcf/appmodulepicker' + publishArtifact: true + componentName: AppModulePicker + artifactlocation: '${{ github.workspace }}/dist' + release: + name: Create Release from tag + needs: [ buildAppModulePickerPCF, buildBroadCastJs] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install Power Platform Tools + uses: microsoft/powerplatform-actions/actions-install@v1 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v4.1.0 + with: + versionSpec: '6.3.x' + - name: Determine Version + id: gitversion # step id used as reference for output values + uses: gittools/actions/gitversion/execute@v4.1.0 + + - name: Download broadcastjs artifact + uses: actions/download-artifact@v4 + with: + name: broadcastjs + path: '${{ github.workspace }}/broadcastjs' + - name: Download AppModulePicker artifact + uses: actions/download-artifact@v4 + with: + name: AppModulePicker + path: '${{ github.workspace }}/AppModulePicker' + - name: Rename broadcastjs/bundle.js into bbundle.js + run: bundle.js bbundle.js + working-directory: ${{ github.workspace }}/AppModulePicker + - name: Update PCF control version with ${{ github.ref }} + uses: Mudlet/xmlstarlet-action@v1.2 + with: + args: >- + ed -L --update "/manifest/control/@version" + -v "${{ steps.gitversion.outputs.majorMinorPatch }}" + ${{ github.workspace }}/AppModulePicker/ControlManifest.xml + - name: Update Solution.xml Version with semver + uses: Mudlet/xmlstarlet-action@v1.2 + with: + args: >- + ed -L --update "/ImportExportXml/SolutionManifest/Version" + -v "${{ steps.gitversion.outputs.assemblySemVer }}" + ${{ github.workspace }}/src/broadcast-solution/Other/Solution.xml + - name: delete bundle.js from the solution directory + run: | + rm src/broadcast-solution/Controls/fdn_Broadcast.AppModulePicker/bundle.js + - name: Pack solution + uses: microsoft/powerplatform-actions/pack-solution@v1 + with: + solution-folder: src/broadcast-solution + map-file: src/solution-mapping-pack.xml + solution-file: BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}.zip + solution-type: Both + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Unmanaged Release Solution + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}.zip + asset_name: BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}.zip + asset_content_type: application/zip + - name: Upload Managed Release Solution + id: upload-release-managed-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}_Managed.zip + asset_name: BroadcastSolution_v${{ steps.gitversion.outputs.majorMinorPatch }}_Managed.zip + asset_content_type: application/zip + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 007b947..64e238d 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,8 @@ vite.config.ts.timestamp-* src/broadcast-pcf/appmodulepicker/push.bat export-solution.ps1 /.vs +pack-solution.ps1 +BroadcastSolution_managed.zip +.gitignore +BroadcastSolution.zip +src/solution-mapping-pack.local.xml diff --git a/src/solution-mapping-pack.xml b/src/solution-mapping-pack.xml new file mode 100644 index 0000000..e6f73e9 --- /dev/null +++ b/src/solution-mapping-pack.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file