morgan pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits:
-
4cc42848
by Morgan at 2024-11-18T21:20:39+00:00
6 changed files:
- + tools/browser/.gitignore
- + tools/browser/README.md
- + tools/browser/sign-tag
- + tools/browser/sign-tag.basebrowser
- + tools/browser/sign-tag.mullvadbrowser
- + tools/browser/sign-tag.torbrowser
Changes:
1 | +basebrowser
|
|
2 | +torbrowser
|
|
3 | +mullvadbrowser |
1 | +# Tools
|
|
2 | + |
|
3 | +### sign-tag
|
|
4 | + |
|
5 | +This script gpg signs a git tag associated with a particular browser commit in the user's tor-browser.git or mullvad-browser.git repo.
|
|
6 | + |
|
7 | +#### Prerequisites
|
|
8 | + |
|
9 | +- The user must create the following soft-links:
|
|
10 | + - `/tools/browser/basebrowser` -> `/path/to/local/tor-browser.git`
|
|
11 | + - `/tools/browser/mullvadbrowser` -> `/path/to/local/mullvad-browser.git`
|
|
12 | + - `/tools/browser/torbrowser` -> `/path/to/local/tor-browser.git`
|
|
13 | +- The user must first checkout the relevant branch of the commit we are tagging
|
|
14 | + - This is needed to extract the ESR version, branch-number, and browser name
|
|
15 | + |
|
16 | +#### Usage
|
|
17 | + |
|
18 | +```
|
|
19 | +usage: ./tools/browser/sign-tag.<browser> <channel> <build-number> [commit]
|
|
20 | + |
|
21 | +browser one of basebrowser, torbrowser, or mullvadbrowser
|
|
22 | +channel the release channel of the commit to sign (e.g. alpha, stable,
|
|
23 | + or legacy)
|
|
24 | +build-number the build number portion of a browser build tag (e.g. build2)
|
|
25 | +commit optional git commit, HEAD is used if argument not present
|
|
26 | +```
|
|
27 | + |
|
28 | +#### Examples
|
|
29 | +Invoke the relevant soft-link'd version of this script to sign a particular browser. The trailing commit argument is optional and if not present, the browser branch's `HEAD` will be tagged+signed.
|
|
30 | + |
|
31 | + - ##### `base-browser-128.4.0esr-14.5-1-build1`
|
|
32 | + After checking out `base-browser-128.4.0esr-14.5-1` branch in linked tor-browser.git
|
|
33 | + ```bash
|
|
34 | + ./sign-tag.basebrowser alpha build1 24e628c1fd3f0593e23334acf55dc81909c30099
|
|
35 | + ```
|
|
36 | + **output**:
|
|
37 | + ```
|
|
38 | + Tag commit 24e628c1fd3f in base-browser-128.4.0esr-14.5-1
|
|
39 | + tag: base-browser-128.4.0esr-14.5-1-build1
|
|
40 | + message: Tagging build1 for 128.4.0esr-based alpha
|
|
41 | + ```
|
|
42 | + |
|
43 | + - ##### `tor-browser-115.17.0esr-13.5-1-build2`
|
|
44 | + After checking out `tor-browser-115.17.0esr-13.5-1` branch in linked tor-browser.git
|
|
45 | + ```bash
|
|
46 | + ./sign-tag.torbrowser legacy build2 8e9e58fe400291f20be5712d057ad0b5fc4d70c1
|
|
47 | + ```
|
|
48 | + **output**:
|
|
49 | + ```
|
|
50 | + Tag commit 8e9e58fe4002 in tor-browser-115.17.0esr-13.5-1
|
|
51 | + tag: tor-browser-115.17.0esr-13.5-1-build2
|
|
52 | + message: Tagging build2 for 115.17.0esr-based legacy
|
|
53 | + ```
|
|
54 | + |
|
55 | + - ##### `mullvad-browser-128.4.0esr-14.0-1-build2`
|
|
56 | + After checking out `mullvad-browser-128.4.0esr-14.0-1` branch in linked mullvad-browser.git
|
|
57 | + ```bash
|
|
58 | + ./sign-tag.mullvadbrowser stable build2 385aa0559a90a258ed6613527ff3e117dfa5ae5b
|
|
59 | + ```
|
|
60 | + **output**:
|
|
61 | + ```
|
|
62 | + Tag commit 385aa0559a90 in mullvad-browser-128.4.0esr-14.0-1
|
|
63 | + tag: mullvad-browser-128.4.0esr-14.0-1-build2
|
|
64 | + message: Tagging build2 for 128.4.0esr-based stable
|
|
65 | + ``` |
|
\ No newline at end of file |
1 | +#!/usr/bin/env bash
|
|
2 | + |
|
3 | +# See README.md for usage instructions.
|
|
4 | + |
|
5 | +# terminate on error
|
|
6 | +set -e
|
|
7 | + |
|
8 | +# Check if at least two arguments are provided
|
|
9 | +if [ "$#" -lt 2 ]; then
|
|
10 | + echo "Usage: $0 channel build-number [commit]"
|
|
11 | + exit 1
|
|
12 | +fi
|
|
13 | + |
|
14 | +script_name=$(basename "${BASH_ARGV0:-$0}")
|
|
15 | +script_dir=$(dirname "${BASH_ARGV0:-$0}")
|
|
16 | +browser=$(echo "$script_name" | perl -pe 's/^[^\.]+\.//')
|
|
17 | + |
|
18 | +case "${browser}" in
|
|
19 | + basebrowser | torbrowser | mullvadbrowser)
|
|
20 | + # go down to browser directory
|
|
21 | + pushd ${script_dir}/${browser} > /dev/null
|
|
22 | + # and exit on script termination
|
|
23 | + trap "popd > /dev/null" EXIT
|
|
24 | + ;;
|
|
25 | + *)
|
|
26 | + echo -n "unrecognized browser: '${browser}'"
|
|
27 | + exit 1
|
|
28 | + ;;
|
|
29 | +esac
|
|
30 | + |
|
31 | +#
|
|
32 | +# Branch name validation and extract components from branch name needed for tag
|
|
33 | +# and message
|
|
34 | +#
|
|
35 | + |
|
36 | +branch_name=$(git rev-parse --abbrev-ref HEAD)
|
|
37 | +if [[ $branch_name =~ ^([a-z]+-browser)-([1-9][0-9]+\.[0-9]+\.[0-9]+esr)-([1-9][0-9]*\.[05])-([1-9]).*$ ]]; then
|
|
38 | + project="${BASH_REMATCH[1]}"
|
|
39 | + esr="${BASH_REMATCH[2]}"
|
|
40 | + version="${BASH_REMATCH[3]}"
|
|
41 | + branch_number="${BASH_REMATCH[4]}"
|
|
42 | +else
|
|
43 | + echo "This script must be run from an official browser branch. For example 'base-browser-128.4.0esr-14.0-1'"
|
|
44 | + exit 1
|
|
45 | +fi
|
|
46 | + |
|
47 | +#
|
|
48 | +# Verify the detected browser matches the name of the current branch
|
|
49 | +#
|
|
50 | +case "${browser}" in
|
|
51 | + basebrowser)
|
|
52 | + valid_project="base-browser"
|
|
53 | + ;;
|
|
54 | + torbrowser)
|
|
55 | + valid_project="tor-browser"
|
|
56 | + ;;
|
|
57 | + mullvadbrowser)
|
|
58 | + valid_project="mullvad-browser"
|
|
59 | + ;;
|
|
60 | +esac
|
|
61 | + |
|
62 | +if ! [[ "${project}" == "${valid_project}" ]]; then
|
|
63 | + echo "Invalid branch \"${branch_name}\". Must be a \"${valid_project}\" branch"
|
|
64 | + exit 1
|
|
65 | +fi
|
|
66 | + |
|
67 | +#
|
|
68 | +# Assign arguments to variables
|
|
69 | +#
|
|
70 | +channel=$1
|
|
71 | +build_number=$2
|
|
72 | +commit=$(git rev-parse --short ${3:-HEAD})
|
|
73 | + |
|
74 | +#
|
|
75 | +# Validate arguments
|
|
76 | +#
|
|
77 | + |
|
78 | +# channel validation
|
|
79 | +if [[ "${project}" == "mullvad-browser" ]]; then
|
|
80 | + valid_channels=("alpha" "stable")
|
|
81 | +else
|
|
82 | + valid_channels=("alpha" "stable" "legacy")
|
|
83 | +fi
|
|
84 | +channel_valid=false
|
|
85 | +for value in "${valid_channels[@]}"; do
|
|
86 | + if [[ "${channel}" == "${value}" ]]; then
|
|
87 | + channel_valid=true
|
|
88 | + break
|
|
89 | + fi
|
|
90 | +done
|
|
91 | + |
|
92 | +if ! $channel_valid; then
|
|
93 | + echo "Invalid channel name \"${channel}\". Must be one of: ${valid_channels[*]}"
|
|
94 | + exit 1
|
|
95 | +fi
|
|
96 | + |
|
97 | +# build number validation
|
|
98 | +if ! [[ "${build_number}" =~ ^build[1-9][0-9]*$ ]]; then
|
|
99 | + echo "Invalid build number \"${build_number}\". Must be in the format \"build[1-9][0-9]*\""
|
|
100 | + exit 1
|
|
101 | +fi
|
|
102 | + |
|
103 | +#
|
|
104 | +# Sign and tag the specified git commit
|
|
105 | +#
|
|
106 | + |
|
107 | +tag="${project}-${esr}-${version}-${branch_number}-${build_number}"
|
|
108 | +message="Tagging ${build_number} for ${esr}-based ${channel}"
|
|
109 | + |
|
110 | + |
|
111 | +echo "Tag commit ${commit} in ${branch_name}"
|
|
112 | +echo " tag: ${tag}"
|
|
113 | +echo " message: ${message}"
|
|
114 | + |
|
115 | +git tag -s "${tag}" "${commit}" -m "${message}" |
1 | +sign-tag |
|
\ No newline at end of file |
1 | +sign-tag |
|
\ No newline at end of file |
1 | +sign-tag |
|
\ No newline at end of file |