Skip to content

Commit

Permalink
automataCI: added i18n feature to release citation function
Browse files Browse the repository at this point in the history
Since we want i18n feature to be applied across all package CI job,
we should first deal with release citation function. Hence, let's
do this.

This patch applies i18n feature to release citation function in
automataCI/ directory.

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
hollowaykeanho and corygalyna committed Dec 16, 2023
1 parent 8bd12e1 commit 0c8214b
Show file tree
Hide file tree
Showing 16 changed files with 513 additions and 290 deletions.
52 changes: 52 additions & 0 deletions automataCI/_package-citation_unix-any.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh
# Copyright 2023 (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/time.sh"
. "${LIBS_AUTOMATACI}/services/compilers/citation.sh"

. "${LIBS_AUTOMATACI}/services/i18n/status-file.sh"




PACKAGE_Run_CITATION() {
__citation_cff="$1"


# assemble citation
I18N_Status_Print_File_Create "$__citation_cff"
CITATION_Build \
"$__citation_cff" \
"${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" \
"${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/CITATIONS.yml" \
"$PROJECT_CITATION" \
"$PROJECT_CITATION_TYPE" \
"$(TIME_Format_ISO8601_Date "$(TIME_Now)")" \
"$PROJECT_NAME" \
"$PROJECT_VERSION" \
"$PROJECT_LICENSE" \
"$PROJECT_SOURCE_URL" \
"$PROJECT_SOURCE_URL" \
"$PROJECT_STATIC_URL" \
"$PROJECT_CONTACT_NAME" \
"$PROJECT_CONTACT_WEBSITE" \
"$PROJECT_CONTACT_EMAIL"
if [ $? -ne 0 ]; then
I18N_Status_Print_File_Create_Failed
return 1
fi


# report status
return 0
}
52 changes: 52 additions & 0 deletions automataCI/_package-citation_windows-any.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2023 (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\time.ps1"
. "${env:LIBS_AUTOMATACI}\services\compilers\citation.ps1"

. "${env:LIBS_AUTOMATACI}\services\i18n\status-file.ps1"




function PACKAGE-Run-CITATION {
param(
[string]$__citation_cff
)

# execute
$null = I18N-Status-Print-File-Create "${__citation_cff}"
$__process = CITATION-Build `
"${__citation_cff}" `
"${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" `
"${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\CITATIONS.yml" `
"${env:PROJECT_CITATION}" `
"${env:PROJECT_CITATION_TYPE}" `
"$(TIME-Format-ISO8601-Date "$(TIME-Now)")" `
"${env:PROJECT_NAME}" `
"${env:PROJECT_VERSION}" `
"${env:PROJECT_LICENSE}" `
"${env:PROJECT_SOURCE_URL}" `
"${env:PROJECT_SOURCE_URL}" `
"${env:PROJECT_STATIC_URL}" `
"${env:PROJECT_CONTACT_NAME}" `
"${env:PROJECT_CONTACT_WEBSITE}" `
"${env:PROJECT_CONTACT_EMAIL}"
if ($__process -ne 0) {
$null = I18N-Status-Print-File-Create-Failed
return 1
}


# report status
return 0
}
50 changes: 16 additions & 34 deletions automataCI/_release-citation_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,31 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/os.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/fs.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/io/time.sh"
. "${PROJECT_PATH_ROOT}/${PROJECT_PATH_AUTOMATA}/services/compilers/citation.sh"
. "${LIBS_AUTOMATACI}/services/io/fs.sh"

. "${LIBS_AUTOMATACI}/services/i18n/status-file.sh"



RELEASE::run_citation() {

RELEASE_Run_CITATION_CFF() {
_target="$1"


# validate
if [ $(FS_Is_Target_A_Citation_CFF "$_target") -ne 0 ]; then
return 0
fi


# execute
OS::print_status info "generating citation file...\n"
CITATION::build \
"${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/CITATION.cff" \
"${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/ABSTRACTS.txt" \
"${PROJECT_PATH_ROOT}/${PROJECT_PATH_SOURCE}/docs/CITATIONS.yml" \
"$PROJECT_CITATION" \
"$PROJECT_CITATION_TYPE" \
"$(TIME_Format_ISO8601_Date "$(TIME_Now)")" \
"$PROJECT_NAME" \
"$PROJECT_VERSION" \
"$PROJECT_LICENSE" \
"$PROJECT_SOURCE_URL" \
"$PROJECT_SOURCE_URL" \
"$PROJECT_STATIC_URL" \
"$PROJECT_CONTACT_NAME" \
"$PROJECT_CONTACT_WEBSITE" \
"$PROJECT_CONTACT_EMAIL"
I18N_Status_Print_File_Export "CITATION.cff"
FS::copy_file "$_target" "${PROJECT_PATH_ROOT}/CITATION.cff"
if [ $? -ne 0 ]; then
OS::print_status error "generate failed.\n"
I18N_Status_Print_File_Export_Failed
return 1
fi

if [ -f "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/CITATION.cff" ]; then
OS::print_status info "exporting CITATION.cff...\n"
FS::copy_file \
"${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/CITATION.cff" \
"${PROJECT_PATH_ROOT}/CITATION.cff"
if [ $? -ne 0 ]; then
OS::print_status error "export failed.\n"
return 1
fi
fi


# report status
return 0
Expand Down
54 changes: 19 additions & 35 deletions automataCI/_release-citation_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,32 @@
# 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:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\os.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\fs.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\io\time.ps1"
. "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_AUTOMATA}\services\compilers\citation.ps1"
. "${env:LIBS_AUTOMATACI}\services\io\fs.ps1"

. "${env:LIBS_AUTOMATACI}\services\i18n\status-file.ps1"



function RELEASE-Run-Citation {
# execute
OS-Print-Status info "generating citation file..."
$__process = CITATION-Build `
"${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\CITATION.cff" `
"${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\ABSTRACTS.txt" `
"${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_SOURCE}\docs\CITATIONS.yml" `
"${env:PROJECT_CITATION}" `
"${env:PROJECT_CITATION_TYPE}" `
"$(TIME-Format-ISO8601-Date "$(TIME-Now)")" `
"${env:PROJECT_NAME}" `
"${env:PROJECT_VERSION}" `
"${env:PROJECT_LICENSE}" `
"${env:PROJECT_SOURCE_URL}" `
"${env:PROJECT_SOURCE_URL}" `
"${env:PROJECT_STATIC_URL}" `
"${env:PROJECT_CONTACT_NAME}" `
"${env:PROJECT_CONTACT_WEBSITE}" `
"${env:PROJECT_CONTACT_EMAIL}"
if ($__process -ne 0) {
OS-Print-Status error "generate failed."
return 1

function RELEASE-Run-CITATION-CFF {
param(
[string]$_target
)


# validate input
$___process = FS-Is-Target-A-Citation-CFF "${_target}"
if ($___process -ne 0) {
return 0
}


if (Test-Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\CITATION.cff") {
OS-Print-Status info "exporting CITATION.cff..."
$__process = FS-Copy-File `
"${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\CITATION.cff" `
"${env:PROJECT_PATH_ROOT}\CITATION.cff"
if ($__process -ne 0) {
OS-Print-Status error "export failed."
return 1
}
# execute
$null = I18N-Status-Print-File-Export "CITATION.cff"
$___process = FS-Copy-File "${_target}" "${env:PROJECT_PATH_ROOT}\CITATION.cff"
if ($___process -ne 0) {
$null = I18N-Status-Print-File-Export-Failed
return 1
}


Expand Down
8 changes: 8 additions & 0 deletions automataCI/package_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fi
. "${LIBS_AUTOMATACI}/_package-cargo_unix-any.sh"
. "${LIBS_AUTOMATACI}/_package-changelog_unix-any.sh"
. "${LIBS_AUTOMATACI}/_package-chocolatey_unix-any.sh"
. "${LIBS_AUTOMATACI}/_package-citation_unix-any.sh"
. "${LIBS_AUTOMATACI}/_package-deb_unix-any.sh"
. "${LIBS_AUTOMATACI}/_package-docker_unix-any.sh"
. "${LIBS_AUTOMATACI}/_package-flatpak_unix-any.sh"
Expand Down Expand Up @@ -69,6 +70,13 @@ if [ $? -ne 0 ]; then
return 1
fi

FILE_CITATION_CFF="${PROJECT_SKU}-CITATION_${PROJECT_VERSION}.cff"
FILE_CITATION_CFF="${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}/${FILE_CITATION_CFF}"
PACKAGE_Run_CITATION "$FILE_CITATION_CFF"
if [ $? -ne 0 ]; then
return 1
fi


I18N_Status_Print_Newline

Expand Down
11 changes: 10 additions & 1 deletion automataCI/package_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (-not (Test-Path -Path $env:PROJECT_PATH_ROOT)) {
. "${env:LIBS_AUTOMATACI}\services\i18n\status-sync.ps1"

. "${env:LIBS_AUTOMATACI}\_package-changelog_windows-any.ps1"
. "${env:LIBS_AUTOMATACI}\_package-citation_windows-any.ps1"



Expand All @@ -48,7 +49,15 @@ $FILE_CHANGELOG_MD = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${FILE_CH
$FILE_CHANGELOG_DEB = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_TEMP}\deb\changelog.gz"
$__process = Package-Run-CHANGELOG "$FILE_CHANGELOG_MD" "$FILE_CHANGELOG_DEB"
if ($__process -ne 0) {
exit 1
return 1
}


$FILE_CITATION_CFF = "${env:PROJECT_SKU}-CITATION_${env:PROJECT_VERSION}.cff"
$FILE_CITATION_CFF = "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}\${FILE_CITATION_CFF}"
$__process = Package-Run-CITATION "$FILE_CITATION_CFF"
if ($__process -ne 0) {
return 1
}


Expand Down
11 changes: 5 additions & 6 deletions automataCI/release_unix-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do
return 1
fi

RELEASE_Run_CITATION_CFF "$TARGET"
if [ $? -ne 0 ]; then
return 1
fi

RELEASE::run_homebrew "$TARGET" "$HOMEBREW_REPO"
if [ $? -ne 0 ]; then
return 1
Expand All @@ -140,12 +145,6 @@ for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do
done


RELEASE::run_citation
if [ $? -ne 0 ]; then
return 1
fi


RELEASE::run_checksum_seal "$STATIC_REPO"
if [ $? -ne 0 ]; then
return 1
Expand Down
11 changes: 5 additions & 6 deletions automataCI/release_windows-any.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ if (Test-Path -PathType Container -Path "${PACKAGE_DIRECTORY}") {
return 1
}

$__process = RELEASE-Run-CITATION-CFF "$TARGET"
if ($__process -ne 0) {
return 1
}

$__process = RELEASE-Run-Homebrew "$TARGET" "$HOMEBREW_REPO"
if ($__process -ne 0) {
return 1
Expand All @@ -144,12 +149,6 @@ if (Test-Path -PathType Container -Path "${PACKAGE_DIRECTORY}") {
}


$__process = RELEASE-Run-Citation
if ($__process -ne 0) {
return 1
}


$__process = RELEASE-Run-Checksum-Seal "$STATIC_REPO"
if ($__process -ne 0) {
return 1
Expand Down
Loading

0 comments on commit 0c8214b

Please sign in to comment.