Shellcheck updates for publish.sh script

This commit is contained in:
Clemens Schwaighofer
2024-07-19 18:39:30 +09:00
parent 672de694ee
commit e706a67427
2 changed files with 18 additions and 15 deletions

2
.shellcheckrc Normal file
View File

@@ -0,0 +1,2 @@
shell=bash
external-sources=true

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
BASE_FOLDER=$(dirname $(readlink -f $0))"/"; BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/";
PACKAGE_DOWNLOAD="${BASE_FOLDER}package-download/"; PACKAGE_DOWNLOAD="${BASE_FOLDER}package-download/";
if [ ! -d "${PACKAGE_DOWNLOAD}" ]; then if [ ! -d "${PACKAGE_DOWNLOAD}" ]; then
mkdir "${PACKAGE_DOWNLOAD}"; mkdir "${PACKAGE_DOWNLOAD}";
@@ -15,8 +15,8 @@ if [ -z "${VERSION}" ]; then
fi; fi;
# compare version, if different or newer, deploy # compare version, if different or newer, deploy
if [ -f "${file_last_published}" ]; then if [ -f "${file_last_published}" ]; then
LAST_PUBLISHED_VERSION=$(cat ${file_last_published}); LAST_PUBLISHED_VERSION=$(cat "${file_last_published}");
if $(dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"); then if dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"; then
echo "git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}"; echo "git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}";
exit; exit;
fi; fi;
@@ -40,9 +40,10 @@ if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then
exit; exit;
fi; fi;
set -o allexport; set -o allexport;
cd ${BASE_FOLDER}; cd "${BASE_FOLDER}" || exit;
# shellcheck source=.env.deploy
source .env.deploy; source .env.deploy;
cd -; cd - || exit;
set +o allexport; set +o allexport;
if [ "${go_flag}" != "go" ]; then if [ "${go_flag}" != "go" ]; then
@@ -55,21 +56,21 @@ fi;
echo "[START]"; echo "[START]";
# gitea # gitea
# skip iof # skip iof
if [ ! -z "${GITEA_PUBLISH}" ]; then if [ -n "${GITEA_PUBLISH}" ]; then
if [ ! -z "${GITEA_UPLOAD_FILENAME}" ] && if [ -n "${GITEA_UPLOAD_FILENAME}" ] &&
[ ! -z "${GITEA_URL_DL}" ] && [ ! -z "${GITEA_URL_PUSH}" ] && [ -n "${GITEA_URL_DL}" ] && [ -n "${GITEA_URL_PUSH}" ] &&
[ ! -z "${GITEA_USER}" ] && [ ! -z "${GITEA_TOKEN}" ]; then [ -n "${GITEA_USER}" ] && [ -n "${GITEA_TOKEN}" ]; then
if [ ! -f "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" ]; then if [ ! -f "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" ]; then
curl -LJO \ curl -LJO \
--output-dir "${PACKAGE_DOWNLOAD}" \ --output-dir "${PACKAGE_DOWNLOAD}" \
${GITEA_URL_DL}/v${VERSION}.zip; "${GITEA_URL_DL}"/v"${VERSION}".zip;
fi; fi;
if [ ! -f "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" ]; then if [ ! -f "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" ]; then
echo "Version file does not exist for ${VERSION}"; echo "Version file does not exist for ${VERSION}";
else else
curl --user ${GITEA_USER}:${GITEA_TOKEN} \ curl --user "${GITEA_USER}":"${GITEA_TOKEN}" \
--upload-file "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" \ --upload-file "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" \
${GITEA_URL_PUSH}?version=${VERSION}; "${GITEA_URL_PUSH}"?version="${VERSION}";
echo "${VERSION}" > "${file_last_published}"; echo "${VERSION}" > "${file_last_published}";
fi; fi;
else else
@@ -78,9 +79,9 @@ if [ ! -z "${GITEA_PUBLISH}" ]; then
fi; fi;
# gitlab # gitlab
if [ ! -z "${GITLAB_PUBLISH}" ]; then if [ -n "${GITLAB_PUBLISH}" ]; then
if [ ! -z "${GITLAB_URL}" ] && [ ! -z "${GITLAB_DEPLOY_TOKEN}" ]; then if [ -n "${GITLAB_URL}" ] && [ -n "${GITLAB_DEPLOY_TOKEN}" ]; then
curl --data tag=v${VERSION} \ curl --data tag=v"${VERSION}" \
--header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \ --header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \
"${GITLAB_URL}"; "${GITLAB_URL}";
curl --data branch=master \ curl --data branch=master \