The text of Dai Nianzu's 中国人为何欢迎相对论 [Why did the Chinese welcome the theory of relativity], a commentary on Hu's book Einstein in China, published on 物理 [Physics; the journal for members of the Chinese Physical Society] is available here.
The relevant quotes are:
早在汉代成书的《尚书纬·考灵曜》中，古代中国人曾这样论证“地动”的思想. 它写道：“地恒动不止，而人不知. 譬如人在大舟中，闭牖而坐，舟行而人不觉也”
As early as in the book Shangshu Wei: Kaolingyao written in the Han Dynasty [202 BC – 220 AD], the ancient Chinese had argued the idea of a "moving earth". It says: "The earth is constantly moving, but people do not know it. Like people sitting in a big boat, with the windows closed, the boat is moving and people do not realize it."
Shangshu Wei: Kaolingyao is a kind of ancient Chinese writings called 纬 ("Wei"), which are apocryphal semi-religious texts purported to be prophetic. Wei books were later banned and destroyed by later dynasties due to e.g. purported political prophecies or other heretic materials. Shangshu Wei was also destroyed; there is no "original" copies preserved. But other books or written works (e.g. official announcements, private letters) may quote or refer to the destroyed books which allow reconstruction of fragments (辑佚).
So the quote is not taken from the work directly but from compilation and reconstruction by later scholars, e.g. Guweishu which was printed during the Chongzhen 崇禎 reign-period (1628-1644). The quote can be found here in a 19th century reprint of the book. From my brief overview of the chapter (Kaolingyao), it appears to be astronomical texts indeed and contains other writings on movement of the earth and stars and explanation of e.g. winter solstice.
Other books also has similar quotes, e.g. in 博物志 Bowuzhi (c. 290 CE). The full quote there is
Kaolingyao says that the earth moves up and down in all (four) directions. At the winter solstice, the earth moves upward, 30,000 miles [See note] from the north to the west; at the summer solstice, the earth moves downward, 30,000 miles from the south to the east; at the two equinoxes spring or autumn, it is somewhere in the middle. The earth is constantly moving, but people do not know it. It is just like people sitting in a big boat, with the windows closed, the boat is moving and people do not realize it. The four directions of heaven and earth are connected by sea water, so the earth is a small part of this. the peoples of different appearances and types living in the different directions are collectively called the "four seas", which means they are all near the sea and implies that they are dim and foolish without insight.
Note: not actual miles, but an unspecified Chinese distance unit; nor is 30,000 an exact number.
(Translated and adapted from the modern Chinese translation of the classic texts available here).
Alternatively, according an unsourced, although coherent post online, there is another book from Tang dynasty (618 to 907 CE) that claims the relevant quote is from another apocryphal book from Han dynasty [202 BC – 220 AD] called 河图 Hetu.
I would be reasonably confident that the quote and its ideas existed before Galileo, although it may be difficult to determine how long ago it is actually from.
Disclaimer: I am not a historian of science (nor of anything else, e.g. ancient Chinese books). I am simply providing the context that I can find and reasonably verify.