Auto Publish(Release) - GitHub Actions

[[Continuous Integration (CI) - GitHub Actions]]

Continuous Integration(CI) is often coupled with the idea of Continuous Delivery(CD).

For releasing or publishing our code automatically, we will use the action Release Drafter

Now we have to configure our actions file.

We can create new workflow file or we can add this workflow to our already present files.

If you want to add the release drafter workflow to already present action file, then the snippet is

name: <PreviousContent>

on:
	<PreviousContent>

jobs:
	allPreviousJos:
		<PreviousJobsContent>

	update_draft_release:
		runs-on: ubuntu-latest
		needs: [ All previous jobs comma separated ]
		steps:
			- uses: toolmantim/release-drafter@v5.2.0
			  env:
				  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

If you see the above code snippet we added one more keyword needs


needs

This just means that this particular jobs requires the mentioned jobs to be executed first then run this particular job.

In our code, we need our publish job to be executed once all our tests and build process is executed successfully, so in that sense we want to execute the build, test, and all other steps to run perfectly and then execute this publish method.


If you are adding new workflow file for the auto-publish process

create new file with whatever name you want and have the below content in that file

Once this is done, The release drafter requires a template to create all the changes and updates that the release had and little like documentation for updated version of release thing.

So create this template in .github folder with below contents

now commit the changes.

Remember that the template should be named as release-drafter.yml in .github folder in your repo


Here comes the good part

Make some random changes in the repo but not in main branch, let those changes be anything

Here i will do some changes regarding in the index.js file and commit them in the testing branch

Once the necessary changes are done, raise the pr and wait for workflows to run and see whether they all checks are passed or not, if not resolve the issue


Releases

Now if you click on releases link in your repo, you will see a draft release docs already being created which is created by github-actions

The draft version may look something like this

![[Git and Github/Github-Actions/Images/Draft-Release-Content.png]] You can also edit this draft or delete this draft

Now release your package...

Last updated