From 535abf5fcf7b5023c0feaf880b39595131ad83e0 Mon Sep 17 00:00:00 2001 From: Ryan Casperson Date: Fri, 6 Sep 2024 13:04:59 -0400 Subject: [PATCH 1/5] RKT-2364: Use upload-secure-artifact action --- .github/workflows/powershell-module-ci.yml | 4 ++-- .github/workflows/release-workflow.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index ce91fda1d..2b27c1bac 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -158,7 +158,7 @@ jobs: Write-Host ('[status] Setting up org') $variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" $variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json - - uses: actions/upload-artifact@v3 + - uses: TheJumpCloud/common-github-actions/upload-secure-artifact@v2 with: name: jumpcloud-vars path: /home/runner/.local/share/powershell/Modules/PesterVariables.json @@ -180,7 +180,7 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: jumpcloud-vars - name: Test PWSH Module diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 4f006d410..90c23d763 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -118,7 +118,7 @@ jobs: "Private" | should -bein $moduleRootDirectories.name "Public" | should -bein $moduleRootDirectories.name - name: Upload Nupkg - uses: actions/upload-artifact@v3 + uses: TheJumpCloud/common-github-actions/upload-secure-artifact@v2 with: name: jumpcloud-module-nupkg path: /home/runner/work/support/support/JumpCloud.*.nupkg @@ -154,7 +154,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Download nupkg artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: jumpcloud-module-nupkg - name: Publish From e66085df0aa9891fe99280dda4089c90c21b28f3 Mon Sep 17 00:00:00 2001 From: Ryan Casperson Date: Fri, 6 Sep 2024 13:12:26 -0400 Subject: [PATCH 2/5] (test): run workflows --- .github/workflows/powershell-module-ci.yml | 19 ++--- .github/workflows/release-workflow.yml | 70 ++++++++----------- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 64 ++++++++--------- PowerShell/ModuleChangelog.md | 16 +++++ 5 files changed, 84 insertions(+), 87 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 2b27c1bac..0197af678 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -2,21 +2,14 @@ name: PowerShell Module CI on: pull_request: - # Sequence of patterns matched against refs/heads - branches: - - "master" - paths: - - "PowerShell/Deploy/**" - - "PowerShell/JumpCloud Module/**" - - "PowerShell/ModuleChangelog.md" - types: [opened, synchronize, reopened, labeled, unlabeled] + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: Filter-Branch: runs-on: ubuntu-latest - if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') + # if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') steps: - run: echo "Building JumpCloud Module Event 'JumpCloudModule_'" Check-PR-Labels: @@ -44,12 +37,8 @@ jobs: } } - if ($typeCount -eq 1) { - echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT - } else { - throw "Multiple or invalid release types were found on PR" - exit 1 - } + echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Validate-Env-Variables: diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 90c23d763..b5807d52b 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -1,18 +1,10 @@ name: Release and Publish PSModule on: pull_request: - types: - - closed - paths: - - "PowerShell/Deploy/**" - - "PowerShell/JumpCloud Module/**" - - "PowerShell/ModuleChangelog.md" - branches: - - master jobs: Check-If-Merged: - if: github.event.pull_request.merged == true + # if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Check if Merged @@ -20,7 +12,7 @@ jobs: Filter-Branch: runs-on: ubuntu-latest - if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') + # if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') steps: - run: echo "Building JumpCloud Module Event 'JumpCloudModule_'" @@ -132,22 +124,22 @@ jobs: - name: Manual Approval for Release run: echo "Awaiting approval from required reviewers before continuing" - Draft-GH-Release: - needs: [Manual-Approval-Release] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build Draft Release - run: | - VERSION=$(grep -Po '(\d+\.\d+\.\d+)' ${{ github.workspace }}/PowerShell/JumpCloud\ Module/JumpCloud.psd1) - TITLE="JumpCloud PowerShell Module v$VERSION" - CHANGELOG=$(cat ${{ github.workspace }}/PowerShell/ModuleChangelog.md |awk "/^## $VERSION/{ f = 1; next } /## [0-9]+.[0-9]+.[0-9]+/{ f = 0 } f") - TAG="v$VERSION" - BODY="$TITLE $CHANGELOG" + # Draft-GH-Release: + # needs: [Manual-Approval-Release] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Build Draft Release + # run: | + # VERSION=$(grep -Po '(\d+\.\d+\.\d+)' ${{ github.workspace }}/PowerShell/JumpCloud\ Module/JumpCloud.psd1) + # TITLE="JumpCloud PowerShell Module v$VERSION" + # CHANGELOG=$(cat ${{ github.workspace }}/PowerShell/ModuleChangelog.md |awk "/^## $VERSION/{ f = 1; next } /## [0-9]+.[0-9]+.[0-9]+/{ f = 0 } f") + # TAG="v$VERSION" + # BODY="$TITLE $CHANGELOG" - (gh release view $TAG && echo "Release exists for $TAG") || gh release create $TAG --title "$TITLE" --notes "$BODY" --draft - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # (gh release view $TAG && echo "Release exists for $TAG") || gh release create $TAG --title "$TITLE" --notes "$BODY" --draft + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Deploy-Nupkg: needs: [Manual-Approval-Release, Build-Nuspec-Nupkg] @@ -157,20 +149,20 @@ jobs: uses: actions/download-artifact@v4 with: name: jumpcloud-module-nupkg - - name: Publish - shell: pwsh - run: | - # add nuget source for PSGallery: - dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery - # get nupkg artifact: - $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - # test - $nupkgPath | Should -Exist - Write-Host "Nupkg Artifact Restored: $nupkgPath" - # nuget push from here: - dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey - env: - NuGetApiKey: ${{ secrets.NUGETAPIKEY }} + # - name: Publish + # shell: pwsh + # run: | + # # add nuget source for PSGallery: + # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery + # # get nupkg artifact: + # $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + # # test + # $nupkgPath | Should -Exist + # Write-Host "Nupkg Artifact Restored: $nupkgPath" + # # nuget push from here: + # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey + # env: + # NuGetApiKey: ${{ secrets.NUGETAPIKEY }} Cleanup-Cache: needs: Deploy-Nupkg diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 2cdb89d4b..4f2b3eab2 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 2.13.1 +Help Version: 2.13.2 Locale: en-Us --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index e96f04f57..4ba73f585 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '2.13.1' +ModuleVersion = '2.13.2' # Supported PSEditions # CompatiblePSEditions = @() @@ -51,8 +51,8 @@ PowerShellVersion = '4.0' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @('JumpCloud.SDK.DirectoryInsights', - 'JumpCloud.SDK.V1', +RequiredModules = @('JumpCloud.SDK.DirectoryInsights', + 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') # Assemblies that must be loaded prior to importing this module @@ -71,35 +71,35 @@ RequiredModules = @('JumpCloud.SDK.DirectoryInsights', # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMember', - 'Add-JCOffice365Member', 'Add-JCRadiusReplyAttribute', - 'Add-JCSystemGroupMember', 'Add-JCSystemUser', - 'Add-JCUserGroupMember', 'Backup-JCOrganization', 'Connect-JCOnline', - 'Copy-JCAssociation', 'Get-JCAdmin', 'Get-JCAssociation', - 'Get-JCBackup', 'Get-JCCloudDirectory', 'Get-JCCommand', - 'Get-JCCommandResult', 'Get-JCCommandTarget', 'Get-JCEvent', - 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', - 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', - 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', - 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', - 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', - 'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember', - 'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV', - 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', - 'New-JCDeploymentTemplate', 'New-JCImportTemplate', - 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', - 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', - 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', - 'Remove-JCCommandTarget', 'Remove-JCGsuiteMember', - 'Remove-JCOffice365Member', 'Remove-JCPolicy', - 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', - 'Remove-JCSystem', 'Remove-JCSystemGroup', - 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', - 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', - 'Send-JCPasswordReset', 'Set-JCCloudDirectory', 'Set-JCCommand', - 'Set-JCOrganization', 'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', - 'Set-JCRadiusServer', 'Set-JCSettingsFile', 'Set-JCSystem', - 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', +FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMember', + 'Add-JCOffice365Member', 'Add-JCRadiusReplyAttribute', + 'Add-JCSystemGroupMember', 'Add-JCSystemUser', + 'Add-JCUserGroupMember', 'Backup-JCOrganization', 'Connect-JCOnline', + 'Copy-JCAssociation', 'Get-JCAdmin', 'Get-JCAssociation', + 'Get-JCBackup', 'Get-JCCloudDirectory', 'Get-JCCommand', + 'Get-JCCommandResult', 'Get-JCCommandTarget', 'Get-JCEvent', + 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', + 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', + 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', + 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', + 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', + 'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember', + 'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV', + 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', + 'New-JCDeploymentTemplate', 'New-JCImportTemplate', + 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', + 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', + 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', + 'Remove-JCCommandTarget', 'Remove-JCGsuiteMember', + 'Remove-JCOffice365Member', 'Remove-JCPolicy', + 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', + 'Remove-JCSystem', 'Remove-JCSystemGroup', + 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', + 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', + 'Send-JCPasswordReset', 'Set-JCCloudDirectory', 'Set-JCCommand', + 'Set-JCOrganization', 'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', + 'Set-JCRadiusServer', 'Set-JCSettingsFile', 'Set-JCSystem', + 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCMSPFromCSV', 'Update-JCUsersFromCSV' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index a19c0f544..8c9e43f1f 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,19 @@ +## 2.13.2 + + +Release Date: August 20, 2024 + +#### RELEASE NOTES + +``` +TEST - DO NOT MERGE +``` + +#### FEATURES: + +* Get-JCAdmin - Returns administrators in your organization + * MSP/MTP tenants can query multiple organizations or individual organizations + ## 2.13.1 Release Date: August 20, 2024 From e087bbf4cd3d02fb62558140d5021f66fcd4126f Mon Sep 17 00:00:00 2001 From: Ryan Casperson Date: Thu, 12 Sep 2024 21:47:38 -0400 Subject: [PATCH 3/5] (fix): Make upload-secure-artifact a local action --- .../actions/upload-secure-artifact/action.yml | 134 ++++++++++++++++++ .github/workflows/powershell-module-ci.yml | 2 +- .github/workflows/release-workflow.yml | 2 +- 3 files changed, 136 insertions(+), 2 deletions(-) create mode 100755 .github/actions/upload-secure-artifact/action.yml diff --git a/.github/actions/upload-secure-artifact/action.yml b/.github/actions/upload-secure-artifact/action.yml new file mode 100755 index 000000000..aa654ff70 --- /dev/null +++ b/.github/actions/upload-secure-artifact/action.yml @@ -0,0 +1,134 @@ +# This was manually copied from JumpCloud's internal actions repository. +# It may need to be updated from time to time. +# Latest Update: 9/12/2024 + +name: "Upload Secure Artifact" +description: "Upload an artifact, but only after it has been scanned for secrets, etc." +inputs: + name: + description: "Name of the artifact to upload" + required: true + path: + description: | + Path to the artifact to upload. + This can be a file or a directory. + Multiple paths can be provided by separating them with a space. + Note: This does not match exactly the use of `path` in actions/upload-artifact. + required: true + + # These inputs are optional. They defaults match the defaults of the actions/upload-artifact action@v4 as of 8/27/2024. + # See https://github.com/actions/upload-artifact?tab=readme-ov-file#inputs + if-no-files-found: + required: false + default: warn + retention-days: + required: false + # Duration after which artifact will expire in days. 0 means using default retention. + default: 0 + compression-level: + required: false + default: 6 + overwrite: + required: false + default: false + +runs: + using: "composite" + + steps: + - name: Check out Gitleaks + uses: actions/checkout@v4 + with: + repository: gitleaks/gitleaks + path: gitleaks + fetch-depth: 1 + - uses: actions/setup-go@v5 + with: + go-version: 1.23 + - name: Install Gitleaks + run: | + ### Install Gitleaks ### + # Set ARTIFACTS_DIR to something that should not collide with any real path in a repo. + ARTIFACTS_DIR="./__artifacts" + SCAN_DIR="${ARTIFACTS_DIR}_scan" + echo "ARTIFACTS_DIR=${ARTIFACTS_DIR}" >> ${GITHUB_ENV} + echo "SCAN_DIR=${SCAN_DIR}" >> ${GITHUB_ENV} + echo "GITLEAKS_SOURCE=${SCAN_DIR}" >> ${GITHUB_ENV} + case ${{ runner.os }} in + Windows) + echo "GITLEAKS_COMMAND=gitleaks/gitleaks.exe" >> ${GITHUB_ENV} + ;; + Linux|macOS) + echo "GITLEAKS_COMMAND=gitleaks/gitleaks" >> ${GITHUB_ENV} + ;; + *) + echo "Unsupported OS: ${{ runner.os }}" + exit 1 + ;; + esac + + cd gitleaks + make build + shell: bash + - name: Scan Artifacts + id: scan-artifacts + run: | + ### Scan Artifacts ### + # Create a directory to store the artifacts + mkdir -p "${ARTIFACTS_DIR}" + # Copy the artifact to the artifacts directory + for path in ${{ inputs.path }}; do + echo "Copying path: $path" + if [[ ! -e $path ]]; then + echo "Skipping non-existent path: $path" + continue + fi + if [[ -d $path ]]; then + cp -r $path "${ARTIFACTS_DIR}" + else + cp $path "${ARTIFACTS_DIR}" + fi + done + # Run the gitleaks scan if ARTIFACTS_DIR is not empty + if [ "$(ls -A ${ARTIFACTS_DIR})" ]; then + # Create a copy of the artifacts directory for scanning only + cp -r "${ARTIFACTS_DIR}" "${SCAN_DIR}" + # Unzip any .zip files in ARTIFACTS_DIR + # Check if there are .zip files in SCAN_DIR + if [ -n "$(find ${SCAN_DIR} -maxdepth 1 -name '*.zip' -print -quit)" ]; then + for file in ${SCAN_DIR}/*.zip; do + echo "Unzipping $file for scanning" + unzip -q $file -d ${SCAN_DIR} + rm $file + done + fi + + ${GITLEAKS_COMMAND} detect --source="${GITLEAKS_SOURCE}" -f -v -f json --no-git || exit_code=$? + if [[ $exit_code -ne 0 ]]; then + echo "Gitleaks scan failed. It is unsafe to upload the artifacts as requested." + echo "To see the scan results, you have to replicate the artifacts and scan locally." + echo "See this link for more information: https://jumpcloud.atlassian.net/wiki/spaces/ED/pages/2135654401/GitHub+Actions#Uploading-Artifacts" + exit 1 + fi + echo "artifacts-exist=true" >> "${GITHUB_OUTPUT}" + else + echo "${ARTIFACTS_DIR} is empty. Skipping scan and upload." + echo "artifacts-exist=false" >> "${GITHUB_OUTPUT}" + fi + shell: bash + - name: Upload Secure Artifacts + if: steps.scan-artifacts.outputs.artifacts-exist == 'true' + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.name }} + path: ${{ env.ARTIFACTS_DIR }} + if-no-files-found: ${{ inputs.if-no-files-found }} + retention-days: ${{ inputs.retention-days }} + compression-level: ${{ inputs.compression-level }} + overwrite: ${{ inputs.overwrite }} + - name: Clean Up Tmp Artifacts Directory + run: | + ### Clean Up Tmp Artifacts Directory ### + # Remove the artifacts directory in case this action is used multiple times in the same job. + rm -rf "${ARTIFACTS_DIR}" + shell: bash diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 0197af678..2a9e6f070 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -147,7 +147,7 @@ jobs: Write-Host ('[status] Setting up org') $variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" $variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json - - uses: TheJumpCloud/common-github-actions/upload-secure-artifact@v2 + - uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-vars path: /home/runner/.local/share/powershell/Modules/PesterVariables.json diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index b5807d52b..463741003 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -110,7 +110,7 @@ jobs: "Private" | should -bein $moduleRootDirectories.name "Public" | should -bein $moduleRootDirectories.name - name: Upload Nupkg - uses: TheJumpCloud/common-github-actions/upload-secure-artifact@v2 + uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg path: /home/runner/work/support/support/JumpCloud.*.nupkg From 65fda44f59ed6e88c80bcbd4a1e5019da07ec156 Mon Sep 17 00:00:00 2001 From: Ryan Casperson Date: Thu, 12 Sep 2024 21:51:41 -0400 Subject: [PATCH 4/5] (fix): Ensure local action is available --- .github/workflows/powershell-module-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 2a9e6f070..66d2a03cb 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -111,6 +111,7 @@ jobs: with: sparse-checkout: | PowerShell + .github - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" @@ -129,6 +130,7 @@ jobs: with: sparse-checkout: | PowerShell + .github - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" @@ -165,6 +167,7 @@ jobs: with: sparse-checkout: | PowerShell + .github - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" @@ -208,6 +211,7 @@ jobs: with: sparse-checkout: | PowerShell + .github - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" From 977e8b88812bae95b7cc86e8e4a188b5455b000f Mon Sep 17 00:00:00 2001 From: Ryan Casperson Date: Thu, 12 Sep 2024 21:55:31 -0400 Subject: [PATCH 5/5] Revert "(test): run workflows" This reverts commit e66085df0aa9891fe99280dda4089c90c21b28f3. --- .github/workflows/powershell-module-ci.yml | 19 +++-- .github/workflows/release-workflow.yml | 70 +++++++++++-------- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 64 ++++++++--------- PowerShell/ModuleChangelog.md | 16 ----- 5 files changed, 87 insertions(+), 84 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 66d2a03cb..d0984ae9a 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -2,14 +2,21 @@ name: PowerShell Module CI on: pull_request: - + # Sequence of patterns matched against refs/heads + branches: + - "master" + paths: + - "PowerShell/Deploy/**" + - "PowerShell/JumpCloud Module/**" + - "PowerShell/ModuleChangelog.md" + types: [opened, synchronize, reopened, labeled, unlabeled] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: Filter-Branch: runs-on: ubuntu-latest - # if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') + if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') steps: - run: echo "Building JumpCloud Module Event 'JumpCloudModule_'" Check-PR-Labels: @@ -37,8 +44,12 @@ jobs: } } - echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT - + if ($typeCount -eq 1) { + echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT + } else { + throw "Multiple or invalid release types were found on PR" + exit 1 + } env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Validate-Env-Variables: diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 463741003..eba038e6a 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -1,10 +1,18 @@ name: Release and Publish PSModule on: pull_request: + types: + - closed + paths: + - "PowerShell/Deploy/**" + - "PowerShell/JumpCloud Module/**" + - "PowerShell/ModuleChangelog.md" + branches: + - master jobs: Check-If-Merged: - # if: github.event.pull_request.merged == true + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Check if Merged @@ -12,7 +20,7 @@ jobs: Filter-Branch: runs-on: ubuntu-latest - # if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') + if: contains(github.event.pull_request.labels.*.name, 'PowerShell Module') steps: - run: echo "Building JumpCloud Module Event 'JumpCloudModule_'" @@ -124,22 +132,22 @@ jobs: - name: Manual Approval for Release run: echo "Awaiting approval from required reviewers before continuing" - # Draft-GH-Release: - # needs: [Manual-Approval-Release] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - name: Build Draft Release - # run: | - # VERSION=$(grep -Po '(\d+\.\d+\.\d+)' ${{ github.workspace }}/PowerShell/JumpCloud\ Module/JumpCloud.psd1) - # TITLE="JumpCloud PowerShell Module v$VERSION" - # CHANGELOG=$(cat ${{ github.workspace }}/PowerShell/ModuleChangelog.md |awk "/^## $VERSION/{ f = 1; next } /## [0-9]+.[0-9]+.[0-9]+/{ f = 0 } f") - # TAG="v$VERSION" - # BODY="$TITLE $CHANGELOG" + Draft-GH-Release: + needs: [Manual-Approval-Release] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build Draft Release + run: | + VERSION=$(grep -Po '(\d+\.\d+\.\d+)' ${{ github.workspace }}/PowerShell/JumpCloud\ Module/JumpCloud.psd1) + TITLE="JumpCloud PowerShell Module v$VERSION" + CHANGELOG=$(cat ${{ github.workspace }}/PowerShell/ModuleChangelog.md |awk "/^## $VERSION/{ f = 1; next } /## [0-9]+.[0-9]+.[0-9]+/{ f = 0 } f") + TAG="v$VERSION" + BODY="$TITLE $CHANGELOG" - # (gh release view $TAG && echo "Release exists for $TAG") || gh release create $TAG --title "$TITLE" --notes "$BODY" --draft - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + (gh release view $TAG && echo "Release exists for $TAG") || gh release create $TAG --title "$TITLE" --notes "$BODY" --draft + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} Deploy-Nupkg: needs: [Manual-Approval-Release, Build-Nuspec-Nupkg] @@ -149,20 +157,20 @@ jobs: uses: actions/download-artifact@v4 with: name: jumpcloud-module-nupkg - # - name: Publish - # shell: pwsh - # run: | - # # add nuget source for PSGallery: - # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery - # # get nupkg artifact: - # $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - # # test - # $nupkgPath | Should -Exist - # Write-Host "Nupkg Artifact Restored: $nupkgPath" - # # nuget push from here: - # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey - # env: - # NuGetApiKey: ${{ secrets.NUGETAPIKEY }} + - name: Publish + shell: pwsh + run: | + # add nuget source for PSGallery: + dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery + # get nupkg artifact: + $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + # test + $nupkgPath | Should -Exist + Write-Host "Nupkg Artifact Restored: $nupkgPath" + # nuget push from here: + dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey + env: + NuGetApiKey: ${{ secrets.NUGETAPIKEY }} Cleanup-Cache: needs: Deploy-Nupkg diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 4f2b3eab2..2cdb89d4b 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 2.13.2 +Help Version: 2.13.1 Locale: en-Us --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 4ba73f585..e96f04f57 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '2.13.2' +ModuleVersion = '2.13.1' # Supported PSEditions # CompatiblePSEditions = @() @@ -51,8 +51,8 @@ PowerShellVersion = '4.0' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @('JumpCloud.SDK.DirectoryInsights', - 'JumpCloud.SDK.V1', +RequiredModules = @('JumpCloud.SDK.DirectoryInsights', + 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') # Assemblies that must be loaded prior to importing this module @@ -71,35 +71,35 @@ RequiredModules = @('JumpCloud.SDK.DirectoryInsights', # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMember', - 'Add-JCOffice365Member', 'Add-JCRadiusReplyAttribute', - 'Add-JCSystemGroupMember', 'Add-JCSystemUser', - 'Add-JCUserGroupMember', 'Backup-JCOrganization', 'Connect-JCOnline', - 'Copy-JCAssociation', 'Get-JCAdmin', 'Get-JCAssociation', - 'Get-JCBackup', 'Get-JCCloudDirectory', 'Get-JCCommand', - 'Get-JCCommandResult', 'Get-JCCommandTarget', 'Get-JCEvent', - 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', - 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', - 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', - 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', - 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', - 'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember', - 'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV', - 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', - 'New-JCDeploymentTemplate', 'New-JCImportTemplate', - 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', - 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', - 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', - 'Remove-JCCommandTarget', 'Remove-JCGsuiteMember', - 'Remove-JCOffice365Member', 'Remove-JCPolicy', - 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', - 'Remove-JCSystem', 'Remove-JCSystemGroup', - 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', - 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', - 'Send-JCPasswordReset', 'Set-JCCloudDirectory', 'Set-JCCommand', - 'Set-JCOrganization', 'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', - 'Set-JCRadiusServer', 'Set-JCSettingsFile', 'Set-JCSystem', - 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', +FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMember', + 'Add-JCOffice365Member', 'Add-JCRadiusReplyAttribute', + 'Add-JCSystemGroupMember', 'Add-JCSystemUser', + 'Add-JCUserGroupMember', 'Backup-JCOrganization', 'Connect-JCOnline', + 'Copy-JCAssociation', 'Get-JCAdmin', 'Get-JCAssociation', + 'Get-JCBackup', 'Get-JCCloudDirectory', 'Get-JCCommand', + 'Get-JCCommandResult', 'Get-JCCommandTarget', 'Get-JCEvent', + 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', + 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', + 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', + 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', + 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', + 'Get-JCSystemUser', 'Get-JCUser', 'Get-JCUserGroupMember', + 'Import-JCCommand', 'Import-JCMSPFromCSV', 'Import-JCUsersFromCSV', + 'Invoke-JCCommand', 'Invoke-JCDeployment', 'New-JCCommand', + 'New-JCDeploymentTemplate', 'New-JCImportTemplate', + 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', + 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', + 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', + 'Remove-JCCommandTarget', 'Remove-JCGsuiteMember', + 'Remove-JCOffice365Member', 'Remove-JCPolicy', + 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', + 'Remove-JCSystem', 'Remove-JCSystemGroup', + 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', + 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', + 'Send-JCPasswordReset', 'Set-JCCloudDirectory', 'Set-JCCommand', + 'Set-JCOrganization', 'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', + 'Set-JCRadiusServer', 'Set-JCSettingsFile', 'Set-JCSystem', + 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', 'Update-JCModule', 'Update-JCMSPFromCSV', 'Update-JCUsersFromCSV' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 8c9e43f1f..a19c0f544 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,19 +1,3 @@ -## 2.13.2 - - -Release Date: August 20, 2024 - -#### RELEASE NOTES - -``` -TEST - DO NOT MERGE -``` - -#### FEATURES: - -* Get-JCAdmin - Returns administrators in your organization - * MSP/MTP tenants can query multiple organizations or individual organizations - ## 2.13.1 Release Date: August 20, 2024