Skip to content

Commit 5d466da

Browse files
authored
Merge pull request #223 from ansidev/feature/gitflow
Feature: gitflow
2 parents ce017e1 + da7031a commit 5d466da

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: create_release_pr
2+
3+
on:
4+
push:
5+
branches:
6+
- "release/**"
7+
- "hotfix/**"
8+
9+
jobs:
10+
create_release_pr:
11+
name: Create release pull request
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
# only create draft pull requests on
16+
# pushing to branches 'release/' or 'hotfix/'
17+
if: |
18+
startsWith(github.ref_name, 'release/') ||
19+
startsWith(github.ref_name, 'hotfix/')
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.ref_name }}
26+
token: ${{ secrets.GH_TOKEN }}
27+
# needed by "gh pr create"
28+
fetch-depth: 0
29+
30+
- name: Set release type as release
31+
if: startsWith(github.ref_name, 'release/')
32+
run: echo "RELEASE_TYPE=release" >> "$GITHUB_ENV"
33+
34+
- name: Set release type as hotfix
35+
if: startsWith(github.ref_name, 'hotfix/')
36+
run: echo "RELEASE_TYPE=hotfix" >> "$GITHUB_ENV"
37+
38+
- name: Create release pull request
39+
uses: ghacts/gitflow/create-release-pr@main
40+
with:
41+
token: ${{ secrets.GH_TOKEN }}
42+
release-type: ${{ env.RELEASE_TYPE }}
43+
release-branch-prefix: '${{ env.RELEASE_TYPE }}/'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: merge_release_into_develop
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
branches:
8+
- develop
9+
10+
jobs:
11+
merge_release_into_develop:
12+
name: Merge release into develop
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
# only merge pull requests that begin with 'release/' or 'hotfix/'
17+
if: |
18+
startsWith(github.head_ref, 'release/') ||
19+
startsWith(github.head_ref, 'hotfix/')
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.head_ref }}
26+
token: ${{ secrets.GH_TOKEN }}
27+
# needed by "gh pr create"
28+
fetch-depth: 0
29+
30+
- name: Merge ${{ github.head_ref }} into develop
31+
uses: ghacts/gitflow/merge-release-into-develop@main
32+
with:
33+
token: ${{ secrets.GH_TOKEN }}
34+
release-branch: ${{ github.head_ref }}
35+
develop-branch: develop
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: publish_release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
env:
11+
VERSION_TAG_PREFIX: "v"
12+
13+
jobs:
14+
release:
15+
name: Publish release
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
# only merge pull requests that begin with 'release/' or 'hotfix/'
20+
if: github.event.pull_request.merged == true &&
21+
(startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/'))
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.head_ref }}
28+
token: ${{ secrets.GH_TOKEN }}
29+
# needed by "gh pr create"
30+
fetch-depth: 0
31+
32+
- name: Set release type as release
33+
if: startsWith(github.head_ref, 'release/')
34+
run: echo "RELEASE_TYPE=release" >> "$GITHUB_ENV"
35+
36+
- name: Set release type as hotfix
37+
if: startsWith(github.head_ref, 'hotfix/')
38+
run: echo "RELEASE_TYPE=hotfix" >> "$GITHUB_ENV"
39+
40+
- name: Extract version from release branch
41+
env:
42+
BRANCH_NAME: ${{ github.head_ref }}
43+
BRANCH_PREFIX: '${{ env.RELEASE_TYPE }}/'
44+
run: |
45+
RELEASE_VERSION=${BRANCH_NAME#${BRANCH_PREFIX}}
46+
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
47+
48+
- name: Publish release
49+
uses: ghacts/gitflow/publish-release@main
50+
with:
51+
token: ${{ secrets.GH_TOKEN }}
52+
release-type: ${{ env.RELEASE_TYPE }}
53+
release-branch-prefix: '${{ env.RELEASE_TYPE }}/'
54+
notes-file: '.changes/${{ env.VERSION_TAG_PREFIX }}${{ env.RELEASE_VERSION }}.md'

.github/workflows/rebase.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: rebase
2+
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
8+
jobs:
9+
rebase:
10+
name: Rebase
11+
runs-on: ubuntu-latest
12+
if: |
13+
github.event.issue.pull_request &&
14+
(
15+
contains(github.event.comment.body, '/rebase') ||
16+
contains(github.event.comment.body, '/autosquash')
17+
)
18+
steps:
19+
- name: Checkout the latest code
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.GH_TOKEN }}
23+
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
24+
25+
- name: Automatic Rebase
26+
uses: cirrus-actions/rebase@1.8
27+
with:
28+
autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

0 commit comments

Comments
 (0)