diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 6ce63097..984a426c 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -1,4 +1,5 @@ # Prologue + **We DO NOT ACCEPT ANY PULL/MERGE REQUEST FOR THIS REPOSITORY**. The right procedure for contributing back via these platform services ARE: @@ -12,6 +13,7 @@ The right procedure for contributing back via these platform services ARE: # Why? + We want to: 1. **Retaining all changes and information inside git log ONLY**; and @@ -35,6 +37,7 @@ identified supply-chain threat. # What is Required in Your Commit Messages + **Write the whole ESSAY of the issue ticket you are working on**. Remember the goal is to capture your commitment from problem to why we should apply your patch. @@ -84,6 +87,7 @@ reviewers know where to digest them. ## GPG Signature for Commit Signature + **Optional but highly recommended** since we are doing manual code-review and automated CI testing internally on our side with our own automation tools. @@ -94,6 +98,7 @@ you internally in the future. # To Generate Patches + To create your patches, please use any of the following `git` command: ```bash @@ -123,6 +128,7 @@ $ git format-patch ^.. --stdout > my.patch # Epilogue + That's all from us. Your pull request **SHALL BE REJECTED WITH PERJUDICE** if you choose to ignore this message. diff --git a/.github/images/sponsor_en_210x50.svg b/.github/images/sponsor_en_210x50.svg new file mode 100644 index 00000000..a959ae0e --- /dev/null +++ b/.github/images/sponsor_en_210x50.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.github/images/sponsor_fr_210x50.svg b/.github/images/sponsor_fr_210x50.svg new file mode 100644 index 00000000..38f894b2 --- /dev/null +++ b/.github/images/sponsor_fr_210x50.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.github/images/sponsor_ms-my_210x50.svg b/.github/images/sponsor_ms-my_210x50.svg new file mode 100644 index 00000000..76595a70 --- /dev/null +++ b/.github/images/sponsor_ms-my_210x50.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.github/images/sponsor_zh-hans_210x50.svg b/.github/images/sponsor_zh-hans_210x50.svg new file mode 100644 index 00000000..168fe122 --- /dev/null +++ b/.github/images/sponsor_zh-hans_210x50.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.github/workflows/git-push.yml b/.github/workflows/git-push.yml index b0288d4e..423fc97d 100644 --- a/.github/workflows/git-push.yml +++ b/.github/workflows/git-push.yml @@ -10,8 +10,6 @@ on: - staging - edge - experimental -env: - PROJECT_PYTHON: 'srcPYTHON/python_version.txt' jobs: develop_on: runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index fac6e818..92506172 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,24 @@ [![AutomataCI](src/icons/icon-1200x400.svg)](#automataci) This is a template git repository equipped with a native built-in -semi-autonomous CI tools known as `AutomataCI`. This allows one to run CI with -or without solely relying on 3rd-party service provider which can becomes a -supply chain threat at least in the 2021-2023 era. +semi-autonomous CI tool known as `AutomataCI`. It allows one to run a full-force +CI jobs with or without solely relying on 3rd-party service providers that +can potentially be a supply chain threat at leas starting from year 2021-2023 +era. ## Why It Matters -Some good business reasons why AutomataCI is made: +Some good business reasons why using AutomataCI: 1. **Start off with a tested and solid foundation** - All the templates and CI jobs are tested and have default configured for immediate software development. -2. **Avoid being threatend by your CI provider** - CI it's a life-support system - for your project; handle it in-house and natively rather than leaving it - vulnerable for 3rd-party vendors to extort it. +2. **Avoid being threatend by your malicious suppliers** - CI it's a + nerve system for your product; handle it in-house and natively rather than + leaving it vulnerable for any 3rd-party to extort you. 3. **Steadily improvable** - AutomataCI itself are designed to be adaptive to market changes, self-improvable, and cater to common use cases. 4. **Simple and scalable** - Only uses `POSIX` shell and `PowerShell` so it @@ -41,7 +42,7 @@ Some good business reasons why AutomataCI is made: 8. [Clang](https://clang.llvm.org/) 9. [MinGW](https://www.mingw-w64.org/) 10. [Emscripten WASM](https://emscripten.org/) -* Node Programming Language (*Coming Soon*) +* Typescript (*Coming Soon*) * [Python Programming Language](https://www.python.org/) * Some Manual MISC stuffs @@ -63,6 +64,24 @@ Some good business reasons why AutomataCI is made: +### 3rd-Party CI Integrations + +AutomataCI works seamlessly out of the box by integration with: + +1. [GitHub Actions](https://docs.github.com/en/actions) +2. [GitLab CI](https://docs.gitlab.com/ee/ci/) (*COMING SOON*) + + + +### Documentations & Specifications + +Check out the PDF file inside +[`automataCI/docs/AutomataCI-Engineering-Specification.pdf`](automataCI/docs/AutomataCI-Engineering-Specification.pdf). + +It's regularly updated from time-to-time before each releases. + + + ## How To Use AutomataCI @@ -93,35 +112,32 @@ By default, the presented product license (`LICENSE.txt`) is using the AutomataCI license. The goal is to change and update it matching to your product license. -Files inside `resources/licenses` shall be updated to match your product -license as well. The `resources/licenses/LICENSE-EN.odt` file is a -[LibreOffice](https://www.libreoffice.org/) writer file. You're free to use -other document generator product as long as it can produce -`resources/licenses/LICENSE-EN.pdf` that will be distributed in various -ecosystem via packages. +You should also update all files inside `src/licenses` matching your own +project. The `src/licenses/LICENSE-EN.odt` file is a +[LibreOffice](https://www.libreoffice.org/) Writer file. Hence, you're free to +use other document generator product as long as it can produce +`src/licenses/LICENSE-EN.pdf` for later packaging distribution use. ### Update Logo By default, the presented icons and banners are of AutomataCI inside -`resources/icons/` directory generated from the materials in -`resources/icons/principle-canvas` using [Inkscape](https://inkscape.org/) +`src/icons/` directory generated from the materials in +`src/icons/principle-canvas` using [Inkscape](https://inkscape.org/) design software. You're free to use other design software as long as it can generate the required output artifacts. -Once you're done designing your product brand in -`resources/icons/principle-canvas` directory, please generate an optimized and -usable graphic artifacts as follow: +Once you're done designing your product brand in `src/icons/principle-canvas` +directory, please generate an optimized and usable graphic artifacts as follow: -1. `resources/icons/icon.svg` - generic and widely-compatible icon file used +1. `src/icons/icon.svg` - generic and widely-compatible icon file used everywhere. -2. `resources/icons/icon-48x48.png` - PNG 48x48 icon file used in Linux system's +2. `src/icons/icon-48x48.png` - PNG 48x48 icon file used in Linux system's + icon and shortcuts. +3. `src/icons/icon-128x128.png` - PNG 48x48 icon file used in Linux system's icon and shortcuts. -3. `resources/icons/icon-128x128.png` - PNG 48x48 icon file used in Linux - system's icon and shortcuts. -4. `resources/icons/icon-1200x400.svg` - used in README.md or marketing - promotion. +4. `src/icons/icon-1200x400.svg` - used in README.md or marketing promotion. @@ -146,7 +162,7 @@ defining the `PROJECT_GO` directory name (default is `srcGO`) at the same time. Choose wisely as the multiple tech feature consideration was made solely for those who wants to use dedicated tech for other purposes (e.g. `SCULLY` for -static documents). +static documents generation). @@ -158,9 +174,9 @@ modify them matching your needs using your POSIX Shell and PowerShell knowledge. -### Update Distribution Resource files +### Update All Distribution Resource files -All the data resource files in `resources/{docs,packages,publishers}` shall be +All the data resource files in `src/{docs,packages,publishers}` shall be updated matching to your product needs. Their specifications are made available in the `automataCI/AutomataCI-Engineering-Specification.pdf` documentation. @@ -248,18 +264,18 @@ and wish to contribute back, there are 2 ways to do so: -### Financial Support +### Financial To financially support the project, please head over to Holloway's sponorship store here: -[![Sponsor](.github/images/sponsor_en_100x30.svg)](https://www.hollowaykeanho.com/stores/) +[![Sponsor](.github/images/sponsor_en_210x50.svg)](https://github.com/sponsors/hollowaykeanho) A small token purchase would helps a lot. -### Craftmanship Support +### Craftmanship If you wish to bring in codes contribution, bug report, and ideas, please feel free to refer the PDF engineering spec located in the `automataCI/` directory. diff --git a/automataCI/SECRETS-template.toml b/automataCI/SECRETS-template.toml new file mode 100644 index 00000000..1dbef3b4 --- /dev/null +++ b/automataCI/SECRETS-template.toml @@ -0,0 +1,36 @@ +###################### +# PYTHON TECHNOLOGY # +###################### +# TWINE_USERNAME +# Use for logging in a PyPi server. This is the account username. Only used +# when PROJECT_PYTHON is enabled. +TWINE_USERNAME = "" + + +# TWINE_PASSWORD +# Use for logging in a PyPi server. This is the account password. Only used +# when PROJECT_PYTHON is enabled. +TWINE_PASSWORD = "" + + + + +########################## +# DISTRIBUTION ECOSYSTEM # +########################## +# PROJECT_GPG_ID +# Your GPG ID for signing here. Note that this requires GPG to be installed in +# the system and the secret key is available for performing such transaction. +PROJECT_GPG_ID ="" + + +# CONTAINER_USERNAME +# Use to login your container image's registry's service provider (e.g. Docker, +# GitHub Packages) etc. This is the account username. +CONTAINER_USERNAME = "" + + +# CONTAINER_PASSWORD +# Use to login your container image's registry's service provider (e.g. Docker, +# GitHub Packages) etc. This is the account password or token value. +CONTAINER_PASSWORD = "" diff --git a/automataCI/_package-pypi_unix-any.sh b/automataCI/_package-pypi_unix-any.sh index af3bbd9d..84145f7d 100644 --- a/automataCI/_package-pypi_unix-any.sh +++ b/automataCI/_package-pypi_unix-any.sh @@ -43,6 +43,7 @@ PACKAGE::run_pypi() { return 0 fi + # prepare workspace and required values _src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}" _target_path="${_dest}/pypi_${_src}" @@ -61,6 +62,7 @@ PACKAGE::run_pypi() { return 1 fi + # copy all complimentary files to the workspace OS::print_status info "assembling package files...\n" if [ -z "$(type -t PACKAGE::assemble_pypi_content)" ]; then @@ -87,6 +89,7 @@ PACKAGE::run_pypi() { ;; esac + # generate required files OS::print_status info "creating pyproject.toml file...\n" PYPI::create_config \ @@ -112,6 +115,7 @@ PACKAGE::run_pypi() { ;; esac + # archive the assembled payload OS::print_status info "archiving PyPi package...\n" FS::make_directory "$_target_path" @@ -121,6 +125,7 @@ PACKAGE::run_pypi() { return 1 fi + # report status return 0 } diff --git a/automataCI/_package-pypi_windows-any.ps1 b/automataCI/_package-pypi_windows-any.ps1 index d84a14a3..6b7c3aec 100644 --- a/automataCI/_package-pypi_windows-any.ps1 +++ b/automataCI/_package-pypi_windows-any.ps1 @@ -44,6 +44,7 @@ function PACKAGE-Run-PYPI { return 0 } + # prepare workspace and required values $_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}" $_target_path = "${_dest}\pypi_${_src}" @@ -62,6 +63,7 @@ function PACKAGE-Run-PYPI { return 1 } + # copy all complimentary files to the workspace OS-Print-Status info "assembling package files..." $__process = OS-Is-Command-Available "PACKAGE-Assemble-PYPI-Content" @@ -84,6 +86,7 @@ function PACKAGE-Run-PYPI { return 1 } + # generate required files OS-Print-Status info "creating pyproject.toml file..." $__process = PYPI-Create-Config ` @@ -104,6 +107,7 @@ function PACKAGE-Run-PYPI { return 1 } + # archive the assembled payload OS-Print-Status info "archiving PyPi package..." $null = FS-Make-Directory "${_target_path}" @@ -113,6 +117,7 @@ function PACKAGE-Run-PYPI { return 1 } + # report status return 0 } diff --git a/automataCI/_release-docker_windows-any.ps1 b/automataCI/_release-docker_windows-any.ps1 index 729a9187..a40da415 100644 --- a/automataCI/_release-docker_windows-any.ps1 +++ b/automataCI/_release-docker_windows-any.ps1 @@ -53,6 +53,7 @@ function RELEASE-Run-DOCKER { $null = FS-Remove-Silently "${_target}" } + # report status return 0 } diff --git a/automataCI/_release-staticrepo_windows-any.ps1 b/automataCI/_release-staticrepo_windows-any.ps1 index 18dca6ad..2033d2db 100644 --- a/automataCI/_release-staticrepo_windows-any.ps1 +++ b/automataCI/_release-staticrepo_windows-any.ps1 @@ -87,8 +87,6 @@ function RELEASE-Run-Static-Repo-Setup { return 1 } - - # execute $__staging = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\${env:PROJECT_PATH_RELEASE}" $__dest = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_RELEASE}\${env:PROJECT_STATIC_REPO_DIRECTORY}" if (Test-Path -PathType Container -Path "${__staging}") { diff --git a/automataCI/ci.sh b/automataCI/ci.sh index f50ac5a5..2d6f2734 100755 --- a/automataCI/ci.sh +++ b/automataCI/ci.sh @@ -1,4 +1,3 @@ -# IMPORTANT NOTE: PLEASE LEAVE THE ABOVE AS IT IS, WHERE IT IS. # Copyright 2023 (Holloway) Chew, Kean Ho # # Licensed under the Apache License, Version 2.0 (the "License"); you may not diff --git a/automataCI/compiler-c_windows-any.ps1 b/automataCI/compiler-c_windows-any.ps1 index 62189c11..bccfe4fa 100644 --- a/automataCI/compiler-c_windows-any.ps1 +++ b/automataCI/compiler-c_windows-any.ps1 @@ -105,6 +105,7 @@ function BUILD-__Validate-Source-Files { } $__line = $__line -replace '/', '\' + # check source code existence $__path = "${env:PROJECT_PATH_ROOT}\${_target_source}" $__path = "${__path}\$($__line -replace '^.*\s', '')" @@ -115,6 +116,7 @@ function BUILD-__Validate-Source-Files { return } + # check source code compatibilities $__os = $__line -replace ' .*$' $__arch = $__os -replace '.*-' @@ -128,6 +130,7 @@ function BUILD-__Validate-Source-Files { continue } + # properly process path $__path = ($__line -split " ")[-1] if ((Split-Path $__path -Parent) -eq $__path) { @@ -137,6 +140,7 @@ function BUILD-__Validate-Source-Files { "${_target_directory}\$(Split-Path $__path -Parent)" } + # create command for parallel execution if ($__path -match "\.c$") { OS-Print-Status info "registering .c file..." @@ -185,6 +189,7 @@ ${_target_directory}\$($__path -replace '.c.*', '.o') $_parallel_total += 1 } + # report status return $_parallel_total } @@ -396,6 +401,7 @@ function BUILD-_Exec-Link { return 1 } + # convert pathing to be GCC friendly $__directory = Split-Path -Parent -Path "${_linker_control}" $__file = Split-Path -Leaf -Path "${_linker_control}" diff --git a/automataCI/docs/AutomataCI-Engineering-Specification.odt b/automataCI/docs/AutomataCI-Engineering-Specification.odt index 0849459b..9707d078 100644 Binary files a/automataCI/docs/AutomataCI-Engineering-Specification.odt and b/automataCI/docs/AutomataCI-Engineering-Specification.odt differ diff --git a/automataCI/docs/AutomataCI-Engineering-Specification.pdf b/automataCI/docs/AutomataCI-Engineering-Specification.pdf index fd4094d7..6bd9867a 100644 Binary files a/automataCI/docs/AutomataCI-Engineering-Specification.pdf and b/automataCI/docs/AutomataCI-Engineering-Specification.pdf differ diff --git a/automataCI/services/archive/ar.ps1 b/automataCI/services/archive/ar.ps1 index 1ab3f5f5..d0f3ad8b 100644 --- a/automataCI/services/archive/ar.ps1 +++ b/automataCI/services/archive/ar.ps1 @@ -15,11 +15,14 @@ function AR-Is-Available { + # execute $__process = Get-Command "ar" -ErrorAction SilentlyContinue if (-not ($__process)) { return 1 } + + # report status return 0 } @@ -32,6 +35,7 @@ function AR-Create { [string]$__list ) + # validate input if ([string]::IsNullOrEmpty($__name) -or [string]::IsNullOrEmpty($__list)) { return 1 @@ -42,9 +46,11 @@ function AR-Create { return 1 } + # execute $__process = OS-Exec "ar" "r ${__name} ${__list}" + # report status return $__process } diff --git a/automataCI/services/archive/ar.sh b/automataCI/services/archive/ar.sh index b0158166..fe5a7abb 100644 --- a/automataCI/services/archive/ar.sh +++ b/automataCI/services/archive/ar.sh @@ -11,10 +11,12 @@ # License for the specific language governing permissions and limitations under # the License. AR::is_available() { + # execute if [ -z "$(type -t ar)" ]; then return 1 fi + # report status return 0 } @@ -25,17 +27,21 @@ AR::create() { # __name="$1" # __list="$2" + # validate input if [ -z "$1" ] || [ -z "$2" ]; then return 1 fi + # execute ar r "$1" $2 + # report status if [ $? -eq 0 ]; then return 0 fi + return 1 } diff --git a/automataCI/services/archive/zip.ps1 b/automataCI/services/archive/zip.ps1 index 4847dd13..a10ad74e 100644 --- a/automataCI/services/archive/zip.ps1 +++ b/automataCI/services/archive/zip.ps1 @@ -15,6 +15,7 @@ function ZIP-Create { [string]$__source ) + # execute try { Compress-Archive -Path $__source -DestinationPath $__destination if (Test-Path $__destination) { @@ -31,5 +32,6 @@ function ZIP-Create { function ZIP-Is-Available { + # report status return 0 } diff --git a/automataCI/services/archive/zip.sh b/automataCI/services/archive/zip.sh index 4dc23b1c..e7ce4755 100644 --- a/automataCI/services/archive/zip.sh +++ b/automataCI/services/archive/zip.sh @@ -11,10 +11,12 @@ # License for the specific language governing permissions and limitations under # the License. ZIP::is_available() { + # execute if [ ! -z "$(type -t zip)" ]; then return 0 fi + # report status return 1 } @@ -25,15 +27,18 @@ ZIP::create() { # __destination="$1" # __source="$2" + # validate input ZIP::is_available if [ $? -ne 0 ]; then return 1 fi + # execute zip -9 -r "$1" $2 + # report status if [ $? -eq 0 ]; then return 0 diff --git a/automataCI/services/checksum/md5.ps1 b/automataCI/services/checksum/md5.ps1 index 53a48ece..698bb952 100644 --- a/automataCI/services/checksum/md5.ps1 +++ b/automataCI/services/checksum/md5.ps1 @@ -36,10 +36,13 @@ function MD5-Checksum-File { function MD5-Is-Available { + # execute $__md5 = [System.Security.Cryptography.MD5]::Create("MD5") if ($__md5) { return 0 } + + # report status return 1 } diff --git a/automataCI/services/checksum/md5.sh b/automataCI/services/checksum/md5.sh index 491231fc..a4a53b72 100644 --- a/automataCI/services/checksum/md5.sh +++ b/automataCI/services/checksum/md5.sh @@ -40,9 +40,12 @@ MD5::checksum_file() { MD5::is_available() { + # execute if [ ! -z "$(type -t md5sum)" ] || [ ! -z "$(type -t md5)" ]; then return 0 fi + + # report status return 1 } diff --git a/automataCI/services/checksum/shasum.ps1 b/automataCI/services/checksum/shasum.ps1 index e8826a6d..87f9a59a 100644 --- a/automataCI/services/checksum/shasum.ps1 +++ b/automataCI/services/checksum/shasum.ps1 @@ -15,6 +15,7 @@ function SHASUM-Checksum-File { [string]$__algo ) + # validate input if ([string]::IsNullOrEmpty($__target) -or (-not (Test-Path -Path "$__target")) -or @@ -22,6 +23,7 @@ function SHASUM-Checksum-File { return "" } + # execute switch ($__algo) { '1' { @@ -51,6 +53,7 @@ function SHASUM-Checksum-File { function SHASUM-Is-Available { + # execute $__ret = [System.Security.Cryptography.SHA1]::Create("SHA1") if (-not $__ret) { return 1 @@ -71,5 +74,7 @@ function SHASUM-Is-Available { return 1 } + + # report status return 0 } diff --git a/automataCI/services/checksum/shasum.sh b/automataCI/services/checksum/shasum.sh index 15868974..bf50a7b4 100644 --- a/automataCI/services/checksum/shasum.sh +++ b/automataCI/services/checksum/shasum.sh @@ -14,6 +14,7 @@ SHASUM::create_file() { #__target="$1" #__algo="$2" + # validate input if [ -z "$1" ] || [ ! -f "$1" ] || [ -z "$2" ]; then return 1 @@ -27,6 +28,7 @@ SHASUM::create_file() { ;; esac + # execute if [ ! -z "$(type -t shasum)" ]; then __ret="$(shasum -a "$2" "$1")" @@ -38,6 +40,7 @@ SHASUM::create_file() { unset __ret fi + # report status return 0 } @@ -46,9 +49,12 @@ SHASUM::create_file() { SHASUM::is_available() { + # execute if [ ! -z "$(type -t shasum)" ]; then return 0 fi + + # report status return 1 } diff --git a/automataCI/services/compilers/changelog.ps1 b/automataCI/services/compilers/changelog.ps1 index d244b8d9..bf1a7c90 100644 --- a/automataCI/services/compilers/changelog.ps1 +++ b/automataCI/services/compilers/changelog.ps1 @@ -31,6 +31,7 @@ function CHANGELOG-Assemble-DEB { $__directory = "${__directory}\deb" $__target = $__target -replace '\.gz.*$' + # assemble file $null = FS-Remove-Silently "${__target}" $null = FS-Remove-Silently "${__target}.gz" @@ -68,9 +69,11 @@ function CHANGELOG-Assemble-DEB { } } + # gunzip $__process = GZ-Create "${__target}" + # report status return $__process } @@ -95,6 +98,7 @@ function CHANGELOG-Assemble-MD { $__directory = "${__directory}\data" + # assemble file $null = FS-Remove-Silently "${__target}" $null = FS-Make-Housing-Directory "${__target}" @@ -121,6 +125,7 @@ function CHANGELOG-Assemble-MD { } } + # report status return $__process } @@ -139,6 +144,7 @@ function CHANGELOG-Assemble-RPM { [string]$__cadence ) + # validate input if ([string]::IsNullOrEmpty($__target) -or [string]::IsNullOrEmpty($__resources) -or @@ -152,12 +158,14 @@ function CHANGELOG-Assemble-RPM { return 1 } + # emit stanza $__process = FS-Write-File "${__target}" "%%changelog`n" if ($__process -ne 0) { return 1 } + # emit latest changelog if (Test-Path -Path "${__resources}\changelog\data\latest") { $__process = FS-Append-File "${__target}" ` @@ -184,9 +192,11 @@ function CHANGELOG-Assemble-RPM { } } + # emit tailing newline $__process = FS-Append-File "${__target}" "`n" + # report status return $__process } @@ -199,17 +209,20 @@ function CHANGELOG-Build-Data-Entry { [string]$__directory ) + # validate input if ([string]::IsNullOrEmpty($__directory)) { return 1 } + # get last tag from git log $__tag = Invoke-Expression "git rev-list --tags --max-count=1" if ([string]::IsNullOrEmpty($__tag)) { $__tag = Invoke-Expression "git rev-list --max-parents=0 --abbrev-commit HEAD" } + # generate log file from the latest to the last tag $__directory = "${__directory}\data" $null = FS-Make-Directory "${__directory}" @@ -219,10 +232,12 @@ function CHANGELOG-Build-Data-Entry { return 1 } + # good file, update the previous $null = FS-Remove-Silently "${__directory}\latest" $__process = FS-Move "${__directory}\.latest" "${__directory}\latest" + # report status return $__process } @@ -242,6 +257,7 @@ function CHANGELOG-Build-DEB-Entry { [string]$__date ) + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__version) -or @@ -255,7 +271,6 @@ function CHANGELOG-Build-DEB-Entry { return 1 } - switch ($__dist) { stable { break @@ -269,15 +284,18 @@ function CHANGELOG-Build-DEB-Entry { return 1 }} + # all good. Generate the log fragment $null = FS-Make-Directory "${__directory}\deb" + # create the entry header $null = FS-Write-File "${__directory}\deb\.latest" @" ${__sku} (${__version}) ${__dist}; urgency=${__urgency} "@ + # generate body line-by-line Get-Content -Path "${__directory}\data\latest" | ForEach-Object { $__line = $_.Substring(0, [Math]::Min($_.Length, 80)) @@ -285,13 +303,16 @@ ${__sku} (${__version}) ${__dist}; urgency=${__urgency} } $null = FS-Append-File "${__directory}\deb\.latest" "" + # create the entry sign-off $null = FS-Append-File "${__directory}\deb\.latest" ` "-- ${__name} <${__email}> ${__date}" + # good file, update the previous $__process = FS-Move "${__directory}\deb\.latest" "${__directory}\deb\latest" + # report status return $__process } @@ -305,15 +326,21 @@ function CHANGELOG-Compatible-Data-Version { [string]$__version ) + + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__version)) { return 1 } + + # execute $__process = FS-Is-File "${__directory}\data\${__version}" if ($__process -ne 0) { return 0 } + + # report status return 1 } @@ -326,15 +353,21 @@ function CHANGELOG-Compatible-DEB-Version { [string]$__version ) + + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__version)) { return 1 } + + # execute $__process = FS-Is-File "${__directory}\deb\${__version}" if ($__process -ne 0) { return 0 } + + # report status return 1 } @@ -342,6 +375,7 @@ function CHANGELOG-Compatible-DEB-Version { function CHANGELOG-Is-Available { + # execute $__program = Get-Command git -ErrorAction SilentlyContinue if (-not ($__program)) { return 1 @@ -352,6 +386,8 @@ function CHANGELOG-Is-Available { return 1 } + + # report status return 0 } @@ -364,6 +400,7 @@ function CHANGELOG-Seal { [string]$__version ) + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__version) -or @@ -379,6 +416,7 @@ function CHANGELOG-Seal { return 1 } + # execute $__process = FS-Move "${__directory}\data\latest" "${__directory}\data\${__version}" if ($__process -ne 0) { @@ -390,6 +428,7 @@ function CHANGELOG-Seal { return 1 } + # report status return 0 } diff --git a/automataCI/services/compilers/changelog.sh b/automataCI/services/compilers/changelog.sh index cab2f7ab..aebcbe3d 100644 --- a/automataCI/services/compilers/changelog.sh +++ b/automataCI/services/compilers/changelog.sh @@ -21,6 +21,7 @@ CHANGELOG::assemble_deb() { __target="$2" __version="$3" + # validate input if [ -z "$__directory" ] || [ -z "$__target" ] || [ -z "$__version" ]; then return 1 @@ -29,6 +30,7 @@ CHANGELOG::assemble_deb() { __directory="${__directory}/deb" __target="${__target%.gz*}" + # assemble file FS::remove_silently "$__target" FS::remove_silently "${__target}.gz" @@ -66,9 +68,11 @@ CHANGELOG::assemble_deb() { IFS="$old_IFS" unset old_IFS __line __tag + # gunzip GZ::create "$__target" + # report status if [ $? -eq 0 ]; then return 0 @@ -86,6 +90,7 @@ CHANGELOG::assemble_md() { __version="$3" __title="$4" + # validate input if [ -z "$__directory" ] || [ -z "$__target" ] || @@ -96,6 +101,7 @@ CHANGELOG::assemble_md() { __directory="${__directory}/data" + # assemble file FS::remove_silently "$__target" FS::make_housing_directory "$__target" @@ -125,6 +131,7 @@ CHANGELOG::assemble_md() { IFS="$old_IFS" unset old_IFS __line __tag + # report status if [ $? -eq 0 ]; then return 0 @@ -145,6 +152,7 @@ CHANGELOG::assemble_rpm() { __version="$6" __cadence="$7" + # validate input if [ -z "$__target" ] || [ -z "$__resources" ] || @@ -158,12 +166,14 @@ CHANGELOG::assemble_rpm() { return 1 fi + # emit stanza FS::append_file "$__target" "%%changelog\n" if [ $? -ne 0 ]; then return 1 fi + # emit latest changelog if [ -f "${__resources}/changelog/data/latest" ]; then FS::append_file "$__target" \ @@ -192,12 +202,14 @@ CHANGELOG::assemble_rpm() { fi fi + # emit tailing newline FS::append_file "$__target" "\n" if [ $? -ne 0 ]; then return 1 fi + # report status return 0 } @@ -208,17 +220,20 @@ CHANGELOG::assemble_rpm() { CHANGELOG::build_data_entry() { __directory="$1" + # validate input if [ -z "$__directory" ]; then return 1 fi + # get last tag from git log __tag="$(git rev-list --tags --max-count=1)" if [ -z "$__tag" ]; then __tag="$(git rev-list --max-parents=0 --abbrev-commit HEAD)" fi + # generate log file from the latest to the last tag __directory="${__directory}/data" FS::make_directory "$__directory" @@ -227,14 +242,17 @@ CHANGELOG::build_data_entry() { return 1 fi + # good file, update the previous FS::remove_silently "${__directory}/latest" &> /dev/null FS::move "${__directory}/.latest" "${__directory}/latest" + # report verdict if [ $? -eq 0 ]; then return 0 fi + return 1 } @@ -251,6 +269,7 @@ CHANGELOG::build_deb_entry() { __email="$7" __date="$8" + # validate input if [ -z "$__directory" ] || [ -z "$__version" ] || @@ -272,15 +291,18 @@ CHANGELOG::build_deb_entry() { ;; esac + # all good. Generate the log fragment FS::make_directory "${__directory}/deb" + # create the entry header FS::append_file "${__directory}/deb/.latest" "\ ${__sku} (${__version}) ${__dist}; urgency=${__urgency} " + # generate body line-by-line old_IFS="$IFS" while IFS="" read -r line || [ -n "$line" ]; do @@ -291,17 +313,21 @@ ${__sku} (${__version}) ${__dist}; urgency=${__urgency} unset line old_IFS FS::append_file "${__directory}/deb/.latest" "\n" + # create the entry signed-off FS::append_file "${__directory}/deb/.latest" \ "-- ${__name} <${__email}> ${__date}\n" + # good file, update the previous FS::move "${__directory}/deb/.latest" "${__directory}/deb/latest" + # report status if [ $? -eq 0 ]; then return 0 fi + return 1 } @@ -312,14 +338,20 @@ CHANGELOG::compatible_data_version() { __directory="$1" __version="$2" + + # validate input if [ -z "$__directory" ] || [ -z "$__version" ]; then return 1 fi + + # execute if [ ! -f "${__directory}/data/${__version}" ]; then return 0 fi + + # report status return 1 } @@ -330,14 +362,20 @@ CHANGELOG::compatible_deb_version() { __directory="$1" __version="$2" + + # validate input if [ -z "$__directory" ] || [ -z "$__version" ]; then return 1 fi + + # execute if [ ! -f "${__directory}/deb/${__version}" ]; then return 0 fi + + # report status return 1 } @@ -345,6 +383,7 @@ CHANGELOG::compatible_deb_version() { CHANGELOG::is_available() { + # execute if [ -z "$(type -t git)" ]; then return 1 fi @@ -354,6 +393,8 @@ CHANGELOG::is_available() { return 1 fi + + # report status return 0 } @@ -364,6 +405,7 @@ CHANGELOG::seal() { __directory="$1" __version="$2" + # validate input if [ -z "$__directory" ] || [ -z "$__version" ] || [ ! -d "$__directory" ]; then return 1 @@ -377,6 +419,7 @@ CHANGELOG::seal() { return 1 fi + # execute FS::move "${__directory}/data/latest" "${__directory}/data/${__version}" if [ $? -ne 0 ]; then @@ -388,6 +431,7 @@ CHANGELOG::seal() { return 1 fi + # report status return 0 } diff --git a/automataCI/services/compilers/flatpak.ps1 b/automataCI/services/compilers/flatpak.ps1 index b6478b58..26dcb41c 100644 --- a/automataCI/services/compilers/flatpak.ps1 +++ b/automataCI/services/compilers/flatpak.ps1 @@ -22,21 +22,25 @@ function FLATPAK-Create-AppInfo { [string]$__resources ) + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__resources)) { return 1 } + # check for overriding manifest file if (Test-Path "${__directory}\appdata.xml") { return 2 } + # check appinfo is available if (-not (Test-Path "${__resources}\packages\flatpak.xml")) { return 1 } + # copy flatpak.xml to workspace return FS-Copy-File "${__resources}\packages\flatpak.xml" "${__directory}\appdata.xml" } @@ -53,6 +57,7 @@ function FLATPAK-Create-Archive { [string]$__gpg_id ) + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__destination) -or @@ -69,10 +74,12 @@ function FLATPAK-Create-Archive { $__path_manifest = ".\manifest.yml" $null = FS-Make-Directory "${__repo}" + # change location into the workspace $__current_path = Get-Location Set-Location -Path $__directory + # build archive if (-not (Test-Path $__path_manifest)) { return 1 @@ -125,13 +132,16 @@ function FLATPAK-Create-Archive { return 1 } + # export output $__process = FS-Move "${__path_build}" "${__destination}" + # head back to current directory Set-Location -Path ${__current_path} Remove-Variable -Name __current_path + # report status return $__process } @@ -151,6 +161,7 @@ function FLATPAK-Create-Manifest { [string]$__sdk ) + # validate input if ([string]::IsNullOrEmpty($__location) -or [string]::IsNullOrEmpty($__resources) -or @@ -165,12 +176,14 @@ function FLATPAK-Create-Manifest { return 1 } + # check for overriding manifest file if ((Test-Path "${__location}\manifest.yml") -or (Test-Path "${__location}\manifest.json")) { return 2 } + # generate manifest app metadata fields $__target = "${__location}\manifest.yml" $null = FS-Write-File "${__target}" @" @@ -198,6 +211,7 @@ modules: path: appdata.xml "@ + # process icon.svg if (Test-Path "${__location}\icon.svg") { $null = FS-Append-File "${__target}" @" @@ -211,6 +225,7 @@ modules: "@ } + # process icon-48x48.png if (Test-Path "${__location}\icon-48x48.png") { $null = FS-Append-File "${__target}" @" @@ -224,6 +239,7 @@ modules: "@ } + # process icon-128x128.png if (Test-Path "${__location}\icon-128x128.png") { $null = FS-Append-File "${__target}" @" @@ -237,6 +253,7 @@ modules: "@ } + # append more setup if available if (Test-Path "${__resources}\packages\flatpak.yml") { foreach($__line in Get-Content "${__resources}\packages\flatpak.yml") { @@ -252,6 +269,7 @@ modules: } } + # report status return 0 } @@ -269,6 +287,7 @@ function FLATPAK-Is-Available { return 1 } + # check compatible target os switch ($__os) { windows { @@ -279,6 +298,7 @@ function FLATPAK-Is-Available { Break }} + # check compatible target cpu architecture switch ($__arch) { any { @@ -287,12 +307,14 @@ function FLATPAK-Is-Available { Break }} + # validate dependencies $__process = OS-Is-Command-Available "flatpak-builder" if ($__process -ne 0) { return 1 } + # report status return 0 } @@ -306,17 +328,20 @@ function FLATPAK-Test-Build { [string]$__command ) + # validate input if ([string]::IsNullOrEmpty($__target) -or [string]::IsNullOrEmpty($__command)) { return 1 } + # execute $__arguments = "--run `"${__target}`" " + "`"${__target}\files\manifest.json`" " + "${__command}" $__process = OS-Exec "flatpak-builder" $__arguments + # report status if ($__process -eq 0) { return 0 diff --git a/automataCI/services/compilers/flatpak.sh b/automataCI/services/compilers/flatpak.sh index a1d19446..46f45af7 100644 --- a/automataCI/services/compilers/flatpak.sh +++ b/automataCI/services/compilers/flatpak.sh @@ -21,26 +21,31 @@ FLATPAK::create_appinfo() { __directory="$1" __resources="$2" + # validate input if [ -z "$__directory" ] || [ -z "$__resources" ]; then return 1 fi + # check for overriding manifest file if [ -f "${__directory}/appdata.xml" ]; then return 2 fi + # check appinfo is available if [ ! -f "${__resources}/packages/flatpak.xml" ]; then return 1 fi + # copy flatpak.xml to workspace FS::copy_file "${__resources}/packages/flatpak.xml" "${__directory}/appdata.xml" if [ $? -ne 0 ]; then return 1 fi + return 0 } @@ -54,6 +59,7 @@ FLATPAK::create_archive() { __app_id="$4" __gpg_id="$5" + # validate input if [ -z "$__directory" ] || [ -z "$__destination" ] || @@ -70,10 +76,12 @@ FLATPAK::create_archive() { __path_manifest="./manifest.yml" FS::make_directory "$__repo" + # change location into the workspace __current_path="$PWD" cd "$__directory" + # build archive if [ ! -f "$__path_manifest" ]; then return 1 @@ -110,17 +118,21 @@ FLATPAK::create_archive() { return 1 fi + # export output FS::move "$__path_package" "$__destination" __exit=$? + # head back to current directory cd "${__current_path}" && unset __current_path + # report status if [ $__exit -ne 0 ]; then return 1 fi + return 0 } @@ -137,6 +149,7 @@ FLATPAK::create_manifest() { __runtime_version="$7" __sdk="$8" + # validate input if [ -z "$__location" ] || [ -z "$__resources" ] || @@ -151,11 +164,13 @@ FLATPAK::create_manifest() { return 1 fi + # check for overriding manifest file if [ -f "${__location}/manifest.yml" ] || [ -f "${__location}/manifest.json" ]; then return 2 fi + # generate manifest app metadata fields __target="${__location}/manifest.yml" FS::write_file "$__target" "\ @@ -184,6 +199,7 @@ modules: path: appdata.xml " + # process icon.svg if [ -f "${__location}/icon.svg" ]; then FS::write_file "$__target" "\ @@ -197,6 +213,7 @@ modules: " fi + # process icon-48x48.png if [ -f "${__location}/icon-48x48.png" ]; then FS::write_file "$__target" "\ @@ -210,6 +227,7 @@ modules: " fi + # process icon-128x128.png if [ -f "${__location}/icon-128x128.png" ]; then FS::write_file "$__target" "\ @@ -223,6 +241,7 @@ modules: " fi + # append more setup if available if [ -f "${__resources}/packages/flatpak.yml" ]; then old_IFS="$IFS" @@ -240,6 +259,7 @@ modules: IFS="$old_IFS" && unset old_IFS fi + # report status return 0 } @@ -255,6 +275,7 @@ FLATPAK::is_available() { return 1 fi + # check compatible target os case "$__os" in windows|darwin) @@ -264,6 +285,7 @@ FLATPAK::is_available() { ;; esac + # check compatible target cpu architecture case "$__arch" in any) @@ -273,12 +295,14 @@ FLATPAK::is_available() { ;; esac + # validate dependencies OS::is_command_available "flatpak-builder" if [ $? -ne 0 ]; then return 1 fi + # report status return 0 } @@ -290,17 +314,20 @@ FLATPAK::test_build() { __target="$1" __command="$2" + # validate input if [ -z "$__target" ] || [ -z "$__command" ]; then return 1 fi + # execute flatpak-builder \ --run "$__target" \ "${__target}/files/manifest.json" \ "$__command" + # report status if [ $? -eq 0 ]; then return 0 diff --git a/automataCI/services/compilers/go.ps1 b/automataCI/services/compilers/go.ps1 index 9ad02ac0..988b2bdd 100644 --- a/automataCI/services/compilers/go.ps1 +++ b/automataCI/services/compilers/go.ps1 @@ -94,6 +94,7 @@ function GO-Setup-Local-Environment { return 1 } + # execute $__process = GO-Is-Available if ($__process -ne 0) { diff --git a/automataCI/services/compilers/installer.sh b/automataCI/services/compilers/installer.sh index 2c401257..a383659f 100644 --- a/automataCI/services/compilers/installer.sh +++ b/automataCI/services/compilers/installer.sh @@ -31,6 +31,7 @@ INSTALLER::setup() { return 0 fi + # execute /bin/bash -c \ "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" @@ -89,9 +90,11 @@ INSTALLER::setup_curl() { return 0 fi + # execute brew install curl + # report status if [ $? -eq 0 ]; then return 0 @@ -168,12 +171,14 @@ INSTALLER::setup_docker() { return 0 fi + # execute DOCKER::setup_builder_multiarch if [ $? -ne 0 ]; then return 1 fi + # report status return 0 } @@ -193,9 +198,11 @@ INSTALLER::setup_go() { return 0 fi + # execute brew install go + # report status if [ $? -eq 0 ]; then return 0 @@ -290,9 +297,11 @@ INSTALLER::setup_python() { return 0 fi + # execute brew install python + # report status if [ $? -eq 0 ]; then return 0 @@ -389,9 +398,11 @@ INSTALLER::setup_reprepro() { return 0 fi + # execute brew install reprepro + # report status if [ $? -eq 0 ]; then return 0 diff --git a/automataCI/services/compilers/python.ps1 b/automataCI/services/compilers/python.ps1 index 72607242..f349e835 100644 --- a/automataCI/services/compilers/python.ps1 +++ b/automataCI/services/compilers/python.ps1 @@ -23,6 +23,7 @@ function PYTHON-Activate-VENV { return 0 } + # execute $__location = "$(PYTHON-Get-Activator-Path)" if (-not (Test-Path "${__location}")) { @@ -35,6 +36,7 @@ function PYTHON-Activate-VENV { return 1 } + # report status return 0 } @@ -47,17 +49,20 @@ function PYTHON-Clean-Artifact { [string]$__target ) + # validate input if ([string]::IsNullOrEmpty($__target) -or (-not (Test-Path -Path "${__target}" -PathType Container))) { return 1 } + # execute $null = Get-ChildItem -Path "${__target}" -Recurse ` | Where-Object {$_.Name -match "__pycache__|\.pyc$" } ` | Remove-Item -Force -Recurse + # report status return 0 } @@ -82,11 +87,14 @@ function PYTHON-Has-PIP { function PYTHON-Is-Available { + # execute $__program = Get-Command python -ErrorAction SilentlyContinue if ($__program) { return 0 } + + # report status return 1 } @@ -94,10 +102,13 @@ function PYTHON-Is-Available { function PYTHON-Is-VENV-Activated { + # execute if ($env:VIRTUAL_ENV) { return 0 } + + # report status return 1 } @@ -118,17 +129,20 @@ function PYTHON-Setup-VENV { return 1 } + # execute $__process = PYTHON-Is-Available if ($__process -ne 0) { return 1 } + # check if the repo is already established... if (Test-Path "$(PYTHON-Get-Activator-Path)") { return 0 } + # it's a clean repo. Start setting up virtual environment... $__location = "${env:PROJECT_PATH_ROOT}" ` + "\${env:PROJECT_PATH_TOOLS}" ` @@ -142,6 +156,7 @@ function PYTHON-Setup-VENV { return 1 } + # report status return 0 } @@ -150,11 +165,14 @@ function PYTHON-Setup-VENV { function PYPI-Check-Login { + # execute if ([string]::IsNullOrEmpty($env:TWINE_USERNAME) -or [string]::IsNullOrEmpty($env:TWINE_PASSWORD)) { return 1 } + + # report status return 0 } @@ -167,12 +185,14 @@ function PYPI-Is-Available { return 1 } + # execute $__process = PYTHON-Is-VENV-Activated if ($__process -ne 0) { return 1 } + # report status return 0 } @@ -185,12 +205,14 @@ function PYPI-Is-Valid { [string]$__target ) + # validate input if ([string]::IsNullOrEmpty(${__target}) -or (-not (Test-Path -Path "${__target}" -PathType Container))) { return 1 } + # execute $__process = STRINGS-Has-Prefix "pypi" (Split-Path -Leaf -Path "${__target}") if ($__process -ne 0) { @@ -210,6 +232,7 @@ function PYPI-Is-Valid { return 0 } + # report status return 1 } @@ -231,6 +254,7 @@ function PYPI-Create-Config { [string]$__license ) + # validate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__project_name) -or @@ -247,11 +271,13 @@ function PYPI-Create-Config { return 1 } + # check existing overriding file if (Test-Path -Path "${__directory}\pyproject.toml") { return 2 } + # create default file $__process = FS-Write-File "${__directory}\pyproject.toml" @" [build-system] @@ -282,6 +308,7 @@ email = '${__email}' Homepage = '${__website}' "@ + # report status return $__process } @@ -295,6 +322,7 @@ function PYPI-Create-Archive { [string]$__destination ) + # valdiate input if ([string]::IsNullOrEmpty($__directory) -or [string]::IsNullOrEmpty($__destination) -or @@ -309,6 +337,7 @@ function PYPI-Create-Archive { return 1 } + # construct archive $__current_path = Get-Location Set-Location -Path $__directory @@ -329,6 +358,7 @@ function PYPI-Create-Archive { Set-Location -Path $__current_path Remove-Variable -Name __current_path + # export to destination foreach ($__file in (Get-ChildItem -Path "${__directory}\dist")) { $__process = FS-Move "${__directory}\dist\${__file}" "${__destination}" @@ -337,6 +367,7 @@ function PYPI-Create-Archive { } } + # report status return 0 } @@ -351,6 +382,7 @@ function PYPI-Release { [string]$__url ) + # validate input if ([string]::IsNullOrEmpty($__target) -or [string]::IsNullOrEmpty($__gpg) -or @@ -369,6 +401,7 @@ function PYPI-Release { return 1 } + # execute $__arguments = "upload " ` + "--sign " ` @@ -380,6 +413,7 @@ function PYPI-Release { return 1 } + # report status return 0 } diff --git a/automataCI/services/compilers/python.sh b/automataCI/services/compilers/python.sh index e956169e..eb5dff8b 100644 --- a/automataCI/services/compilers/python.sh +++ b/automataCI/services/compilers/python.sh @@ -24,6 +24,7 @@ PYTHON::activate_venv() { return 0 fi + # execute __location="$(PYTHON::get_activator_path)" if [ ! -f "$__location" ]; then @@ -36,6 +37,7 @@ PYTHON::activate_venv() { return 1 fi + # report status return 0 } @@ -46,6 +48,7 @@ PYTHON::activate_venv() { PYTHON::clean_artifact() { # __target="$1" + # validate input if [ -z "$1" ] || [ ! -d "$1" ]; then return 1 @@ -56,9 +59,11 @@ PYTHON::clean_artifact() { return 1 fi + # execute find "$1" | grep -E "(__pycache__|\.pyc$)" | xargs rm -rf &> /dev/null + # report status return 0 } @@ -84,12 +89,15 @@ PYTHON::has_pip() { PYTHON::is_available() { + # execute if [ ! -z "$(type -t python3)" ]; then return 0 elif [ ! -z "$(type -t python)" ]; then return 0 fi + + # report status return 1 } @@ -97,10 +105,13 @@ PYTHON::is_available() { PYTHON::is_venv_activated() { + # execute if [ ! -z "$VIRTUAL_ENV" ] ; then return 0 fi + + # report status return 1 } @@ -121,6 +132,7 @@ PYTHON::setup_venv() { return 1 fi + # execute __program="" if [ ! -z "$(type -t python3)" ]; then @@ -137,6 +149,7 @@ PYTHON::setup_venv() { return 0 fi + # it's a clean repo. Start setting up virtual environment... __location="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TOOLS}/${PROJECT_PATH_PYTHON_ENGINE}" $__program -m venv "$__location" @@ -148,6 +161,7 @@ PYTHON::setup_venv() { return 1 fi + # report status return 0 } @@ -156,11 +170,13 @@ PYTHON::setup_venv() { PYPI::check_login() { - # validate input + # execute if [ -z "$TWINE_USERNAME" ] || [ -z "$TWINE_PASSWORD" ]; then return 1 fi + + # report status return 0 } @@ -173,12 +189,14 @@ PYPI::is_available() { return 1 fi + # execute PYTHON::is_venv_activated if [ $? -ne 0 ]; then return 1 fi + # report status return 0 } @@ -189,11 +207,13 @@ PYPI::is_available() { PYPI::is_valid() { #__target="$1" + # validate input if [ -z "$1" ] || [ ! -d "$1" ]; then return 1 fi + # execute STRINGS::has_prefix "pypi" "${1##*/}" if [ $? -ne 0 ]; then @@ -216,6 +236,7 @@ PYPI::is_valid() { return 0 fi + # report status return 1 } @@ -235,6 +256,7 @@ PYPI::create_config() { __readme_type="$9" __license="${10}" + # validate input if [ -z "$__directory" ] || [ -z "$__project_name" ] || @@ -251,11 +273,13 @@ PYPI::create_config() { return 1 fi + # check existing overriding file if [ -f "${__directory}/pyproject.toml" ]; then return 2 fi + # create default file FS::write_file "${__directory}/pyproject.toml" "\ [build-system] @@ -286,6 +310,7 @@ email = '${__email}' Homepage = '${__website}' " + # report status return $? } @@ -297,6 +322,7 @@ PYPI::create_archive() { __directory="$1" __destination="$2" + # validate input if [ -z "$__directory" ] || [ -z "$__destination" ] || @@ -311,6 +337,7 @@ PYPI::create_archive() { return 1 fi + # construct archive __current_path="$PWD" && cd "$__directory" python -m build --sdist --wheel . @@ -326,6 +353,7 @@ PYPI::create_archive() { fi cd "$__current_path" && unset __current_path + # export to destination for __file in "${__directory}/dist/"*; do FS::move "$__file" "$__destination" @@ -334,6 +362,7 @@ PYPI::create_archive() { fi done + # report status return 0 } @@ -346,6 +375,7 @@ PYPI::release() { __gpg="$2" __url="$3" + # validate input if [ -z "$__target" ] || [ -z "$__gpg" ] || @@ -364,6 +394,7 @@ PYPI::release() { return 1 fi + # execute twine upload "${__target}/"* \ --sign \ @@ -374,6 +405,7 @@ PYPI::release() { return 1 fi + # report status return 0 } diff --git a/automataCI/services/compress/gz.ps1 b/automataCI/services/compress/gz.ps1 index 03172571..8dd69d78 100644 --- a/automataCI/services/compress/gz.ps1 +++ b/automataCI/services/compress/gz.ps1 @@ -19,6 +19,7 @@ function GZ-Create { [string]$__source ) + # validate input $__process = GZ-Is-Available if ($__process -ne 0) { @@ -30,6 +31,7 @@ function GZ-Create { } $__source = $__source -replace "\.gz$" + # create .gz compressed target if ((OS-Is-Command-Available "gzip") -eq 0) { $__process = OS-Exec "gzip" "-9 `"${__source}`"" @@ -39,6 +41,7 @@ function GZ-Create { $__process = 1 } + # report status return $__process } @@ -47,6 +50,7 @@ function GZ-Create { function GZ-Is-Available { + # execute $__process = OS-Is-Command-Available "gzip" if ($__process -eq 0) { return 0 @@ -57,5 +61,7 @@ function GZ-Is-Available { return 0 } + + # report status return 1 } diff --git a/automataCI/services/compress/gz.sh b/automataCI/services/compress/gz.sh index b0205275..1d589d2f 100644 --- a/automataCI/services/compress/gz.sh +++ b/automataCI/services/compress/gz.sh @@ -18,6 +18,7 @@ GZ::create() { __source="$1" + # validate input GZ::is_available if [ $? -ne 0 ]; then @@ -29,6 +30,7 @@ GZ::create() { fi __source="${__source%.gz}" + # create .gz compressed target if [ ! -z "$(type -t gzip)" ]; then gzip -9 $__source @@ -40,10 +42,12 @@ GZ::create() { __exit=1 fi + # report status if [ $__exit -ne 0 ]; then return 1 fi + return 0 } @@ -51,6 +55,7 @@ GZ::create() { GZ::is_available() { + # execute OS::is_command_available "gzip" if [ $? -eq 0 ]; then return 0 @@ -61,5 +66,7 @@ GZ::is_available() { return 0 fi + + # report status return 1 } diff --git a/automataCI/services/compress/xz.ps1 b/automataCI/services/compress/xz.ps1 index 32502bae..cca884cb 100644 --- a/automataCI/services/compress/xz.ps1 +++ b/automataCI/services/compress/xz.ps1 @@ -19,6 +19,7 @@ function XZ-Create { [string]$__source ) + # validate input $__process = XZ-Is-Available if ($__process -ne 0) { @@ -30,9 +31,11 @@ function XZ-Create { } $__source = $__source -replace "\.xz$" + # create .gz compressed target $__process = OS-Exec "xz" "-9 --compress `"${__source}`"" + # report status return $__process } @@ -41,10 +44,13 @@ function XZ-Create { function XZ-Is-Available { + # execute $__process = OS-Is-Command-Available "xz" if ($__process -eq 0) { return 0 } + + # report status return 1 } diff --git a/automataCI/services/compress/xz.sh b/automataCI/services/compress/xz.sh index 7dc40d30..3da1a066 100644 --- a/automataCI/services/compress/xz.sh +++ b/automataCI/services/compress/xz.sh @@ -18,6 +18,7 @@ XZ::create() { __source="$1" + # validate input XZ::is_available if [ $? -ne 0 ]; then @@ -30,9 +31,11 @@ XZ::create() { fi __source="${__source%.xz}" + # create .gz compressed target xz -9 --compress "$__source" + # report status if [ $? -eq 0 ]; then return 0 @@ -45,10 +48,13 @@ XZ::create() { XZ::is_available() { + # execute OS::is_command_available "xz" if [ $? -eq 0 ]; then return 0 fi + + # report status return 1 } diff --git a/automataCI/services/io/disk.ps1 b/automataCI/services/io/disk.ps1 index 4fdd4f8e..cf9f0265 100644 --- a/automataCI/services/io/disk.ps1 +++ b/automataCI/services/io/disk.ps1 @@ -14,6 +14,7 @@ function DISK-Calculate-Size { [string]$__location ) + # validate input if ([string]::IsNullOrEmpty($__location) -or (-not (Test-Path -Path "$__location"))) { return 1 @@ -24,6 +25,7 @@ function DISK-Calculate-Size { return 1 } + # execute $__value = Get-ChildItem ${__location} -Recurse -Force ` -ErrorAction SilentlyContinue -Include * ` diff --git a/automataCI/services/io/disk.sh b/automataCI/services/io/disk.sh index ed858424..de5f34cd 100644 --- a/automataCI/services/io/disk.sh +++ b/automataCI/services/io/disk.sh @@ -13,6 +13,7 @@ DISK::calculate_size() { # __location="$1" + # validate input if [ -z "$1" ] || [ ! -d "$1" ]; then return 1 @@ -23,9 +24,11 @@ DISK::calculate_size() { return 1 fi + # execute __size="$(du -ks "$1")" + # report status if [ $? -ne 0 ]; then return 1 @@ -39,9 +42,12 @@ DISK::calculate_size() { DISK::is_available() { + # execute if [ ! -z "$(type -t du)" ]; then return 0 fi + + # report status return 1 } diff --git a/automataCI/services/io/os.ps1 b/automataCI/services/io/os.ps1 index f3e9acb6..99456022 100644 --- a/automataCI/services/io/os.ps1 +++ b/automataCI/services/io/os.ps1 @@ -14,11 +14,13 @@ function OS-Is-Command-Available { [string] $__command ) + # validate input if ([string]::IsNullOrEmpty($__command)) { return 1 } + # execute $__program = Get-Command $__command -ErrorAction SilentlyContinue if ($__program) { @@ -36,17 +38,20 @@ function OS-Exec { [string]$__arguments ) + # validate input if ([string]::IsNullOrEmpty($__command) -or [string]::IsNullOrEmpty($__arguments)) { return 1 } + # get program $__program = Get-Command $__command -ErrorAction SilentlyContinue if (-not ($__program)) { return 1 } + # execute command $__process = Start-Process -Wait ` -FilePath "$__program" ` diff --git a/automataCI/services/io/os.sh b/automataCI/services/io/os.sh index b90794a8..c0df85a3 100644 --- a/automataCI/services/io/os.sh +++ b/automataCI/services/io/os.sh @@ -13,11 +13,13 @@ OS::is_command_available() { # __command="$1" + # validate input if [ -z "$1" ]; then return 1 fi + # execute if [ ! -z "$(type -t "$1")" ]; then return 0 diff --git a/automataCI/services/publishers/createrepo.ps1 b/automataCI/services/publishers/createrepo.ps1 index 080b0698..29de8546 100644 --- a/automataCI/services/publishers/createrepo.ps1 +++ b/automataCI/services/publishers/createrepo.ps1 @@ -16,6 +16,7 @@ function CREATEREPO-Is-Available { + # execute $__process = OS-Is-Command-Available "createrepo" if ($__process -eq 0) { return 0 @@ -26,6 +27,7 @@ function CREATEREPO-Is-Available { return 0 } + # report status return 1 } @@ -39,6 +41,7 @@ function CREATEREPO-Publish { [string]$__directory ) + # validate input if ([string]::IsNullOrEmpty($__target) -or [string]::IsNullOrEmpty($__directory) -or @@ -47,6 +50,7 @@ function CREATEREPO-Publish { return 1 } + # execute $__process = FS-Copy-File "${__target}" "${__directory}" if ($__process -ne 0) { @@ -69,6 +73,7 @@ function CREATEREPO-Publish { } } + # report status return 1 } diff --git a/automataCI/services/publishers/createrepo.sh b/automataCI/services/publishers/createrepo.sh index fc802eed..8139abab 100644 --- a/automataCI/services/publishers/createrepo.sh +++ b/automataCI/services/publishers/createrepo.sh @@ -17,6 +17,7 @@ CREATEREPO::is_available() { + # execute OS::is_command_available "createrepo" if [ $? -eq 0 ]; then return 0 @@ -27,6 +28,8 @@ CREATEREPO::is_available() { return 0 fi + + # report status return 1 } @@ -37,6 +40,7 @@ CREATEREPO::publish() { __target="$1" __directory="$2" + # validate input if [ -z "$__target" ] || [ -z "$__directory" ] || @@ -45,6 +49,7 @@ CREATEREPO::publish() { return 1 fi + # execute FS::copy_file "$__target" "$__directory" if [ $? -ne 0 ]; then @@ -67,6 +72,7 @@ CREATEREPO::publish() { fi fi + # report status return 1 } diff --git a/src/changelog/data/latest b/src/changelog/data/latest index a8322e62..b5aed842 100644 --- a/src/changelog/data/latest +++ b/src/changelog/data/latest @@ -1,3 +1,4 @@ +root: added ipk packaging function srcPYTHON: backported chocolatey packaging function to Python srcGO: backported chocolatey packaging function to Go root: added and close Chocolatey ecosystem diff --git a/src/changelog/deb/latest b/src/changelog/deb/latest index 57aede38..90715995 100644 --- a/src/changelog/deb/latest +++ b/src/changelog/deb/latest @@ -1,5 +1,6 @@ automataci (1.6.0) stable; urgency=low + * root: added ipk packaging function * srcPYTHON: backported chocolatey packaging function to Python * srcGO: backported chocolatey packaging function to Go * root: added and close Chocolatey ecosystem @@ -20,4 +21,4 @@ automataci (1.6.0) stable; urgency=low * root: added C Programming Language support * README.md: corrected typo --- Your Legal Full Name Here Tue, 10 Oct 2023 16:41:31 +0800 +-- Your Legal Full Name Here Tue, 10 Oct 2023 21:26:29 +0800