Transcript
00:00 Alright so until now in our workspace we have this release script which triggers our custom script over here and this one basically preps everything, copies it to a build folder, then runs the versioning, changes the generation and publishes it in the end. Now publishing right now means to a local registry. Ideally this will go to npm
00:18 but what we want to do now is to not run this locally by basically triggering this release script but rather having a github action that does it for us. Now there are different ways of accomplishing that like you could have a github action that triggers on every comment to main on a weekly basis. What we want to do is to have something that triggers manually where we can
00:37 click a button which will take the latest main branch and then release that and version it and generate all the changelogs. So for now we are not going to publish to npm as this first step so let me just comment this out for now and rather let's here say process.exit zero so this would be
00:54 like a good exit. Now what we want to do though maybe is also to have our changelogs here being generated into these packages. Right now we just have a workspace level changelog so let me go in here and also create a project changelogs entry that sets it to true.
01:15 So that will mean we get now one changelog for each of these files which is actually handy if you then publish it to let's say npm because in this way people can actually see what changed in this specific package as they installed it into their workspace. That means we need to update here our code to also copy over all these local changelog files.
01:37 And so let me just paste in here a handy function that basically runs our copy changelog files and so after we actually run the versioning we have our changelogs done and ready and so we can go ahead and generate the changelogs locally in our branch which will happen in the source folder
01:53 and then afterwards just go and copy them over into our build folder. So next let's create a new workflow file so let me create a github folder workflows publish yaml file and let me paste in some rough steps that will outline our publish script that we can then launch on github actions.
02:12 So this is basically the name of my script which is called publish. Here you can see how we can specify to have this a manual workflow that we need to trigger by clicking a button on github actions. You could also set this up to be at a nightly basis or weekly basis for for instance canary releases or if you're really re-experimental you can also like release a new version whenever
02:32 something gets merged to main which could also work in a fully automated fashion. Here this is just something I've set up to make sure folks don't accidentally run this because it wouldn't make any sense and would probably also fail and then down here we have the usual setup that you have for npm workspaces. Now as a first step we need to run our release actually and so
02:52 we need to have this run a new release package. What we need to do down here is to run our local script so that would be what we just ran before locally which is run release. This is our local package json script that we have in our repo so exactly this one here and since this script is
03:11 actually going to push to github and as well as also run a github release we need to make sure we have the proper token set up. As you can see here I'm getting already a suggestion for that and this token has been provided to all github actions so you can just pull this in as is here. Now up here
03:29 on the permissions since we create also commit we also need to have the contents permission that allows us to write and push commits to this repo and since we are also writing these comments we need to make sure to have the git config set up as well and so here let me add here a new section
03:47 which here sets up my username and a recording email and so with that we should be set up. Let's commit this and push it to our repo so now if I go over to our repository you can see the latest comment just got pushed up and if we now go to the actions menu here we see a new publish
04:05 script which I now can trigger manually. You see some of my previous runs here but we can trigger a new one and click a run workflow which will now run through the various steps and so once
04:20 this is complete if we now go back to our repository we should see the new commit being pushed to our repo so we now see publish 1.7.0 successfully and also see the github release that got published by our github action.