first init
This commit is contained in:
33
charts/audiobookshelf/tools/scripts/ci-push-changes.sh
Normal file
33
charts/audiobookshelf/tools/scripts/ci-push-changes.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
# exit on error
|
||||
set -e
|
||||
|
||||
commit_message=$1
|
||||
|
||||
if [ -z "$commit_message" ]; then
|
||||
echo "Commit message is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if there are no changes, exit
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "No changes found"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Adding the changes to the git stage"
|
||||
git add .
|
||||
|
||||
echo "Checking the status of the git repository"
|
||||
git status
|
||||
|
||||
echo "Committing the changes"
|
||||
git commit --no-verify -m "$commit_message"
|
||||
|
||||
current_remote=$(git config --get "branch.$CI_COMMIT_BRANCH.remote")
|
||||
|
||||
echo "Pushing the changes to the branch $CI_COMMIT_BRANCH in the remote $current_remote"
|
||||
git push --no-verify "$current_remote" "$CI_COMMIT_BRANCH"
|
||||
|
||||
echo "Done"
|
83
charts/audiobookshelf/tools/scripts/ci-setup-git-via-ssh.sh
Normal file
83
charts/audiobookshelf/tools/scripts/ci-setup-git-via-ssh.sh
Normal file
@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
|
||||
# exit on error
|
||||
set -e
|
||||
|
||||
if [ -z "$GIT_SSH_KEY" ]; then
|
||||
echo "No GIT_SSH_KEY variable found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GIT_COMMITTER_EMAIL=${GIT_COMMITTER_EMAIL:-$GITLAB_USER_EMAIL}
|
||||
GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME:-$GITLAB_USER_NAME}
|
||||
|
||||
if [ -z "$GIT_COMMITTER_EMAIL" ]; then
|
||||
echo "No GIT_COMMITTER_EMAIL variable found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$GIT_COMMITTER_NAME" ]; then
|
||||
echo "No GIT_COMMITTER_NAME variable found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "GIT_COMMITTER_EMAIL: $GIT_COMMITTER_EMAIL"
|
||||
echo "GIT_COMMITTER_NAME: $GIT_COMMITTER_NAME"
|
||||
|
||||
mkdir -p ~/.ssh
|
||||
|
||||
echo "
|
||||
Host $CI_SERVER_SHELL_SSH_HOST
|
||||
HostName $CI_SERVER_SHELL_SSH_HOST
|
||||
User git
|
||||
Port $CI_SERVER_SHELL_SSH_PORT
|
||||
IdentityFile $GIT_SSH_KEY
|
||||
IdentitiesOnly yes
|
||||
" > ~/.ssh/config
|
||||
|
||||
chmod 600 ~/.ssh/config
|
||||
chmod 600 "$GIT_SSH_KEY"
|
||||
|
||||
echo "SSH configuration: ~/.ssh/config"
|
||||
cat ~/.ssh/config
|
||||
|
||||
echo "Adding the ssh key to the known hosts"
|
||||
ssh-keyscan -H "$CI_SERVER_SHELL_SSH_HOST" >> ~/.ssh/known_hosts
|
||||
|
||||
echo "Connecting to the ssh server"
|
||||
ssh git@$CI_SERVER_SHELL_SSH_HOST
|
||||
|
||||
echo "Current git version: $(git --version)"
|
||||
|
||||
echo "Setting up the git configuration"
|
||||
git config --global core.sshCommand "ssh -F ~/.ssh/config"
|
||||
git config --global user.email "$GIT_COMMITTER_EMAIL"
|
||||
git config --global user.name "$GIT_COMMITTER_NAME"
|
||||
|
||||
git remote add ssh git@$CI_SERVER_SHELL_SSH_HOST:$CI_PROJECT_PATH.git
|
||||
|
||||
echo "Checking out the branch $CI_COMMIT_BRANCH"
|
||||
git checkout "$CI_COMMIT_BRANCH"
|
||||
|
||||
echo "Pulling the latest changes from the branch $CI_COMMIT_BRANCH"
|
||||
git pull origin "$CI_COMMIT_BRANCH"
|
||||
|
||||
echo "Fetch the remote branch"
|
||||
git fetch --depth 1 ssh "$CI_COMMIT_BRANCH"
|
||||
|
||||
echo "Set the upstream to ssh"
|
||||
git branch --set-upstream-to="ssh/$CI_COMMIT_BRANCH" "$CI_COMMIT_BRANCH"
|
||||
|
||||
echo "verifying the changes"
|
||||
git branch -vv
|
||||
|
||||
echo "current git status"
|
||||
git status
|
||||
|
||||
echo "current git branch"
|
||||
git branch
|
||||
|
||||
echo "current head commit"
|
||||
git rev-parse HEAD
|
||||
|
||||
echo "Done"
|
31
charts/audiobookshelf/tools/scripts/update-app-version.sh
Normal file
31
charts/audiobookshelf/tools/scripts/update-app-version.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
yq --version || (echo "yq is not installed. Please install yq." && exit 1)
|
||||
jq --version || (echo "jq is not installed. Please install jq." && exit 1)
|
||||
|
||||
current_app_version=$(cat Chart.yaml | yq -r '.appVersion')
|
||||
echo "Current app version: $current_app_version"
|
||||
|
||||
latest_app_version=$(curl -s "https://api.github.com/repos/advplyr/audiobookshelf/releases/latest" | jq -r '.tag_name' | sed 's/^v//')
|
||||
|
||||
echo "Latest app version: $latest_app_version"
|
||||
|
||||
if [ "$(printf "%s\n%s" "$current_app_version" "$latest_app_version" | sort -V | head -n1)" = "$current_app_version" ]; then
|
||||
if [ "$current_app_version" = "$latest_app_version" ]; then
|
||||
echo "Current version is equal to the latest version."
|
||||
exit 0
|
||||
else
|
||||
echo "Current version is less than the latest version."
|
||||
fi
|
||||
else
|
||||
echo "Current version is greater than the latest version."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating app version to $latest_app_version"
|
||||
|
||||
yq eval ".appVersion = \"$latest_app_version\"" -i Chart.yaml
|
||||
|
||||
echo "Commit and push the changes to the repository."
|
||||
|
||||
sh ./tools/scripts/ci-push-changes.sh "fix: update app version to $latest_app_version"
|
Reference in New Issue
Block a user