-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automataCI: enabled automated release branches implementations
There are a number of technologies rely on release branches such as but not limited to NPM and Go. Hence, we have to enable the automation for it. Let's do this. This patch enables automated release branches implementations in automataCI/ directory. 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
1 parent
62f2288
commit ccf42d4
Showing
12 changed files
with
650 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#!/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/io/fs.sh" | ||
. "${LIBS_AUTOMATACI}/services/io/os.sh" | ||
. "${LIBS_AUTOMATACI}/services/io/strings.sh" | ||
. "${LIBS_AUTOMATACI}/services/archive/tar.sh" | ||
. "${LIBS_AUTOMATACI}/services/archive/zip.sh" | ||
. "${LIBS_AUTOMATACI}/services/i18n/translations.sh" | ||
. "${LIBS_AUTOMATACI}/services/versioners/git.sh" | ||
|
||
|
||
|
||
|
||
# initialize | ||
if [ "$PROJECT_PATH_ROOT" = "" ]; then | ||
>&2 printf "[ ERROR ] - Please run me from automataCI/ci.sh.ps1 instead!\n" | ||
return 1 | ||
fi | ||
|
||
|
||
|
||
|
||
RELEASE_Run_LIBS() { | ||
#_target="$1" | ||
|
||
|
||
# validate input | ||
if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_RELEASE_TAG_LATEST") -eq 0 ]; then | ||
return 0 | ||
fi | ||
|
||
if [ $(FS_Is_Target_A_Library "$1") -ne 0 ]; then | ||
return 0 | ||
fi | ||
|
||
if [ $(STRINGS_Is_Empty "$PROJECT_SOURCE_GIT_REMOTE") -eq 0 ]; then | ||
return 0 | ||
fi | ||
|
||
GIT_Is_Available | ||
if [ $? -ne 0 ]; then | ||
return 0 | ||
fi | ||
|
||
|
||
# execute | ||
## identify tag | ||
__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 | ||
return 0 | ||
fi | ||
|
||
__branch="${__branch}_${PROJECT_NODE_BRANCH_TAG}" | ||
else | ||
return 0 | ||
fi | ||
|
||
I18N_Publish "git@$__branch" | ||
if [ $(OS_Is_Run_Simulated) -eq 0 ]; then | ||
I18N_Simulate_Publish "$__branch" | ||
return 0 | ||
fi | ||
|
||
## create workspace directory | ||
__workspace="${PROJECT_PATH_ROOT}/${PROJECT_PATH_TEMP}/release-branch_${__branch}" | ||
GIT_Setup_Workspace_Bare "$PROJECT_SOURCE_GIT_REMOTE" "$__branch" "$__workspace" | ||
if [ $? -ne 0 ]; then | ||
I18N_Publish_Failed | ||
return 1 | ||
fi | ||
|
||
## unpack package into directory | ||
if [ $(FS_Is_Target_A_TARGZ "$1") -eq 0 ]; then | ||
TAR_Extract_GZ "$__workspace" "$1" | ||
elif [ $(FS_Is_Target_A_TARXZ "$1") -eq 0 ]; then | ||
TAR_Extract_XZ "$__workspace" "$1" | ||
elif [ $(FS_Is_Target_A_ZIP "$1") -eq 0 ]; then | ||
ZIP_Extract "$__workspace" "$1" | ||
else | ||
FS_Copy_File "$1" "${__workspace}" | ||
fi | ||
|
||
if [ $? -ne 0 ]; then | ||
I18N_Publish_Failed | ||
return 1 | ||
fi | ||
|
||
## commit release | ||
__current_path="$PWD" && cd "$__workspace" | ||
GIT_Autonomous_Commit "$__branch" | ||
___process=$? | ||
cd "$__current_path" && unset __current_path | ||
if [ $___process -ne 0 ]; then | ||
I18N_Publish_Failed | ||
return 1 | ||
fi | ||
|
||
## push to upstream | ||
GIT_Push_Specific "$__workspace" \ | ||
"$PROJECT_SOURCE_GIT_REMOTE" \ | ||
"$__branch" \ | ||
"$__branch" | ||
if [ $? -ne 0 ]; then | ||
I18N_Publish_Failed | ||
return 1 | ||
fi | ||
|
||
GIT_Push_Specific "$__workspace" \ | ||
"$PROJECT_SOURCE_GIT_REMOTE" \ | ||
"$__branch" \ | ||
"${PROJECT_SOURCE_RELEASE_TAG_LATEST}_${__branch#*_}" | ||
if [ $? -ne 0 ]; then | ||
I18N_Publish_Failed | ||
return 1 | ||
fi | ||
|
||
|
||
# report status | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
# 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. | ||
. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1" | ||
. "${env:LIBS_AUTOMATACI}\services\io\os.ps1" | ||
. "${env:LIBS_AUTOMATACI}\services\io\strings.ps1" | ||
. "${env:LIBS_AUTOMATACI}\services\archive\tar.ps1" | ||
. "${env:LIBS_AUTOMATACI}\services\archive\zip.ps1" | ||
. "${env:LIBS_AUTOMATACI}\services\i18n\translations.ps1" | ||
. "${env:LIBS_AUTOMATACI}\services\versioners\git.ps1" | ||
|
||
|
||
|
||
|
||
# initialize | ||
if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) { | ||
Write-Error "[ ERROR ] - Please run from automataCI\ci.sh.ps1 instead!`n" | ||
return | ||
} | ||
|
||
|
||
|
||
|
||
function RELEASE-Run-LIBS { | ||
param( | ||
[string]$_target | ||
) | ||
|
||
|
||
# validate input | ||
if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_RELEASE_TAG_LATEST}") -eq 0) { | ||
return 0 | ||
} | ||
|
||
$___process = FS-Is-Target-A-Library "${_target}" | ||
if ($___process -ne 0) { | ||
return 0 | ||
} | ||
|
||
if ($(STRINGS-Is-Empty "${env:PROJECT_SOURCE_GIT_REMOTE}") -eq 0) { | ||
return 0 | ||
} | ||
|
||
$___process = GIT-Is-Available | ||
if ($___process -ne 0) { | ||
return 0 | ||
} | ||
|
||
|
||
# execute | ||
## identify tag | ||
$__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) { | ||
return 0 | ||
} | ||
|
||
$__branch = "${__branch}_${env:PROJECT_NODE_BRANCH_TAG}" | ||
} else { | ||
return 0 | ||
} | ||
|
||
$null = I18N-Publish "git@${__branch}" | ||
if ($(OS-Is-Run-Simulated) -eq 0) { | ||
$null = I18N-Simulate-Publish "${__branch}" | ||
return 0 | ||
} | ||
|
||
## create workspace directory | ||
$__workspace = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\release-branch_${_branch}" | ||
$___process = GIT-Setup-Workspace-Bare ` | ||
"${env:PROJECT_SOURCE_GIT_REMOTE}" ` | ||
"${__branch}" ` | ||
"${__workspace}" | ||
if ($___process -ne 0) { | ||
$null = I18N-Publish-Failed | ||
return 1 | ||
} | ||
|
||
## unpack package into directory | ||
if ($(FS-Is-Target-A-TARGZ "$1") -eq 0) { | ||
$___process = TAR-Extract-GZ "${__workspace}" "${_target}" | ||
} elseif ($(FS-Is-Target-A-TARXZ "$1") -eq 0) { | ||
$___process = TAR-Extract-XZ "${__workspace}" "${_target}" | ||
} elseif ($(FS-Is-Target-A-ZIP "$1") -eq 0) { | ||
$___process = ZIP-Extract "${__workspace}" "${_target}" | ||
} else { | ||
$___process = FS-Copy-File "${_target}" "${__workspace}" | ||
} | ||
|
||
if ($___process -ne 0) { | ||
$null = I18N-Publish-Failed | ||
return 1 | ||
} | ||
|
||
## commit release | ||
$__current_path = Get-Location | ||
$null = Set-Location -Path "${__workspace}" | ||
$___process = GIT-Autonomous-Commit "${__branch}" | ||
$null = Set-Location -Path "${__current_path}" | ||
$null = Remove-Variable -Name __current_path | ||
if ($___process -ne 0) { | ||
$null = I18N-Publish-Failed | ||
return 1 | ||
} | ||
|
||
## push to upstream | ||
$___process = GIT-Push-Specific "${__workspace}" ` | ||
"${env:PROJECT_SOURCE_GIT_REMOTE}" ` | ||
"${__branch}" | ||
"${__branch}" | ||
if ($___process -ne 0) { | ||
$null = I18N-Publish-Failed | ||
return 1 | ||
} | ||
|
||
$___process = GIT-Push-Specific "${__workspace}" ` | ||
"${env:PROJECT_SOURCE_GIT_REMOTE}" ` | ||
"${__branch}" | ||
"${env:PROJECT_SOURCE_RELEASE_TAG_LATEST}_$($__branch -replace "^.*_", '')" | ||
if ($___process -ne 0) { | ||
$null = I18N-Publish-Failed | ||
return 1 | ||
} | ||
|
||
|
||
# report status | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.