I am trying to remember a hard sci-fi novel that ends with vast civilization ships all cruising in a line toward the same destination in the galaxy.
I wouldn't call it "hard science fiction", and it's a novelette rather than a novel, and the spaceships are in a three-dimensional formation rather than a line, but "Rescue Party" by Arthur C. Clarke does end with a fleet of "vast civilization ships" carrying the whole human race away from a doomed Earth. This story was also the answer to the question Science Fiction story about humans escaping Earth's destruction among others. It was first published in Astounding Science Fiction, May 1946, which is available at the Internet Archive. At the end of the story:
The picture on the vision screen was the familiar one of endless star fields, sun beyond sun to the very limits of the Universe. Near the center of the screen a distant nebula made a patch of haze that was difficult for the eye to grasp.
Rugon increased the magnification. The stars flowed out of the field; the little nebula expanded until it filled the screen and then — it was a nebula no longer. A simultaneous gasp of amazement came from all the company at the sight that lay before them.
Lying across league after league of space, ranged in a vast three dimensional array of rows and columns with the precision of a marching army, were thousands of tiny pencils of light. They were moving swiftly; the whole immense lattice holding its shape as a single unit. Even as Alveron and his comrades watched, the formation began to drift off the screen and Rugon had to recenter the controls.
After a long pause, Rugon started to speak.
"This is the race," he said softly, "that has only known radio for two centuries — the race that we believed had crept to die in the heart of its planet. I have examined those images under the highest possible magnification.
"That is the greatest fleet of which there has even been a record. Each of those points of light represents a ship larger than our own. Of course, they are very primitive — what you see on the screen are the jets of their rockets. Yes, they dared to use rockets to bridge interstellar space! You realize what that means. It would take them centuries to reach the nearest star. The whole race must have embarked on this journey in the hope that its descendants would complete it generations later.
Another story that vaguely fits your description is "Things Pass By", a novelette by Murray Leinster, first published in Thrilling Wonder Stories, Summer 1945, also available at the Internet Archive. However, the great space fleet of the Things shows up at the beginning of Leinster's story.
The narrator of the story is the pilot/maintainer of a ship full of cryogenically-frozen colonists. Multiple other ships exist, all heading for the same destination, and the narrator communicates with the pilot of one of them as he goes past. (The narrator's ship is experiencing problems, which are the source of the story.)
I think there's a fairly low probability that this is what you're after, but still, it's worth mentioning just in case. Plus it's a brilliant little story.
It seems like a bit of a long shot, but could you be thinking of the exodus of the Pierson's Puppeteers in Larry Niven's "Known Space" future history?
In the story "At the Core", the Puppeteers found out that our galaxy would become uninhabitable in about 20,000 years, and they immediately took action to evacuate their entire population from this galaxy to another.
I had forgotten this detail, but the Puppeteers had the ability to move entire planets, and they were actually moving all their populated worlds in this fleet. Given their paranoia I'm sure they had a well-armed fleet of ships to protect the planets, too.
I seem to remember there was a story or novel where the protagonist saw the Puppeteers' Fleet of Worlds and was awed at the size of the undertaking. But I can't think of what it was, and it's possible I'm mistaken.