Should I focus on GPA or publishing (undergraduate)? I have high GPA. However, I'm now in my last undergraduate year and I feel attracted to research and publishing research outputs. Should I go ahead with publishing my research? This may negatively affect my GPA a little bit and it takes from my time a lot.
Is it worth sacrificing a little GPA to publish as an undergraduate?
There is, unfortunately, no single answer to this question. In most fields undergraduate publication is uncommon enough that any publications look good. However, the amount of value added by publications compared to GPA will depend on a range of factors, including the following: 

Area of study: Some disciplines may place a higher importance on social or community projects rather than publications, while others may prize GPA. You will need to determine how your discipline prioritizes these academic goals. Within my discipline (psychology) undergraduate publications can be helpful if applying to graduate school, but are not expected of incoming graduate students.

Intended career: Similarly, if you are entering an applied field once you graduate, they may be far more interested in other, more concrete forms of experience. Again, for someone pursuing a clinical career in psychology, publications (especially those that are clinically relevant) might be nice, but employers are more likely to be interested in clinical experience. If you are entering industry they may pay little attention to your GPA, assuming it hits a basic threshold. If you are intending to pursue an advanced degree publications may be more useful, but again this will depend on your discipline. 

Amount your GPA will drop: If you have an excellent GPA and will be risking only a small drop (so that you would still consider your final GPA to be competitive), then it may be worth pursuing publication. Many graduate programs in the USA look for a basic cut off in GPA when considering admissions; that is, so long as it is "good enough" it is ok. However, what is considered "good enough" will vary by discipline and program. If you are risking a substantial drop in GPA, it may not be worth it. Be sure you have a sense of how low your grades could be while still maintaining what you consider to be an acceptable GPA. Then determine if you feel the burden of publishing will put you at risk of missing that mark. 

Quality/timing/authorship of publications: The overall impact of your publications will influence how much "extra value" they add to your career or academic pursuits. Obviously, higher impact journals will look better than lower-tier. Beyond just having the publication on your CV, the quality of the work and your role in the work will also matter. Being involved with the development or conceptualization of the project will be more valuable in terms of experience than if you assist with data entry. That type of conceptual involvement will better enable you to discuss the project and its implications in job or graduate school interviews. Additionally, in some fields the order of authorship on papers is important and holding a valued authorship position (first, second, last, etc. depending on field) may be beneficial. In disciplines that do not assign weights to the order of authorship (e.g., mathematics), this is a non-issue.

Impact on your personal life: Finally, you will have to determine whether pursuing publications is worth the significant amount of time you believe it will take. Think about this carefully. If you begin to make some trade-offs with your GPA to pursue publishing, and then decide the work load is too much of a burden in other aspects of your life, it may be difficult to refocus on your grades. 

If you are having difficulty evaluating these different factors, seek advice from a mentor, professor, or someone who is pursuing the career you are interested in. You may also be able to gather some information about how your field and possible career paths value these factors by looking at graduate program entrance requirements, job postings, and the publicly available resumes or CVs of people in your field.