Skip to content

Commit

Permalink
root: added DOTNET's nupkg implementations
Browse files Browse the repository at this point in the history
Since DOTNET's nupkg is quite simple to create and to upstream,
it's best we support it from the start. Besides, the Chocolatey
is one of the nupkg implementations so no worries.

This patch adds DOTNET's nupkg implementations in root
repository.

Co-authored-by: Shuralyov, Jean <[email protected]>
Co-authored-by: Galyna, Cory <[email protected]>
Co-authored-by: (Holloway) Chew, Kean Ho <[email protected]>
Signed-off-by: (Holloway) Chew, Kean Ho <[email protected]>
  • Loading branch information
3 people committed Jun 21, 2024
1 parent 288912c commit 521c473
Show file tree
Hide file tree
Showing 72 changed files with 3,850 additions and 141 deletions.
56 changes: 46 additions & 10 deletions CONFIG.toml
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,15 @@ PROJECT_BOOK = 'srcBOOK'
PROJECT_C = 'srcC'


# PROJECT_C_BRANCH_TAG
# PROJECT_C_ID
# This is for technology tagging purposes such as but not limited to release
# branches identification. The value shall always be lowercase, short, and
# directly identify it is C technology.
# directly identify as a C-based technology.
#
# This field shall not be EMPTY.
#
# Default is: 'c'
# To disable: set it empty ''
PROJECT_C_BRANCH_TAG = 'c'
PROJECT_C_ID = 'c'



Expand Down Expand Up @@ -628,14 +629,15 @@ PROJECT_NODE_VERSION = 'v22.2.0'
PROJECT_NODE_NPM_REGISTRY = 'https://npm.pkg.github.com'


# PROJECT_NODE_BRANCH_TAG
# PROJECT_NODE_NPM_ID
# This is for technology tagging purposes such as but not limited to release
# branches identification. The value shall always be lowercase, short, and
# directly identify it is Node technology.
# directly identify as a Node NPM technology.
#
# This field shall not be EMPTY.
#
# Default is: 'npm'
# To disable: set it empty ''
PROJECT_NODE_BRANCH_TAG = 'npm'
PROJECT_NODE_NPM_ID = 'npm'



Expand Down Expand Up @@ -888,15 +890,25 @@ PROJECT_RELEASE_IPK = 'enabled'
PROJECT_CHOCOLATEY_URL = 'https://github.com/ChewKeanHo/AutomataCI/releases/latest/download'




# PROJECT_CHOCOLATEY_VERSION
# The Chocolatey version as a dependency. This field SHALL NOT BE EMPTY.
#
# Default value is: '0.9.8.21'
PROJECT_CHOCOLATEY_VERSION = '0.9.8.21'


# PROJECT_CHOCOLATEY_ID
# This is for technology tagging purposes such as but not limited to release
# branches identification. The value shall always be lowercase, short, and
# directly identify as Chocolatey technology (including away from the original
# DOTNET nupkg).
#
# This field shall not be EMPTY.
#
# Default is: 'chocolatey'
PROJECT_CHOCOLATEY_ID = 'chocolatey'




#############################
Expand Down Expand Up @@ -1664,6 +1676,30 @@ PROJECT_MSI_DOCS_COMPONENT_GUID = '7E665EAF-446B-7738-84D9-FE18BE039404'



##########################
# DISTRIBUTION - NUPKG #
##########################
# PROJECT_NUPKG_URL
# The registry url for publishing the DOTNET .nupkg package file. More info:
# (1) https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry
# (2) https://learn.microsoft.com/en-us/nuget/api/package-publish-resource
# (3) https://learn.microsoft.com/en-us/nuget/api/overview
#
# Some examples:
# (1) GitHub Package: 'https://nuget.pkg.github.com/[USERNAME]'
# (2) Nuget.org : 'https://www.nuget.org/api/v2/package'
#
# This field also acts as the flag for enabling or disabling the nupkg pipeline.
#
# To enable : fill in the end-user downloadable URL without ending slash.
# To disable: leave this field empty ('').
#
# !! IMPORTANT !! - Please avoid ending with the URL slash.
PROJECT_NUPKG_URL = 'https://nuget.pkg.github.com/ChewKeanHo'




