Is it OK to publish a book as an undergraduate? I am a CS student at 4th year in my university. I have done a lot of real-world projects, worked as a freelancer for many years, and have released a lot of software in use by thousands of people. I believe I have good experience about topics which I am interested in.

My question is about whether writing a book about those topics and publishing it in my name would be a good idea? I heard that whatever undergrads write in Academia is not considered reliable/trustworthy. And that even if the thing you write was actually very good, people would still not rely on it. Is this is true?

Is there a possible way to publish a book as an undergraduate student? I would like to write the book now because I feel it is so needed by my local community (non-English). We have a very limited number of books in this field. And I don't think I'll have the same amount of time as when I graduate.
Go for it, and see whether you can get one of your professors to do a technical review.  That technical review, acknowledged in the preface, will lend weight to your book.  If you have professors who speak your language, think about co-authors.

Do not, however, expect to make money.  Only blockbuster textbooks make significant money for their authors.  Also, beware vanity publishing, where you pay the publisher rather than the reverse.  

If you write the book, Amazon will let you make it available free or very cheap.  (That's true for English language books; you'll need to check about other languages.)