Important: I archived this repository because I included the functionality with CompVer. Therefore, you can find the GitHub action, in a slightly different form, here.
This small solution is intended to automatically merge a branch, with each new tag / release, the data from the default branch.
This is especially important for solutions like Go libraries, where you have to maintain an associated v2
branch from version 2 on. So you can use this action exactly for this and with every new version the versions branch gets a merge to the default branch. Thus, this is always supplied with the correct data.
For this to work correctly, the corresponding branch must be created. You can do this directly at GitHub. You can decide how this should be called. But you have to consider this when creating the action. Here you can find an example of how you can use the action. In this example, because it is convenient for golang, we use a suffix of v
, so that when the new tag is checked, the major version number is output with the v
prepended.
That means we would currently create a v1
branch, which is only maintained as long as there are releases / tags in the major version 1. After that we create a branch for v2
, so that this can also be maintained automatically.
Here you can find an example for the action, so you can use it in your project. How to create a github action you can find here.
If you use this example, please pay attention to the version number below the dot Get the major version
.
name: VMerge
on:
push:
tags:
- "v*.*.*"
env:
USER_NAME: "GitHub Action"
USER_EMAIL: "actions@github.com"
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
COMMIT_MESSAGE: "ci: The data of the default branch was merged automatically."
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set repository tag information
id: information
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Get the major version
id: vmerge
uses: gowizzard/vmerge@v1
env:
VERSION: ${{ steps.information.outputs.tag }}
SUFFIX: "v"
- name: Set git config
run: |
git config --local user.name "$USER_NAME"
git config --local user.email "$USER_EMAIL"
- name: Merge data from master branch
run: |
git fetch
git checkout ${{ steps.vmerge.outputs.branch_name }}
git pull
git merge --no-ff "origin/$DEFAULT_BRANCH" -m "$COMMIT_MESSAGE"
git push
Thanks to JetBrains for supporting me with this and other open source projects.