##########################
# DISTRIBUTION - RPM #
##########################
Expand Down
11 changes: 11 additions & 0 deletions automataCI/SECRETS-template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ NPM_TOKEN = ""



######################
# NUPKG TECHNOLOGY #
######################
# NUPKG_TOKEN
# The Authentication token (e.g. 'Authentication: ' or 'X-NuGet-ApiKey: ') for
# logging into the corresponding NUPKG registry defined in the CONFIG.toml.
NUPKG_TOKEN = ""




######################
# PYTHON TECHNOLOGY #
######################
Expand Down
33 changes: 14 additions & 19 deletions automataCI/_package-chocolatey_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ PACKAGE_Run_CHOCOLATEY() {

# prepare workspace and required values
I18N_Create_Package "CHOCOLATEY"
_src="${_target_filename}_${PROJECT_VERSION}_${_target_os}-${_target_arch}"
_src="${PROJECT_CHOCOLATEY_ID}-${_target_filename}"
_src="${_src}_${PROJECT_VERSION}_${_target_os}-${_target_arch}"
_target_path="${_dest}/${_src}"
_src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-choco-${_src}"
_src="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/packagers-${_src}"
I18N_Remake "$_src"
FS_Remake_Directory "$_src"
if [ $? -ne 0 ]; then
Expand All @@ -91,6 +92,7 @@ PACKAGE_Run_CHOCOLATEY() {
return 0
;;
0)
# accepted
;;
*)
I18N_Assemble_Failed
Expand All @@ -100,29 +102,22 @@ PACKAGE_Run_CHOCOLATEY() {


# check nuspec file is available
I18N_Check ".nuspec"
__name=""
for __file in "${_src}/"*.nuspec; do
FS_Is_File "${__file}"
if [ $? -eq 0 ]; then
if [ $(STRINGS_Is_Empty "$__name") -ne 0 ]; then
I18N_Check_Failed
return 1
fi

__name="${__file##*/}"
__name="${__name%.nuspec*}"
fi
done

if [ $(STRINGS_Is_Empty "$__name") -eq 0 ]; then
__name="${_src}/.nuspec"
I18N_Check "$__name"
FS_Is_File "$__name"
if [ $? -ne 0 ]; then
I18N_Check_Failed
return 1
fi


# archive the assembled payload
__name="${__name}-chocolatey_${PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg"
__name="${PROJECT_SKU}-${PROJECT_CHOCOLATEY_ID}"
FS_Is_Target_A_Library "${_target_filename}"
if [ $? -ne 0 ]; then
__name="lib${__name}"
fi
__name="${__name}_${PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg"
__name="${_dest}/${__name}"
I18N_Archive "$__name"
CHOCOLATEY_Archive "$__name" "$_src"
Expand Down
28 changes: 13 additions & 15 deletions automataCI/_package-chocolatey_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ function PACKAGE-Run-CHOCOLATEY {

# prepare workspace and required values
$null = I18N-Create-Package "CHOCOLATEY"
$_src = "${_target_filename}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}"
$_src = "${env:PROJECT_CHOCOLATEY_ID}-${_target_filename}"
$_src = "${_src}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}"
$_target_path = "${_dest}\${_src}"
$_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-choco-${_src}"
$_src = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\packagers-${_src}"
$null = I18N-Remake "${_src}"
$___process = FS-Remake-Directory "${_src}"
if ($___process -ne 0) {
Expand Down Expand Up @@ -94,25 +95,22 @@ function PACKAGE-Run-CHOCOLATEY {


# check nuspec is available
$null = I18N-Check ".nuspec metadata"
$__name = ""
foreach ($__file in (Get-ChildItem -File -Path "${_src}\*.nuspec")) {
if ($(STRINGS-Is-Empty "${__name}") -ne 0) {
$null = I18N-Check-Failed
return 1
}

$__name = $__file.Name -replace '\.nuspec.*$', ''
}

if ($(STRINGS-Is-Empty "${__name}") -eq 0) {
$__name = "${_src}\.nuspec"
$null = I18N-Check "${__name}"
$___process = FS-Is-File "${__name}"
if ($___process -ne 0) {
$null = I18N-Check-Failed
return 1
}


# archive the assembled payload
$__name = "${__name}-chocolatey_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg"
$__name = "${env:PROJECT_SKU}-${env:PROJECT_CHOCOLATEY_ID}"
$___process = FS-Is-Target-A-Library "${_target_filename}"
if ($___process -eq 0) {
$__name = "lib${__name}"
}
$__name = "${__name}_${env:PROJECT_VERSION}_${_target_os}-${_target_arch}.nupkg"
$__name = "${_dest}\${__name}"
$null = I18N-Archive "${__name}"
$___process = CHOCOLATEY-Archive "${__name}" "${_src}"
Expand Down
4 changes: 3 additions & 1 deletion automataCI/_release-citation_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ RELEASE_Run_CITATION_CFF() {
# execute
I18N_Publish "CITATION.cff"
if [ $(OS_Is_Run_Simulated) -ne 0 ]; then
FS_Copy_File "$1" "${PROJECT_PATH_ROOT}/CITATION.cff"
__dest="${PROJECT_PATH_ROOT}/CITATION.cff"
FS_Remove_Silently "$__dest"
FS_Copy_File "$1" "$__dest"
if [ $? -ne 0 ]; then
I18N_Publish_Failed
return 1
Expand Down
4 changes: 3 additions & 1 deletion automataCI/_release-citation_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function RELEASE-Run-CITATION-CFF {
# execute
$null = I18N-Publish "CITATION.cff"
if ($(OS-Is-Run-Simulated) -ne 0) {
$___process = FS-Copy-File "${__target}" "${env:PROJECT_PATH_ROOT}\CITATION.cff"
$__dest = "${env:PROJECT_PATH_ROOT}\CITATION.cff"
$null = FS-Remove-Silently "${__dest}"
$___process = FS-Copy-File "${__target}" "${__dest}"
if ($___process -ne 0) {
$null = I18N-Publish-Failed
return 1
Expand Down
16 changes: 11 additions & 5 deletions automataCI/_release-lib_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ RELEASE_Run_LIBS() {
return 0
fi

if [ $(FS_Is_Target_A_TARGZ "$1") -ne 0 ] ||
[ $(FS_Is_Target_A_TARXZ "$1") -ne 0 ] ||
[ $(FS_Is_Target_A_ZIP "$1") -ne 0 ]; then
return 0
fi

GIT_Is_Available
if [ $? -ne 0 ]; then
return 0
Expand All @@ -56,17 +62,17 @@ RELEASE_Run_LIBS() {
# execute
__branch="v${PROJECT_VERSION}"
if [ $(FS_Is_Target_A_NPM "$1") -eq 0 ]; then
if [ $(STRINGS_Is_Empty "$PROJECT_NODE_BRANCH_TAG") -eq 0 ]; then
if [ $(STRINGS_Is_Empty "$PROJECT_NODE_NPM_ID") -eq 0 ]; then
return 0
fi

__branch="${__branch}_${PROJECT_NODE_BRANCH_TAG}"
__branch="${__branch}_${PROJECT_NODE_NPM_ID}"
elif [ $(FS_Is_Target_A_C "$1") -eq 0 ]; then
if [ $(STRINGS_Is_Empty "$PROJECT_C_BRANCH_TAG") -eq 0 ]; then
if [ $(STRINGS_Is_Empty "$PROJECT_C_ID") -eq 0 ]; then
return 0
fi

__branch="${__branch}_${PROJECT_C_BRANCH_TAG}"
__branch="${__branch}_${PROJECT_C_ID}"
else
return 0
fi
Expand Down Expand Up @@ -97,7 +103,7 @@ RELEASE_Run_LIBS() {
elif [ $(FS_Is_Target_A_ZIP "$1") -eq 0 ]; then
ZIP_Extract "$__workspace" "$1"
else
FS_Copy_File "$1" "${__workspace}"
FS_Copy_File "$1" "${__workspace}/$(FS_Get_File "$1")"
fi

if [ $? -ne 0 ]; then
Expand Down
18 changes: 13 additions & 5 deletions automataCI/_release-lib_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ function RELEASE-Run-LIBS {
return 0
}

if (($(FS-Is-Target-A-TARGZ "${__target}") -ne 0) -or
($(FS-Is-Target-A-TARXZ "${__target}") -ne 0) -or
($(FS-Is-Target-A-ZIP "${__target}") -ne 0)) {
return 0
}

$___process = GIT-Is-Available
if ($___process -ne 0) {
return 0
Expand All @@ -58,17 +64,17 @@ function RELEASE-Run-LIBS {
# execute
$__branch = "v${env:PROJECT_VERSION}"
if ($(FS-Is-Target-A-NPM "${__target}") -eq 0) {
if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_BRANCH_TAG}") -eq 0) {
if ($(STRINGS-Is-Empty "${env:PROJECT_NODE_NPM_ID}") -eq 0) {
return 0
}

$__branch = "${__branch}_${env:PROJECT_NODE_BRANCH_TAG}"
$__branch = "${__branch}_${env:PROJECT_NODE_NPM_ID}"
} elseif ($(FS-Is-Target-A-C "${__target}") -eq 0) {
if ($(STRINGS-Is-Empty "${env:PROJECT_C_BRANCH_TAG}") -eq 0) {
if ($(STRINGS-Is-Empty "${env:PROJECT_C_ID}") -eq 0) {
return 0
}

$__branch = "${__branch}_${env:PROJECT_C_BRANCH_TAG}"
$__branch = "${__branch}_${env:PROJECT_C_ID}"
} else {
return 0
}
Expand Down Expand Up @@ -102,7 +108,9 @@ function RELEASE-Run-LIBS {
} elseif ($(FS-Is-Target-A-ZIP "${__target}") -eq 0) {
$___process = ZIP-Extract "${__workspace}" "${__target}"
} else {
$___process = FS-Copy-File "${__target}" "${__workspace}"
$___process = FS-Copy-File `
"${__target}" `
"${__workspace}\$(FS-Get-File "${__target}")"
}

if ($___process -ne 0) {
Expand Down
56 changes: 56 additions & 0 deletions automataCI/_release-nupkg_unix-any.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
# Copyright 2024 (Holloway) Chew, Kean Ho <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at:
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
. "${LIBS_AUTOMATACI}/services/hestiaOS/Vanilla.sh.ps1"
. "${LIBS_AUTOMATACI}/services/hestiaCONSOLE/Vanilla.sh.ps1"
. "${LIBS_AUTOMATACI}/services/hestiaKERNEL/Vanilla.sh.ps1"
. "${LIBS_AUTOMATACI}/services/hestiaNUPKG/Vanilla.sh.ps1"




# initialize
if [ "$PROJECT_PATH_ROOT" = "" ]; then
>&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n"
return 1
fi




RELEASE_Run_NUPKG() {
#__target="$1"


# validate input
if [ $(hestiaNUPKG_Is_Target_Valid "$1") -ne $hestiaKERNEL_ERROR_OK ]; then
return $hestiaKERNEL_ERROR_OK
fi


# execute
hestiaCONSOLE_Log_Publish "NUPKG"
if [ $(hestiaOS_Is_Simulation_Mode) -ne 0 ]; then
hestiaNUPKG_Publish "$PROJECT_NUPKG_URL" "$NUPKG_TOKEN" "$__target"
if [ $? -ne 0 ]; then
hestiaCONSOLE_Log_Publish_Failed
return $hestiaKERNEL_ERROR_BAD_EXEC
fi
else
# always simulate in case of error or mishaps before any point of no return
hestiaCONSOLE_Log_Publish_Simulate "NUPKG"
fi


# report status
return $hestiaKERNEL_ERROR_OK
}
Loading

0 comments on commit 521c473

Please sign in to comment.