From 2a3a89db2f09ea30b6a4fc0ba801c5f235b8e3d2 Mon Sep 17 00:00:00 2001 From: JGStew Date: Mon, 11 Apr 2022 18:11:39 -0400 Subject: [PATCH 1/7] Create AutoPkg-Release-Source.download.recipe.yaml new recipe from https://github.com/jgstew/jgstew-recipes/blob/main/AutoPkgRecipe/AutoPkgRelease.download.recipe.yaml --- ...utoPkg-Release-Source.download.recipe.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 AutoPkg/AutoPkg-Release-Source.download.recipe.yaml diff --git a/AutoPkg/AutoPkg-Release-Source.download.recipe.yaml b/AutoPkg/AutoPkg-Release-Source.download.recipe.yaml new file mode 100644 index 00000000..4d7f9573 --- /dev/null +++ b/AutoPkg/AutoPkg-Release-Source.download.recipe.yaml @@ -0,0 +1,23 @@ +--- +Description: Download Source zip for Released AutoPkg +# based upon: https://github.com/jgstew/jgstew-recipes/blob/main/AutoPkgRecipe/AutoPkgRelease.download.recipe.yaml +Identifier: com.github.autopkg.download.AutoPkgReleaseSource +Input: + NAME: autopkg +MinimumVersion: "2.3" +Process: + - Processor: GitHubReleasesInfoProvider + Arguments: + # https://github.com/autopkg/autopkg/releases/tag/v2.4.1 + # https://github.com/autopkg/autopkg/archive/refs/tags/v2.4.1.zip + github_repo: autopkg/autopkg + #asset_regex: ".*.zip" + - Processor: URLDownloader + Arguments: + url: "https://github.com/autopkg/autopkg/archive/refs/tags/v%version%.zip" + filename: autopkg.zip + # NOTE: a valid %GITHUB_TOKEN% is only required if running in a GitHub Action: + # - if run locally without %GITHUB_TOKEN% this should still work unless you hit API limits locally + # - https://github.community/t/using-github-token-in-http-call-to-api/16608/8?u=jgstew + request_headers: {"authorization": "Bearer %GITHUB_TOKEN%"} + - Processor: EndOfCheckPhase From bb61e5ef10230055c0d5c6b3b2f4741e64bd363b Mon Sep 17 00:00:00 2001 From: JGStew Date: Mon, 11 Apr 2022 18:16:15 -0400 Subject: [PATCH 2/7] Create AutoPkg-Release.nupkg.recipe.yaml originally from: https://github.com/jgstew/jgstew-recipes/blob/main/AutoPkgRecipe/AutoPkgRelease.nupkg.recipe.yaml --- AutoPkg/AutoPkg-Release.nupkg.recipe.yaml | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 AutoPkg/AutoPkg-Release.nupkg.recipe.yaml diff --git a/AutoPkg/AutoPkg-Release.nupkg.recipe.yaml b/AutoPkg/AutoPkg-Release.nupkg.recipe.yaml new file mode 100644 index 00000000..9705c1b7 --- /dev/null +++ b/AutoPkg/AutoPkg-Release.nupkg.recipe.yaml @@ -0,0 +1,33 @@ +--- +# Based upon: https://github.com/autopkg/recipes/blob/master/AutoPkg/AutoPkgGitMaster.nupkg.recipe +Description: Build Chocolatey Package for Released AutoPkg +Identifier: com.github.autopkg.nupkg.AutoPkgRelease +Input: + NAME: autopkg + PYTHON_PACKAGE_ID: python3 + PYTHON_VERSION: "3.8" +MinimumVersion: "2.3" +SupportedPlatforms: + - Windows +ParentRecipe: com.github.autopkg.download.AutoPkgReleaseSource +Process: + - Processor: ChocolateyPackager + Arguments: + id: "%NAME%" + version: "%version%" + title: "%NAME%" + authors: Autopkg Contributors + description: AutoPkg is an automation framework software packaging and distribution, oriented towards the tasks one would normally perform manually to prepare third-party software for mass deployment to managed clients. + installer_type: zip + dependencies: + - {"id": "%PYTHON_PACKAGE_ID%", "version": "%PYTHON_VERSION%"} + additional_install_actions: | + $AutoPkgDir = Resolve-Path $env:ChocolateyPackageFolder\tools\autopkg-* + & python -m venv $AutoPkgDir\.python-env + Write-Output 'Running "pip install ..." to generate self-contained environment.' + & $AutoPkgDir\.python-env\Scripts\pip --disable-pip-version-check install -r $AutoPkgDir\requirements.txt --quiet + Get-ChildItem -Recurse $AutoPkgDir\.python-env -Include *.exe, *.dll | + foreach { New-Item -ItemType File "$($_.FullName).ignore" } | Write-Verbose + Install-ChocolateyPowershellCommand -PackageName $packageArgs.packageName -PsFileFullPath $AutoPkgDir\Scripts\autopkg.ps1 + +# TODO: set output var `nuget_package_path` to ENV for further github action use From e1e4a76b1596065487b972e6b949b1428c99f72a Mon Sep 17 00:00:00 2001 From: JGStew Date: Mon, 11 Apr 2022 18:18:19 -0400 Subject: [PATCH 3/7] Rename AutoPkg-Release.nupkg.recipe.yaml to AutoPkg-Release-Source.nupkg.recipe.yaml --- ...nupkg.recipe.yaml => AutoPkg-Release-Source.nupkg.recipe.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename AutoPkg/{AutoPkg-Release.nupkg.recipe.yaml => AutoPkg-Release-Source.nupkg.recipe.yaml} (100%) diff --git a/AutoPkg/AutoPkg-Release.nupkg.recipe.yaml b/AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml similarity index 100% rename from AutoPkg/AutoPkg-Release.nupkg.recipe.yaml rename to AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml From 9f562d602ce190aea0232844b0b3d73442aa73ba Mon Sep 17 00:00:00 2001 From: jgstew Date: Mon, 11 Apr 2022 18:33:39 -0400 Subject: [PATCH 4/7] test recipes for autopkg release nupkg --- .github/workflows/AutoPkgReleaseNupkg.yaml | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/AutoPkgReleaseNupkg.yaml diff --git a/.github/workflows/AutoPkgReleaseNupkg.yaml b/.github/workflows/AutoPkgReleaseNupkg.yaml new file mode 100644 index 00000000..59350b14 --- /dev/null +++ b/.github/workflows/AutoPkgReleaseNupkg.yaml @@ -0,0 +1,74 @@ +--- +name: Test AutoPkg Release Nupkg +# based upon: https://github.com/autopkg/recipes/blob/master/AutoPkg/AutoPkgGitMaster.nupkg.recipe + +on: + push: + paths: + - ".github/workflows/AutoPkgReleaseNupkg.yaml" + - "AutoPkg/AutoPkg-Release-Source.download.recipe.yaml" + - "AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml" + pull_request: + paths: + - ".github/workflows/AutoPkgReleaseNupkg.yaml" + - "AutoPkg/AutoPkg-Release-Source.download.recipe.yaml" + - "AutoPkg/AutoPkg-Release-Source.nupkg.recipe.yaml" + +jobs: + AutoPkgNupkg: + runs-on: windows-latest + steps: + # only needed on self hosted windows runners: + - name: set powershell execution policy CurrentUser + if: runner.os == 'Windows' + shell: cmd + run: powershell -command "Set-ExecutionPolicy -Force -ExecutionPolicy RemoteSigned -Scope CurrentUser" + + - name: Set token + # required for githubreleaseinfoprovider in github actions + # without this, API limits will be hit + run: | + cd ~ + echo ${{ secrets.GITHUB_TOKEN }} > ".autopkg_gh_token" + + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.8 + + # - name: Install requirements + # run: pip install --requirement requirements.txt + - name: rename folder, git clone autopkg + shell: cmd + run: | + rename "AutoPkg" "AutoPkgRecipe" + git clone https://github.com/autopkg/autopkg.git + - name: Install AutoPkg Reqirements + run: pip install --requirement autopkg/requirements.txt + - name: create empty config windows + # https://stackoverflow.com/questions/57946173/github-actions-run-step-on-specific-os + if: runner.os == 'Windows' + shell: cmd + run: | + if not exist "%USERPROFILE%/AppData/Local/Autopkg" mkdir "%USERPROFILE%/AppData/Local/Autopkg" + if not exist "%USERPROFILE%/AppData/Local/Autopkg/config.json" echo {} > "%USERPROFILE%/AppData/Local/Autopkg/config.json" + - name: create default autopkg config file Linux + if: runner.os == 'Linux' + run: | + cd ~ && mkdir -p .config/Autopkg + cd ~ && echo {} > .config/Autopkg/config.json + - name: run nupkg recipe + run: python autopkg/Code/autopkg run -v AutoPkgRecipe/AutoPkg-Release-Source.nupkg.recipe.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: chocolately install python + # python versions: 3.8.10, 3.9.12, 3.10.4 + # - See Here: https://community.chocolatey.org/packages/python#versionhistory + run: choco install python3 --version 3.9.12 --no-progress --yes --force --force-dependencies + - name: test chocolately install autopkg.nupkg + run: choco install autopkg -s "C:\Users\runneradmin\Library\AutoPkg\Cache\com.github.jgstew.nupkg.AutoPkg\nupkgs\" --no-progress --yes --force --force-dependencies + - name: test autopkg chocolately install + run: autopkg help +# Related: +# - https://github.com/jgstew/bigfix-content/blob/master/.github/workflows/autopkg.yaml From 6d56f970e131c6d6e114c925b37166f4398d3afa Mon Sep 17 00:00:00 2001 From: jgstew Date: Mon, 11 Apr 2022 18:40:00 -0400 Subject: [PATCH 5/7] fix install nupkg path --- .github/workflows/AutoPkgReleaseNupkg.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/AutoPkgReleaseNupkg.yaml b/.github/workflows/AutoPkgReleaseNupkg.yaml index 59350b14..f243f5f2 100644 --- a/.github/workflows/AutoPkgReleaseNupkg.yaml +++ b/.github/workflows/AutoPkgReleaseNupkg.yaml @@ -67,7 +67,7 @@ jobs: # - See Here: https://community.chocolatey.org/packages/python#versionhistory run: choco install python3 --version 3.9.12 --no-progress --yes --force --force-dependencies - name: test chocolately install autopkg.nupkg - run: choco install autopkg -s "C:\Users\runneradmin\Library\AutoPkg\Cache\com.github.jgstew.nupkg.AutoPkg\nupkgs\" --no-progress --yes --force --force-dependencies + run: choco install autopkg -s "$env:USERPROFILE\Library\AutoPkg\Cache\com.github.autopkg.nupkg.AutoPkgRelease\nupkgs" --no-progress --yes --force --force-dependencies - name: test autopkg chocolately install run: autopkg help # Related: From 5eaceb2a31da9a5d83de1246e3e2a7004b5de49d Mon Sep 17 00:00:00 2001 From: jgstew Date: Mon, 11 Apr 2022 18:48:40 -0400 Subject: [PATCH 6/7] add test recipe --- .github/workflows/AutoPkgReleaseNupkg.yaml | 4 +- .../AutopkgCoreProcessors.test.recipe.yaml | 41 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 AutoPkg/AutopkgCoreProcessors.test.recipe.yaml diff --git a/.github/workflows/AutoPkgReleaseNupkg.yaml b/.github/workflows/AutoPkgReleaseNupkg.yaml index f243f5f2..7277733d 100644 --- a/.github/workflows/AutoPkgReleaseNupkg.yaml +++ b/.github/workflows/AutoPkgReleaseNupkg.yaml @@ -58,6 +58,8 @@ jobs: run: | cd ~ && mkdir -p .config/Autopkg cd ~ && echo {} > .config/Autopkg/config.json + - name: run test recipe + run: python autopkg/Code/autopkg run -v com.github.autopkg.test.AutoPkgCoreProcessors - name: run nupkg recipe run: python autopkg/Code/autopkg run -v AutoPkgRecipe/AutoPkg-Release-Source.nupkg.recipe.yaml env: @@ -69,6 +71,6 @@ jobs: - name: test chocolately install autopkg.nupkg run: choco install autopkg -s "$env:USERPROFILE\Library\AutoPkg\Cache\com.github.autopkg.nupkg.AutoPkgRelease\nupkgs" --no-progress --yes --force --force-dependencies - name: test autopkg chocolately install - run: autopkg help + run: autopkg run -v com.github.autopkg.test.AutoPkgCoreProcessors # Related: # - https://github.com/jgstew/bigfix-content/blob/master/.github/workflows/autopkg.yaml diff --git a/AutoPkg/AutopkgCoreProcessors.test.recipe.yaml b/AutoPkg/AutopkgCoreProcessors.test.recipe.yaml new file mode 100644 index 00000000..8932491b --- /dev/null +++ b/AutoPkg/AutopkgCoreProcessors.test.recipe.yaml @@ -0,0 +1,41 @@ +--- +Description: Test AutoPkg Core Cross Platform Processors +Identifier: com.github.autopkg.test.AutoPkgCoreProcessors +Input: + NAME: AutoPkgCoreTest +MinimumVersion: "2.3" +Process: + # TODO: add: PlistEditor, PlistReader, Unarchiver, Versioner + - Processor: DeprecationWarning + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/DeprecationWarning.py + Arguments: + warning_message: "This is just a test, not a real Deprecation Warning" + - Processor: FileCreator + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/FileCreator.py + Arguments: + file_path: "test_file.txt" + file_content: "Hello World! FileCreator Processor test" + - Processor: FileFinder + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/FileFinder.py + Arguments: + pattern: "**test_file.txt" + - Processor: FileMover + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/FileMover.py + Arguments: + source: "test_file.txt" + target: "test_file_moved.txt" + - Processor: Copier + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/Copier.py + Arguments: + source_path: "test_file_moved.txt" + destination_path: "test_file.txt" + - Processor: PackageRequired + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/PackageRequired.py + Arguments: + PKG: "test_file.txt" + # PathDeleter should have an option to NOT raise an error if file not found + # it is a common practice to "delete" before copy or "delete" before move + - Processor: PathDeleter + # https://github.com/autopkg/autopkg/blob/master/Code/autopkglib/PathDeleter.py + Arguments: + path_list: ["test_file.txt", "test_file_moved.txt"] From c67e4695abdfeefbea8d4ff17fb965a0bf909a06 Mon Sep 17 00:00:00 2001 From: jgstew Date: Mon, 11 Apr 2022 18:53:10 -0400 Subject: [PATCH 7/7] seems like the choco installed autopkg has less output --- .github/workflows/AutoPkgReleaseNupkg.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/AutoPkgReleaseNupkg.yaml b/.github/workflows/AutoPkgReleaseNupkg.yaml index 7277733d..1c792934 100644 --- a/.github/workflows/AutoPkgReleaseNupkg.yaml +++ b/.github/workflows/AutoPkgReleaseNupkg.yaml @@ -71,6 +71,6 @@ jobs: - name: test chocolately install autopkg.nupkg run: choco install autopkg -s "$env:USERPROFILE\Library\AutoPkg\Cache\com.github.autopkg.nupkg.AutoPkgRelease\nupkgs" --no-progress --yes --force --force-dependencies - name: test autopkg chocolately install - run: autopkg run -v com.github.autopkg.test.AutoPkgCoreProcessors + run: autopkg run -vv com.github.autopkg.test.AutoPkgCoreProcessors # Related: # - https://github.com/jgstew/bigfix-content/blob/master/.github/workflows/autopkg.yaml