Skip to content

Commit

Permalink
ci: use built in system to select the release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniBodor committed Jul 8, 2024
1 parent f373865 commit e039e69
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/release_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ on:
- patch
- minor
- major
release_branch:
description: "Branch to use for releasing."
type: string
default: "develop"

permissions:
contents: write
Expand All @@ -28,6 +24,16 @@ jobs:
shell: bash -l {0}

steps:
- name: Release from develop branch by default
if: ${{ github.ref_name }} == 'main'
run: |
echo "RELEASE_BRANCH=develop" >> $GITHUB_ENV
- name: Release from specified branch
if: ${{ github.ref_name }} != 'main'
run: |
echo "RELEASE_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand All @@ -42,7 +48,7 @@ jobs:
- name: Merge changes into main
run: |
git switch main
git merge ${{ github.event.inputs.release_branch }} --no-ff --no-commit
git merge $RELEASE_BRANCH --no-ff --no-commit
git merge --continue
- name: Bump version
Expand Down Expand Up @@ -92,8 +98,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "-- searching for associated PR"
branch_name=${{ github.event.inputs.release_branch }}
pr_number=$(gh pr list --head $branch_name --json number --jq '.[0].number')
pr_number=$(gh pr list --head $RELEASE_BRANCH --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
echo "-- closing PR #$pr_number"
gh pr close $pr_number
Expand All @@ -109,9 +114,9 @@ jobs:
- name: Delete release branch other than main or develop
run: |
if [[ ${{ github.event.inputs.release_branch}} != "main" && ${{ github.event.inputs.release_branch}} != "develop" ]]; then
echo "-- deleting branch '${{ github.event.inputs.release_branch }}'"
git push origin -d ${{ github.event.inputs.release_branch }}
if [[ $RELEASE_BRANCH != "main" && $RELEASE_BRANCH != "develop" ]]; then
echo "-- deleting branch '$RELEASE_BRANCH'"
git push origin -d $RELEASE_BRANCH
else
echo "-- branch '${{ github.event.inputs.release_branch}}' will not be deleted from remote"
echo "-- branch '$RELEASE_BRANCH' will not be deleted from remote"
fi
11 changes: 7 additions & 4 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ We use [prettier](https://prettier.io/) for formatting most other files. If you
- if everything goes well, this PR will automatically be closed after the draft release is created.
1. Navigate to [Draft Github Release](https://github.com/EIT-ALIVE/eitprocessing/actions/workflows/release_github.yml)
on the [Actions](https://github.com/EIT-ALIVE/eitprocessing/actions) tab.
2. On the right hand side, you can select the level increase (patch, minor, or major) and which branch to release from.
- if released from a different branch than `develop`, then the workflow will attempt to merge the changes into develop
as well. If succesfull, the release branch will be deleted from the remote repository.
- [follow semantic versioning conventions](https://semver.org/) to chose the level increase:
2. On the right hand side, you can select the level increase ("patch", "minor", or "major") and which branch to release from.
- [Follow semantic versioning conventions](https://semver.org/) to chose the level increase:
- `patch`: when backward compatible bug fixes were made
- `minor`: when functionality was added in a backward compatible manner
- `major`: when API-incompatible changes have been made
- Note that if you choose `main` (the default shown) as the release branch, this will be re-defaulted to develop
instead. To release from `main` directly, you must follow the [manual release
instructions](#manually-create-a-release) below.
- If the release branch is not `develop`, the workflow will attempt to merge the changes into develop as well. If
succesfull, the release branch will be deleted from the remote repository.
3. Visit [Actions](https://github.com/EIT-ALIVE/eitprocessing/actions) tab to check whether everything went as expected.
4. Navigate to the [Releases](https://github.com/EIT-ALIVE/eitprocessing/releases) tab and click on the newest draft
release that was just generated.
Expand Down

0 comments on commit e039e69

Please sign in to comment.