Can 2017 income be used for a 2018 Roth IRA Contribution?

Last year, from June of 2017 to December of 2017, I earned 14,000 dollars. I maxed out my 2017 Roth IRA contribution at 5,500 dollars. Can I contribute to my 2018 Roth IRA with income from last year? Or do I have to wait until I have made 5,500 dollars in this year (Jan 1-Dec 31).

Thank you!