We derive the partition function of 5d ${cal N}=1$ gauge theories on the manifold $S^3_b times Sigma_{frak g}$ with a partial topological twist along the Riemann surface, $Sigma_{frak g}$. This setup is a higher dimensional uplift of the two-dimensional A-twist, and the result can be expressed as a sum over solutions of Bethe-Ansatz-type equations, with the computation receiving nontrivial non-perturbative contributions. We study this partition function in the large $N$ limit, where it is related to holographic RG flows between asymptotically locally AdS$_6$ and AdS$_4$ spacetimes, reproducing known holographic relations between the corresponding free energies on $S^{5}$ and $S^{3}$ and predicting new ones. We also consider cases where the 5d theory admits a UV completion as a 6d SCFT, such as the maximally supersymmetric ${cal N}=2$ Yang-Mills theory, in which case the partition function computes the 4d index of general class ${cal S}$ theories, which we verify in certain simplifying limits. Finally, we comment on the generalization to ${cal M}_3 times Sigma_{frak g}$ with more general three-manifolds ${cal M}_3$ and focus in particular on ${cal M}_3=Sigma_{frak g}times S^{1}$, in which case the partition function relates to the entropy of black holes in AdS$_6$.