Chuck's Academy

Git and GitHub

Version Management and Release Deployment

In this module, we will learn about version management and release deployment in projects managed with Git and GitHub. Version management helps to tag and track specific versions of your project, while releases provide a formal way to package and distribute your software.

Version Management

What is a version?

A version is a snapshot of your project at a specific point in time. Versions are typically tagged with semantic version numbers, like v1.0.0, v1.1.0, v2.0.0, etc. Semantic versioning follows the pattern: MAJOR.MINOR.PATCH

Tags

Tags in Git are references that point to specific points in the history, usually used to mark release versions.

Create a tag

You can create a lightweight tag or an annotated tag.

  • Lightweight tag:

    bash
  • Annotated tag:

    bash
View existing tags

To list all tags in your repository:

bash
View information about a tag

To see the details of an annotated tag:

bash
Share tags with the remote repository

To push tags to the remote repository:

bash

To push all tags:

bash

Release Deployment on GitHub

What is a release?

A release on GitHub is a packaged version of your code that you can make available to users. It includes the source code, release notes, and optionally, precompiled binaries.

Create a release

  1. Go to the repository on GitHub.
  2. Navigate to the "Releases" tab.
  3. Click "Draft a new release".

Fill out the release information

  1. Tag version: Select an existing tag or create a new one.
  2. Release title: Provide a descriptive title.
  3. Description: Detail the changes in this release (can include a changelog).
  4. Attachments: Optionally, upload precompiled binaries or relevant files.
  5. Click "Publish release" to publish the release.

Changelog

What is a changelog?

A changelog is a record of all notable changes in each version of your project. It is a valuable way to communicate improvements, fixes, and new features to users and contributors.

Maintaining a changelog

You can maintain a changelog manually in a CHANGELOG.md file and update it with each new version:

markdown

Practical Example

Create a tag for a new version

  1. Create an annotated tag:

    bash
  2. Push the tag to the remote repository:

    bash

Create a release on GitHub

  1. Go to the "Releases" tab in the GitHub repository.
  2. Click "Draft a new release".
  3. Select the previously created v1.0.0 tag.
  4. Fill out the release title and description.
  5. (Optional) Add attachments.
  6. Click "Publish release".

Release Automation

Using GitHub Actions to automate releases

You can set up GitHub Actions to automate the creation of releases. Here’s an example of how to do it with a YAML file.

  1. Create .github/workflows/release.yml:
    yaml

Best Practices

  • Semantic Versioning: Follow semantic versioning for tagging your versions.
  • Update Changelog: Maintain and update a changelog with each new release.
  • Automation: Use GitHub Actions or similar tools to automate the release creation and deployment process.
  • Release Notes: Provide detailed release notes that clearly summarize the changes made.

Additional Tools

semantic-release

semantic-release is a tool for automating version management according to semantic versioning conventions. It publishes, creates, and updates release notes automatically.

To install and set up semantic-release:

  1. Install semantic-release:

    bash
  2. Add a configuration file .releaserc at the root of the project:

    json

With these techniques, you can effectively manage versions and release deployments using Git and GitHub. In the next module, we will conclude the course with best practices in Git and GitHub.


Ask me anything