  Long-duration gamma-ray bursts (GRBs) require an engine capable of driving a
jet of plasma to ultrarelativistic bulk Lorentz factors of up to several
hundred and into narrow opening angles of a few degrees. We use global
axisymmetric stationary solutions of magnetically-dominated (force-free)
ultrarelativistic jets to test whether the popular magnetic-driving paradigm
can generate the required Lorentz factors and opening angles. Our global
solutions are obtained via time-dependent relativistic ideal magnetodynamical
numerical simulations which follow the jet from the central engine to beyond
six orders of magnitude in radius. Our model is primarily motivated by the
collapsar model, in which a jet is produced by a spinning black hole or neutron
star and then propagates through a massive stellar envelope. We find that the
size of the presupernova progenitor star and the radial profile of pressure
inside the star determine the terminal Lorentz factor and opening angle of the
jet. At the radius where the jet breaks out of the star, our well-motivated
fiducial model generates a Lorentz factor $\gamma\sim 400$ and a half-opening
angle $\theta_j\sim 2^\circ$, consistent with observations of many
long-duration GRBs. Other models with slightly different parameters give
$\gamma$ in the range 100 to 5000 and $\theta_j$ from $0.1^\circ$ to
$10^\circ$, thus reproducing the range of properties inferred for GRB jets. A
potentially observable feature of some of our solutions is that the maximum
Poynting flux in the jet is found at $\theta \sim \theta_j$ with the jet power
concentrated in a hollow cone, while the maximum in the Lorentz factor occurs
at an angle $\theta$ substantially smaller than $\theta_j$ also in a hollow
cone. [abridged]
