-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7d680d
commit 1143ce7
Showing
2 changed files
with
40 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,16 +31,18 @@ on: | |
required: true | ||
|
||
jobs: | ||
validate-release: | ||
name: "Validates that tag does not already exist" | ||
validate-and-prepare: | ||
name: "Validate that tag does not already exist and prepare branch" | ||
runs-on: ubuntu-latest | ||
if: ${{ github.ref_name == 'main' || startsWith(github.ref, 'refs/tags/') }} | ||
outputs: | ||
branch_name: ${{ steps.resolve_branch.outputs.branch_name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- id: check-tag | ||
name: Check if tag exists | ||
name: "Check if tag exists" | ||
run: |- | ||
tag=$(git tag -l ${{ inputs.version }}) | ||
|
@@ -50,25 +52,25 @@ jobs: | |
echo "Tag already exists! Please choose another tag." | ||
exit 1 | ||
fi | ||
resolve-branch-prefix: | ||
name: "Resolve branch prefix (release or bugfix)" | ||
needs: validate-release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
branch_name: ${{ steps.release.outputs.branch_name || steps.bugfix.outputs.branch_name }} | ||
steps: | ||
- id: release | ||
if: github.ref_name == 'main' | ||
run: echo "branch_name=release/${{ inputs.version }}" >> "$GITHUB_OUTPUT" | ||
- id: bugfix | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: echo "branch_name=bugfix/${{ inputs.version }}" >> "$GITHUB_OUTPUT" | ||
- id: resolve_branch | ||
name: "Resolve branch prefix (release or bugfix)" | ||
run: | | ||
if [[ ${{ github.ref_name }} == "main"]]; | ||
then | ||
echo "branch_name=release/${{ inputs.version }}" >> "$GITHUB_OUTPUT" | ||
elif [[ ${{ github.ref }} == refs/tags/* ]] | ||
then | ||
echo "branch_name=bugfix/${{ inputs.version }}" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "Ref branch does not match required criteria. Should either be "main" or a tag." | ||
exit 1 | ||
fi | ||
draft-new-release: | ||
name: "Draft a new release" | ||
runs-on: ubuntu-latest | ||
needs: resolve-branch-prefix | ||
needs: validate-and-prepare | ||
permissions: | ||
contents: write | ||
packages: write | ||
|
@@ -77,7 +79,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Create Release or Bugfix branch | ||
run: git checkout -b ${{ needs.resolve-branch-prefix.outputs.branch_name }} | ||
run: git checkout -b ${{ needs.validate-and-prepare.outputs.branch_name }} | ||
- name: Initialize mandatory git config | ||
run: | | ||
git config user.name "eclipse-tractusx-bot" | ||
|
@@ -112,14 +114,14 @@ jobs: | |
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | ||
- name: Push new branch | ||
run: git push origin ${{ needs.resolve-branch-prefix.outputs.branch_name }} | ||
run: git push origin ${{ needs.validate-and-prepare.outputs.branch_name }} | ||
- name: Create pull request | ||
if: ${{ github.ref_name == 'main' }} | ||
uses: thomaseizinger/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
head: ${{ needs.resolve-branch-prefix.outputs.branch_name }} | ||
head: ${{ needs.validate-and-prepare.outputs.branch_name }} | ||
base: main | ||
title: Release version ${{ inputs.version }} | ||
reviewers: ${{ github.actor }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters