diff --git a/.github/workflows/auto_merge_release_hotfix_into_develop.yaml b/.github/workflows/auto_merge_release_hotfix_into_develop.yaml deleted file mode 100644 index a81c2b4b..00000000 --- a/.github/workflows/auto_merge_release_hotfix_into_develop.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: auto_merge_release_hotfix_into_develop - -on: - pull_request: - types: - - opened - branches: - - develop - -env: - BRANCH_DEVELOP: develop - -jobs: - auto_merge: - name: Merge release into develop - runs-on: ubuntu-latest - permissions: - contents: write - # only merge pull requests that begin with 'release/' or 'hotfix/' - if: startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/') - - steps: - - name: Set GitHub token - run: | - echo "GH_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - token: ${{ env.GH_TOKEN }} - # needed by "gh pr create" - fetch-depth: 0 - - - name: Merge PR - env: - PR_NUMBER: ${{ github.event.number }} - PR_TITLE: Merge branch '${{ github.head_ref }}' into ${{ env.BRANCH_DEVELOP }} - run: | - gh pr merge ${PR_NUMBER} -m -d -t "${PR_TITLE}" diff --git a/.github/workflows/create_release_pr.yaml b/.github/workflows/create_release_pr.yaml new file mode 100644 index 00000000..85367934 --- /dev/null +++ b/.github/workflows/create_release_pr.yaml @@ -0,0 +1,43 @@ +name: create_release_pr + +on: + push: + branches: + - "release/**" + - "hotfix/**" + +jobs: + create_release_pr: + name: Create release pull request + runs-on: ubuntu-latest + permissions: + contents: write + # only create draft pull requests on + # pushing to branches 'release/' or 'hotfix/' + if: | + startsWith(github.ref_name, 'release/') || + startsWith(github.ref_name, 'hotfix/') + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.ref_name }} + token: ${{ secrets.GH_TOKEN }} + # needed by "gh pr create" + fetch-depth: 0 + + - name: Set release type as release + if: startsWith(github.ref_name, 'release/') + run: echo "RELEASE_TYPE=release" >> "$GITHUB_ENV" + + - name: Set release type as hotfix + if: startsWith(github.ref_name, 'hotfix/') + run: echo "RELEASE_TYPE=hotfix" >> "$GITHUB_ENV" + + - name: Create release pull request + uses: ghacts/gitflow/create-release-pr@main + with: + token: ${{ secrets.GH_TOKEN }} + release-type: ${{ env.RELEASE_TYPE }} + release-branch-prefix: '${{ env.RELEASE_TYPE }}/' diff --git a/.github/workflows/draft_release_hotfix_pr.yaml b/.github/workflows/draft_release_hotfix_pr.yaml deleted file mode 100644 index d85b5d57..00000000 --- a/.github/workflows/draft_release_hotfix_pr.yaml +++ /dev/null @@ -1,86 +0,0 @@ -name: draft_release_hotfix_pr - -on: - push: - branches: - - "release/**" - - "hotfix/**" - -env: - BRANCH_MAIN: main - BRANCH_DEVELOP: develop - TAG_PREFIX: v - -jobs: - create_draft_pr: - name: Create draft PR - runs-on: ubuntu-latest - permissions: - contents: write - # only create draft pull requests on pushing to branches 'release/' or 'hotfix/' - if: (startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/')) - - steps: - - name: Set GitHub token - run: | - echo "GH_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ github.ref_name }} - token: ${{ env.GH_TOKEN }} - # needed by "gh pr create" - fetch-depth: 0 - - - name: Set environment variables for publishing release - if: startsWith(github.ref_name, 'release/') - run: | - BRANCH_NAME="${{ github.ref_name }}" - VERSION=${BRANCH_NAME#release/} - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - echo "RELEASE_TYPE=release" >> $GITHUB_ENV - - - name: Set environment variables for publishing hotfix - if: startsWith(github.ref_name, 'hotfix/') - run: | - BRANCH_NAME="${{ github.ref_name }}" - VERSION=${BRANCH_NAME#hotfix/} - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - echo "RELEASE_TYPE=hotfix" >> $GITHUB_ENV - - - name: Check whether pre-release version - if: contains(env.RELEASE_VERSION, 'alpha') || contains(env.RELEASE_VERSION, 'beta') || contains(env.RELEASE_VERSION, 'rc') - run: | - echo "PRE_RELEASE=true" >> $GITHUB_ENV - - - name: Set PR title - run: | - RELEASE_TYPE=${{ env.RELEASE_TYPE }} - PR_PREFIX=${RELEASE_TYPE^} - PR_TITLE="${PR_PREFIX} ${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}" - echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV - - - name: Create PR '${{ env.PR_TITLE }}' - env: - PR_BODY: | - This PR was created to prepare for releasing ${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}. - - Merging this PR will create the GitHub release ${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}. - run: | - PR_LABELS="automated-pr,${RELEASE_TYPE}-pr" - - [[ ${PRE_RELEASE:-false} == "true" ]] && gh label create 'pre-release' --force && PR_LABELS="$PR_LABELS,pre-release" - - for LABEL in $(echo $PR_LABELS | sed "s/,/ /g"); do gh label create $LABEL --force; done - - PR_ID=$(gh pr list --state open --search "base:${{ env.BRANCH_MAIN }} head:${{ github.ref_name }}" | head -1 | cut -f1) - [[ ! -z "$PR_ID" ]] && echo "PR was created with ID $PR_ID. Ignored!" || \ - gh pr create \ - --draft \ - --base "${{ env.BRANCH_MAIN }}" \ - --head "${{ github.ref_name }}" \ - --title "${{ env.PR_TITLE }}" \ - --body "${{ env.PR_BODY }}" \ - --label "${PR_LABELS}" \ - --fill diff --git a/.github/workflows/merge_release_into_develop.yaml b/.github/workflows/merge_release_into_develop.yaml new file mode 100644 index 00000000..30704d10 --- /dev/null +++ b/.github/workflows/merge_release_into_develop.yaml @@ -0,0 +1,35 @@ +name: merge_release_into_develop + +on: + pull_request: + types: + - opened + branches: + - develop + +jobs: + merge_release_into_develop: + name: Merge release into develop + runs-on: ubuntu-latest + permissions: + contents: write + # only merge pull requests that begin with 'release/' or 'hotfix/' + if: | + startsWith(github.head_ref, 'release/') || + startsWith(github.head_ref, 'hotfix/') + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GH_TOKEN }} + # needed by "gh pr create" + fetch-depth: 0 + + - name: Merge ${{ github.head_ref }} into develop + uses: ghacts/gitflow/merge-release-into-develop@main + with: + token: ${{ secrets.GH_TOKEN }} + release-branch: ${{ github.head_ref }} + develop-branch: develop diff --git a/.github/workflows/publish_release.yaml b/.github/workflows/publish_release.yaml new file mode 100644 index 00000000..89ea2d4c --- /dev/null +++ b/.github/workflows/publish_release.yaml @@ -0,0 +1,54 @@ +name: publish_release + +on: + pull_request: + types: + - closed + branches: + - main + +env: + VERSION_TAG_PREFIX: "v" + +jobs: + release: + name: Publish release + runs-on: ubuntu-latest + permissions: + contents: write + # only merge pull requests that begin with 'release/' or 'hotfix/' + if: github.event.pull_request.merged == true && + (startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/')) + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.GH_TOKEN }} + # needed by "gh pr create" + fetch-depth: 0 + + - name: Set release type as release + if: startsWith(github.head_ref, 'release/') + run: echo "RELEASE_TYPE=release" >> "$GITHUB_ENV" + + - name: Set release type as hotfix + if: startsWith(github.head_ref, 'hotfix/') + run: echo "RELEASE_TYPE=hotfix" >> "$GITHUB_ENV" + + - name: Extract version from release branch + env: + BRANCH_NAME: ${{ github.head_ref }} + BRANCH_PREFIX: '${{ env.RELEASE_TYPE }}/' + run: | + RELEASE_VERSION=${BRANCH_NAME#${BRANCH_PREFIX}} + echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV + + - name: Publish release + uses: ghacts/gitflow/publish-release@main + with: + token: ${{ secrets.GH_TOKEN }} + release-type: ${{ env.RELEASE_TYPE }} + release-branch-prefix: '${{ env.RELEASE_TYPE }}/' + notes-file: '.changes/${{ env.VERSION_TAG_PREFIX }}${{ env.RELEASE_VERSION }}.md' diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index f4240174..00000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,86 +0,0 @@ -name: release - -on: - pull_request: - types: - - closed - branches: - - main - -env: - BRANCH_MAIN: main - BRANCH_DEVELOP: develop - TAG_PREFIX: v - CHANGELOG_DIR: .changes - -jobs: - release: - name: Publish new release - runs-on: ubuntu-latest - permissions: - contents: write - # only merge pull requests that begin with 'release/' or 'hotfix/' - if: github.event.pull_request.merged == true && - (startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/')) - - steps: - - name: Set GitHub token - run: | - echo "GH_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - token: ${{ env.GH_TOKEN }} - # needed by "gh pr create" - fetch-depth: 0 - - - name: Extract version from release branch - if: startsWith(github.head_ref, 'release/') - run: | - BRANCH_NAME="${{ github.head_ref }}" - VERSION=${BRANCH_NAME#release/} - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Extract version from hotfix branch - if: startsWith(github.head_ref, 'hotfix/') - run: | - BRANCH_NAME="${{ github.head_ref }}" - VERSION=${BRANCH_NAME#hotfix/} - echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Check whether pre-release version - if: contains(env.RELEASE_VERSION, 'alpha') || contains(env.RELEASE_VERSION, 'beta') || contains(env.RELEASE_VERSION, 'rc') - run: | - echo "PRE_RELEASE=true" >> $GITHUB_ENV - - - name: Create release - env: - RELEASE_TAG: "${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}" - run: | - gh release create \ - ${{ env.RELEASE_TAG }} \ - --target ${{ github.event.pull_request.merge_commit_sha }} \ - --title "${{ env.RELEASE_TAG }}" \ - --notes-file "${{ env.CHANGELOG_DIR }}/${{ env.RELEASE_TAG }}.md" \ - --prerelease=${PRE_RELEASE:-false} - - - name: Create PR ${{ github.head_ref }} -> ${{ env.BRANCH_DEVELOP }} and merge automatically - env: - PR_TITLE: Merge branch '${{ github.head_ref }}' into ${{ env.BRANCH_DEVELOP }} - PR_BODY: | - This PR merges the branch '${{ github.head_ref }}' back into the branch '${{ env.BRANCH_DEVELOP }}'. - - This ensures that the updates on the branch '${{ github.head_ref }}', i.e. CHANGELOG and manifest updates, are also present on the branch '${{ env.BRANCH_DEVELOP }}'. - PR_LABEL: automated-pr - run: | - gh label create ${{ env.PR_LABEL }} --force - - gh pr create \ - --base ${{ env.BRANCH_DEVELOP }} \ - --head ${{ github.head_ref }} \ - --title "${{ env.PR_TITLE }}" \ - --body "${{ env.PR_BODY }}" \ - --label "${{ env.PR_LABEL }}" \ - --fill