Thank you, everyone. I see the defactmentation rules are now learned and people are following
it. If you are not familiar with the defactmentation rules, go as much to decide as possible. That
way we can fit more people who are entering through there. We are amazing door people.
Our next speaker is Dennis and he is presenting a more controversial title than was on the
initial proposal. In this case I would not have accepted the kidding. I heard the second
time today that make fires are horrible. Again that is a personal opinion but maybe they are.
Because this is the second time somebody mentioned this and this is the first time somebody
proposed a solution for it. I have to be fair, I already use GoReleaser. Anyone else?
Okay.
It is no introduction anymore. Everybody knows you already. They go away. Thank you.
Hi, everyone. My name is Denis Germain. I am a French music streaming service. I am
also a tech blogger and if I am telling you this, all the slides, links, related stuff
can be found on the blog. We are on the blog right now. You can find exactly everything.
As you have guessed by now, by my beautiful accent, I am French but hopefully everyone
will understand what I am going to say.
So yeah, the title is a bit controversial. Okay. Putting an end to make files in Go projects
with GoReleaser. Why is this talk? 15 years ago I started my career as a systems engineer
and I haven't wrote a lot of code during that time. I wrote a bit of Python script
and there are a lot of infrastructure as code but not compiled code. Last year I fell
in love with Go. Many of you perhaps as well. But if you know site reliability engineer,
you know that we are the laziest persons on earth. Like literally. We don't ever want
to do anything boring. We don't want to do anything manually. We want to automate everything
to keep drinking coffee instead of working. And I found out that compiled programs are
boring because you have to compile them. Which is not a problem I had when I was writing
Python. And I also started to contribute and to maintain open source projects, little things
here and there. And I found that there were also other tasks really boring that I didn't
want to do by hand. Among those tasks is cross compiling. You just don't have to compile
your binary into one OS and one architecture. With Go you can do it quite easily for many
architectures and many OSes but you have to do it. Building Docker images, obviously you
probably want your users to be able to run this in a container. Making a bunch of packages
like Debian packages, flat packs and so on. And if you create all those artifacts you will
probably also want to check some and sign them so that your user can make sure that
the binaries have not been altered during the downloading process. And last but not
least you will probably release versions of your software if it's complex enough. And
making those releases on your favorite SEM like GitLab or GitHub can be tedious as well.
So, first solution. And I have to say that all those solutions are valid and work. When
I was in engineering school I learned about make and make file. And it worked really great.
I was using it for C programs and when you have to compile something you just create
a simple make file and then you run your task and it's awesome. If you work in an
industrialized environment you probably heard of Jenkins. And if you love Groovy I'm not
judging. But you can automate all those tasks in various Jenkins files. If you run on some
let's say modern SEMs like GitHub or GitLab you will probably use the GitLab CI or the
GitHub Action to help you with this. And the last one is a bit of a joke and you probably
want to understand it if you don't know. But you can do bash scripts. But what I'm going
to show you today and I hope I'm going to convince you is that you can do all this and
much more with a software that is called Gorillazer. Gorillazer is an open source software.
It's an open source open core. Most of the features are open source but if you want more
features you have to pay the maintainer for them. Today we are going to use the open source
version. And it's an awesome software written in Go for Go. Okay. Now it's time to the demo.
Okay. Some of you got that joke. Okay. So for this demo I have written a very super small
program in GoLonger. It's a bit of a joke as well. I don't know if that's the case in
Belgium or in other countries but hairdressers tend to put funny names or play on words in
the name of the shop. So to give you an example that anyone will be able to understand, one
may call it shop hair force one but with an H instead of the hair instead of the plane.
Okay. And in France nearly all hairdressers do that. And so someone made a database of
all those funny names in shops, put it in a JSON database, hosted it on the government
data.gov.fr and I used it, created a program that picks randomly an entry in this database
and output it. So that's what the program is doing basically. It's really silly and I
like silly things. Okay. So no, that's not what I want to show you. Yeah. Is it big enough
for those really? No, not big enough. Okay. Let's increase. It's going to be hard to see
but let's try it like that. So what we are doing in this make file to build this program
to save me some time because my time is precious. I start by doing a prepare which is going to
do the go mod tidy and then I'm going to build which is calling the prepare obviously and
then calls my command to build my software. I give it some environment variables. So I
give it some environment variables to build it for my laptop and some LD flags because
I write the version as an art coded variable. Okay. Let's try to run it. 0.0.1. Make, build.
Okay. So you can see I'm really lazy because it's not that difficult but bear with me. Okay,
diminutive or some. Okay. Great. Let's declare. Okay. Real funny. I'm going to do a little
bit of a demo. I'm pretty sure the French speakers are enjoying it's much more than the
other ones. Okay. And if I want to build a Docker image for this, for this binary, I have also
made a task in my make file. The Docker file looks like this. So I use a multi-stage build.
So in the first stage, in the builder stage, I'm going to download all the necessary dependencies
to build my software and then I copy it in a new container containing only the binary.
So the attack surface is way smaller and it's better for maintenance and size. I'm pretty
sure it won't work because I have some networking issue but we'll try. Nevertheless. Okay. I forgot
to add the version. I'm pretty sure you have always seen how Docker is built and it's going
to fail. So I'm not going to continue here and skip to the rest of the demo. Maybe I have one here.
So in there. Okay. So it's going to be a little bit more complicated. So I'm going to do a
bit of, it works just like the other one. The version is displayed and then a random entry. Okay. Cool.
How can we do better with Gorillazer? Let's say you don't have any idea how Gorillazer works. So there
is a command for you which is called Gorillazer init. One which is going to create a default
create a default Correlizer file,
a default configuration file.
I'm going to remove most of the stuff.
Okay.
Up, and then we will talk about it.
Great.
Okay, so what does this do?
As you can see, there are before hooks
that we can call before doing the actual building.
So here we do the go-mode ID,
just like I was doing before with my prepare in my make.
And then the builds come.
So I can also add environments, variables.
I can tell Correlizer which architectures and OSs
I want to build on.
So let's say I want to build on
ARM64 and AMD64 and on Linux and Mac OS as well.
Okay.
And I'm going to cheat a little bit
to gain some precious seconds here.
I'm going to have the famous LD flags
that I was hard before to hard code my version variable.
And as you can see, I'm not going to pass it
as an un-variable as I did before,
but I'm going to use an automated variable
coming from Correlizer.
Because what I haven't told you is that Correlizer,
as this name says, is going to help us making releases.
And obviously when you release software,
you are going to add a new version for it.
So we are going to leverage the power of Git tags.
We are going to tag our code
and the tag is going to give us our version.
So, okay.
So to make an example, I'm going to add commit.
Then I'm going to tag my code with a new version
being 0.0.1.
I think that's correct.
Okay.
And then, oh no.
Okay.
And then I'm going to try to build my software
with Correlizer.
So Correlizer, there is a sub command called build,
which is going only to make the build.
We'll show you the rest later.
And if I have, okay.
So what is Correlizer doing?
As you can see, it's really quick
because my program is really small.
But if you have some more complex program,
if you try to cross compile,
it's going to take obviously more time.
So Correlizer detected our version with the Git tag.
It ran the, the gomotid with the before hooks.
And then it cross compiled our binary
in on four different targets
just by adding a few lines in my YAML.
Okay.
And just to show you that I haven't cheated,
we are going to try to run it once again
because I never tire of hairdresser jokes.
Okay.
Imaginaire artistif.
Real funny.
Okay.
Okay. So cool.
So now we have something that helps us build software,
but can we do more?
Obviously, yes.
Or else I wouldn't have been selected to talk,
to talk to you today.
So I'm, I have some time left,
but I'm not going to be able to show you step by step.
So I'm going to cheat and take the final configuration file
with all I want to show you.
Just bear with me one second.
I'm just going to modify one or two things.
And then I'm going to say what I'm doing.
Okay.
So,
so here I'm going to tag and push my code
with one little script.
Okay. So what did I change?
So we were there.
So we had my binary and the version.
Okay.
I added one section, which is called archives.
Archives is going to make archives for us.
And we are going to add overrides
because it's possible to override the most,
most functions in Gorillazer for specific arch.
Obviously in Windows, you don't usually,
don't always have something to open our GZ files.
So for Windows, I'm going to override
and put a zip instead.
If you are working in regulated environments, sorry,
you probably will want to have a software
bill of material, S-BOM.
So Gorillazer is going to be able to create
SIFT S-BOMs for you.
You are going to want to check some everything.
And then you are going to want to be able
to create Docker images.
Here I use buildx to cross compile my image.
So here I'm compiling it for Linux, AMD64.
I'm going to push it to GitLab registry.
Oh, I forgot to show you here.
I'm using another variable,
which is a project name,
which is all automatically created by Gorillazer
and it's going to help us to reuse our Gorillazer files
between projects.
I can use the version here as well.
Okay, and last but not least,
I'm going to run an announce on Mastodon
to tell the world about my awesome new version
of my software.
Okay.
And I'm not going to do it on my laptop.
In fact, it's already run on GitLab
because I have a GitLab CI running configured
that I haven't showed you.
So here the GitLab CI YAML file just runs
a Docker image of Gorillazer
with the correct environment, variable and secrets.
And does the build for me.
Okay.
Okay, okay, okay.
Oh, and I also modified the Docker file
because I don't need the builder step,
the multistake build because that's Gorillazer
that does it for me as well.
Okay, so now is the time.
I'm really afraid that the demo failed.
So I'm going to check if my job launched correctly
and if it worked.
Oh, it's still running.
Okay, let's try to see.
Let's try to see if it's running correctly.
Okay.
It looks promising.
So the GitLab CI has detected
that I pushed a new tag, the 0.0.2.
It launched an image, Gorillazer.
It has detected that my tag is 0.0.2
has run the Gomad tidy,
has built my software in many OSes and many architectures
because I have not explicitly told it which one I wanted.
So by default, it does it on like eight targets.
We can also see that it has created archives
and Sbombs for each.
It has created two Docker images.
Someone has seen my student post
and pushed them to the GitLab registry.
And then it has uploaded all the artifacts, sorry,
to the GitLab.
Okay.
And last but not least,
we are going to check on Mastodon if something happened.
But as I can see, I already have some messages
telling me that it's okay.
So if I click on the link,
I'm redirected to my release page
which has been created for me,
containing the various assets,
the change log with all the commits on this release.
And if I try to take a look,
I'm not going to open the binaries
because obviously it works.
If I take a look at the package registry,
no, the container registry, sorry.
Okay.
We can see that we have the Docker images
and they have been created two minutes ago
so I haven't cheated.
Okay, great.
So the demo works.
Okay.
So I was a bit stressed so I spoke really fast.
But what I wanted to show you today
and I hope you are convinced
is that GoReleaser is an awesome tool.
You can do cross-compilation,
you can do Docker images,
you can do signature and checksoming GitLab releases,
you can post on social media
or other communication channels.
There are many more options
that I haven't even all explored.
Obviously you could have done that with a make file
or just in file or so on
but you have to create most of the steps by yourself.
And I think there's nothing wrong
in leveraging the work of someone else to do it for you.
That's it for me.
You can leave me some comments
and tell me if I was good
or if you will learn something using the QR code.
And thanks everyone.
.(audience applauding and cheering loudly.)
If you have any questions,
I'm not sure I will be able to answer all.
I'll come hand you the microphone real quickly.
No difficult questions please.
Thank you.
Thank you for the talk and for the tool.
My question is,
is there a possibility to remove in Go project
from the title?
I mean, is it possible to make the tool not,
so Go oriented let's say?
Because I see there is a potential for it
to be like a structure for something bigger
or generic let's say.
Yes, okay.
That's the word I want to say.
Okay, I get it.
But good stuff anyway.
So you, it's really Go oriented.
You can't cheat because there is an option
to change the binary used to compile it
but it's really hacking the tool.
In fact, I use it as well for,
with in conjunction of another tool
which is called FINE,
FINE which is a tool that helps create UIs with Go,
FINE, F, Y, N, E.
And FINE has its own cross builder,
cross platform builder.
And I try to make them work together.
And it was a bit like, okay,
I add some scripts and put some glue to make it work.
So it's going to work much better
in a fully Go environment.
Any more questions?
Right in front.
Thanks, I think you forgot to mention
the limitations of Go release.
As I remember, it doesn't support in open source version
that multiple projects built in one repo.
So I'm sorry, I didn't hear?
So basically Go release doesn't support
in open source version,
release of multiple binaries from one repo.
Okay, I don't know the answer, but okay.
Thanks for the...
We can't know everything.
Is that a wave for...
I need a mic.
I can ask my question this way.
Okay, but I will have to repeat it.
Excellent.
So, great work on Go release there.
My question is, what about using it for things
that are Go based,
that have a more complex compilation tool
in things like C.Ga?
I know that Go STL is using Go release now.
Did you comment on this?
Is this an idea?
No, I'm not sure.
Can you repeat the question?
Okay.
I can repeat if you want.
Yeah, okay.
Can you use Go release for very much complex
Go project, Sdl and C.Ga?
Well, I have not worked on a very complex Go project yet.
But it would...
Obviously there are limitations
and it's going to sometimes be hard
to glue things together.
But for small to medium project,
I think it's an awesome tool.
Thank you.
Another round of applause.