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