githubpull-requestgithub-release

How to use Github releases feature using Pull Request workflow


I have a project in Github where all the team uses Pull Request workflow. So each developer has a Fork of the master repository.

The process for solving an issue of adding a new feature is the following:

  1. The developer creates a branch into his local repository (Fork from master)
  2. The developer starts working on the ticket for solving the issue
  3. Once the developer finish the ticket, he commits the changes to his local repo and push the changes to his Fork in Github
  4. Then, he request a Pull Request from that branch to Master
  5. Team leader access master repository and validates the Pull Request and accepts the changes and merge it to the master.

When we are going to make a publish the code that is published comes from the Master repo but we want to make like a base line of the code that is in Master so any other Pull Request accepted and merged into Master doesnt change the code that we are going to Release.

Does releases functionality from Github is something we can use to take a copy of Master repo code at some point and keep that code unchanged even if some new Pull Request is merged into master?


Solution

  • To answer your question, yes you can do this with releases. GitHub releases are really just git tags. You can't (as far as I know) create a release with a PR, but you can use a tag:

    $ git checkout master
    $ git pull origin master
    $ git tag v1.2.3
    $ git push origin master --tags
    

    You will now see v1.2.3 in your "Releases" section on GitHub. You can edit it to make it more verbose, attach binaries, etc.

    Tags don't work like branches, but you can make a branch from a tag easily if you ever need to.

    Make sure you've got the tags fetched:

    git fetch --all --tags --prune
    

    Then check out the tag and create a new branch:

    git checkout tags/<tag_name> -b <branch_name>