-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake-pontoon-tarball.sh
executable file
·103 lines (83 loc) · 3.25 KB
/
make-pontoon-tarball.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Dependencies: build-essential git python3 python3-dev python3-venv nodejs npm
# Usage: ./make-pontoon-tarball.sh [PONTOON_REV [VERSION]]
# PONTOON_REV: Pontoon's revision (git) to release (default: main)
# VERSION: The version of the Pontoon Debian release (default: date +%Y.%m.%d.0)
PONTOON_REV=$1
test -z "$PONTOON_REV" && PONTOON_REV=main
VERSION=$2
test -z "$VERSION" && VERSION=$(date +%Y.%m.%d.0)
APP_NAME=pontoon
BUILD_DIR=$PWD/build
OUTPUT_DIR=$PWD/build/$APP_NAME-$VERSION
OUTPUT_TARBALL=$PWD/dist/${APP_NAME}_$VERSION.tar.gz
DEBIAN_DIR=$PWD/debian
# Exit on errors
set -e
# Clean build dirs
rm -rf $BUILD_DIR
rm -rf $OUTPUT_DIR
# Create directories
mkdir -p $BUILD_DIR
mkdir -p $OUTPUT_DIR
mkdir -p $(dirname $OUTPUT_TARBALL)
# Clone Pontoon
git clone https://github.com/mozilla/pontoon.git $BUILD_DIR/$APP_NAME.git
cd $BUILD_DIR/$APP_NAME.git
git checkout $PONTOON_REV
# Prepare Python Virtual Environment using uv if available else using venv
uv --version > /dev/null 2>&1 && uv venv __env__ || python3 -m venv __env__
source __env__/bin/activate
# Collect info about the environment
PYTHON_MAJOR=$(python -c "import sys;print(sys.version_info.major)")
PYTHON_MINOR=$(python -c "import sys;print(sys.version_info.minor)")
uv --version > /dev/null 2>&1 && UV_AVAILABLE=1 || UV_AVAILABLE=0
# Install uv in the venv if not available
if [ $UV_AVAILABLE != 1 ] ; then
pip install uv
fi
# Compile dependencies (Replicating: https://github.com/mozilla/pontoon/blob/d619331f62b28fd69d3f998d97e4343dd0ed6bc4/docker/compile_requirements.sh)
uv pip compile --generate-hashes requirements/default.in -o requirements/default.txt
uv pip compile --generate-hashes requirements/dev.in -o requirements/dev.txt
uv pip compile --generate-hashes requirements/lint.in -o requirements/lint.txt
uv pip compile --generate-hashes requirements/test.in -o requirements/test.txt
# Compile additional dependencies for Python 3.10
cp $DEBIAN_DIR/requirements.py310.in $BUILD_DIR/$APP_NAME.git/
uv pip compile --generate-hashes $BUILD_DIR/$APP_NAME.git/requirements.py310.in -o $OUTPUT_DIR/requirements.py310.txt
# Install Python dependencies
uv pip install -r requirements.txt
if [ $PYTHON_MAJOR == 3 ] && [ $PYTHON_MINOR -ge 12 ] ; then
uv pip install setuptools
fi
# Install Node dependencies
npm install
# Set some basic config to build Pontoon front
export SECRET_KEY=pontoonsecret
export DATABASE_URL=sqlite://:memory:
export DJANGO_DEBUG=True
# Build the front
npm run build:prod
uv run manage.py collectstatic
# Leave the virtualenv
deactivate
# Copy files
cp -vr static/ $OUTPUT_DIR
cp -vr pontoon/ $OUTPUT_DIR
cp -vr translate/ $OUTPUT_DIR
cp -vr requirements/ $OUTPUT_DIR
cp -v setup.py $OUTPUT_DIR
cp -v manage.py $OUTPUT_DIR
cp -v requirements.txt $OUTPUT_DIR
cp -v LICENSE $OUTPUT_DIR
cp -v README.md $OUTPUT_DIR
cp -v contribute.json $OUTPUT_DIR
cp -v CONTRIBUTING.rst $OUTPUT_DIR
cp -v CODE_OF_CONDUCT.md $OUTPUT_DIR
cp -vr $DEBIAN_DIR $OUTPUT_DIR
echo "[pontoon-debian]" >> $OUTPUT_DIR/RELEASE.txt
echo "version = $VERSION" >> $OUTPUT_DIR/RELEASE.txt
echo "pontoon-rev = $(git rev-parse HEAD)" >> $OUTPUT_DIR/RELEASE.txt
echo "release-date = $(date --rfc-email)" >> $OUTPUT_DIR/RELEASE.txt
# Make the tarball
cd $(dirname $OUTPUT_DIR)
tar -cvzf $OUTPUT_TARBALL $(basename $OUTPUT_DIR)