]> Untitled Git - lemmy.git/blob - docker/prod/deploy.sh
Adding version to GetSite. Fixes #1001 (#1002)
[lemmy.git] / docker / prod / deploy.sh
1 #!/bin/sh
2 set -e
3 git checkout main
4
5 # Import translations
6 git fetch weblate
7 git merge weblate/main
8
9 # Creating the new tag
10 new_tag="$1"
11 third_semver=$(echo $new_tag | cut -d "." -f 3)
12
13 # Setting the version on the front end
14 cd ../../
15 # Setting the version on the backend
16 echo "pub const VERSION: &str = \"$new_tag\";" > "server/src/version.rs"
17 git add "server/src/version.rs"
18 # Setting the version for Ansible
19 echo $new_tag > "ansible/VERSION"
20 git add "ansible/VERSION"
21
22 cd docker/prod || exit
23
24 # Changing the docker-compose prod
25 sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../prod/docker-compose.yml
26 sed -i "s/dessalines\/lemmy:.*/dessalines\/lemmy:$new_tag/" ../../ansible/templates/docker-compose.yml
27 git add ../prod/docker-compose.yml
28 git add ../../ansible/templates/docker-compose.yml
29
30 # The commit
31 git commit -m"Version $new_tag"
32 git tag $new_tag
33
34 export COMPOSE_DOCKER_CLI_BUILD=1
35 export DOCKER_BUILDKIT=1
36
37 # Rebuilding docker
38 if [ $third_semver -eq 0 ]; then
39   # TODO get linux/arm/v7 build working
40   # Build for Raspberry Pi / other archs too
41   docker buildx build --platform linux/amd64,linux/arm64 ../../ \
42     --file Dockerfile \
43     --tag dessalines/lemmy:$new_tag \
44     --push
45 else
46   docker buildx build --platform linux/amd64 ../../ \
47     --file Dockerfile \
48     --tag dessalines/lemmy:$new_tag \
49     --push
50 fi
51
52 # Push
53 git push origin $new_tag
54 git push
55
56 # Pushing to any ansible deploys
57 cd ../../../lemmy-ansible || exit
58 ansible-playbook -i prod playbooks/site.yml --vault-password-file vault_pass