Skip to content

Commit

Permalink
ci: fail draft release if performed from main
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniBodor committed Jul 8, 2024
1 parent e039e69 commit c72cf34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/release_github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ jobs:
shell: bash -l {0}

steps:
- name: Release from develop branch by default
- name: Fail if main branch was selected
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
echo "Cannot release from main branch, please select valid release branch."
exit 1
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -48,7 +44,7 @@ jobs:
- name: Merge changes into main
run: |
git switch main
git merge $RELEASE_BRANCH --no-ff --no-commit
git merge ${{ github.ref_name }} --no-ff --no-commit
git merge --continue
- name: Bump version
Expand Down Expand Up @@ -98,7 +94,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "-- searching for associated PR"
pr_number=$(gh pr list --head $RELEASE_BRANCH --json number --jq '.[0].number')
pr_number=$(gh pr list --head ${{ github.ref_name }} --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
echo "-- closing PR #$pr_number"
gh pr close $pr_number
Expand All @@ -114,9 +110,9 @@ jobs:
- name: Delete release branch other than main or develop
run: |
if [[ $RELEASE_BRANCH != "main" && $RELEASE_BRANCH != "develop" ]]; then
echo "-- deleting branch '$RELEASE_BRANCH'"
git push origin -d $RELEASE_BRANCH
if [[ ${{ github.ref_name }} != "main" && ${{ github.ref_name }} != "develop" ]]; then
echo "-- deleting branch '${{ github.ref_name }}'"
git push origin -d ${{ github.ref_name }}
else
echo "-- branch '$RELEASE_BRANCH' will not be deleted from remote"
echo "-- branch '${{ github.ref_name }}' will not be deleted from remote"
fi
5 changes: 2 additions & 3 deletions README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,10 @@ We use [prettier](https://prettier.io/) for formatting most other files. If you
- `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.
- Note that you cannot release from `main` (the default shown) using the automated workflow. To release from `main`
directly, you must [create a release manually](#manually-create-a-release) below.
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 c72cf34

Please sign in to comment.