Skip to content

Commit cafab77

Browse files
authored
Release v1.1.0-rc.0 (#24)
2 parents f72d567 + 89b7535 commit cafab77

File tree

4 files changed

+109
-16
lines changed

4 files changed

+109
-16
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: draft_release_hotfix_pr
2+
3+
on:
4+
push:
5+
branches:
6+
- "release/**"
7+
- "hotfix/**"
8+
9+
env:
10+
BRANCH_MAIN: main
11+
BRANCH_DEVELOP: develop
12+
TAG_PREFIX: v
13+
14+
jobs:
15+
create_draft_pr:
16+
name: Create draft PR
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
# only create draft pull requests on pushing to branches 'release/' or 'hotfix/'
21+
if: (startsWith(github.ref_name, 'release/') || startsWith(github.ref_name, 'hotfix/'))
22+
23+
steps:
24+
- name: Set GitHub token
25+
run: |
26+
echo "GH_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV
27+
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
ref: ${{ github.ref_name }}
32+
token: ${{ env.GH_TOKEN }}
33+
# needed by "gh pr create"
34+
fetch-depth: 0
35+
36+
- name: Set environment variables for publishing release
37+
if: startsWith(github.ref_name, 'release/')
38+
run: |
39+
BRANCH_NAME="${{ github.ref_name }}"
40+
VERSION=${BRANCH_NAME#release/}
41+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
42+
echo "RELEASE_TYPE=release" >> $GITHUB_ENV
43+
44+
- name: Set environment variables for publishing hotfix
45+
if: startsWith(github.ref_name, 'hotfix/')
46+
run: |
47+
BRANCH_NAME="${{ github.ref_name }}"
48+
VERSION=${BRANCH_NAME#hotfix/}
49+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
50+
echo "RELEASE_TYPE=hotfix" >> $GITHUB_ENV
51+
52+
- name: Check whether pre-release-version
53+
if: contains(env.RELEASE_VERSION, 'alpha') || contains(env.RELEASE_VERSION, 'beta') || contains(env.RELEASE_VERSION, 'rc')
54+
run: |
55+
echo "PRE_RELEASE=true" >> $GITHUB_ENV
56+
57+
- name: Set PR title
58+
run: |
59+
RELEASE_TYPE=${{ env.RELEASE_TYPE }}
60+
PR_PREFIX=${RELEASE_TYPE^}
61+
PR_TITLE="${PR_PREFIX} ${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}"
62+
echo "PR_TITLE=$PR_TITLE" >> $GITHUB_ENV
63+
64+
- name: Create PR '${{ env.PR_TITLE }}'
65+
env:
66+
PR_BODY: |
67+
This PR was created to prepare for releasing ${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}.
68+
69+
Merging this PR will create the GitHub release ${{ env.TAG_PREFIX }}${{ env.RELEASE_VERSION }}.
70+
run: |
71+
PR_LABELS="automated-pr,${RELEASE_TYPE}-pr"
72+
for LABEL in $(echo $PR_LABELS | sed "s/,/ /g"); do gh label create $LABEL --force; done
73+
[[ ${PRE_RELEASE:false} == "true" ]] && gh label create 'pre-release' --force
74+
75+
PR_ID=$(gh pr list --state open --search "base:${{ env.BRANCH_MAIN }} head:${{ github.ref_name }}" | head -1 | cut -f1)
76+
[[ ! -z "$PR_ID" ]] && \
77+
gh pr create \
78+
--draft \
79+
--base "${{ env.BRANCH_MAIN }}" \
80+
--head "${{ github.ref_name }}" \
81+
--title "${{ env.PR_TITLE }}" \
82+
--body "${{ env.PR_BODY }}" \
83+
--label "${PR_LABELS}" \
84+
--fill \
85+
|| echo "PR was created. Ignored!"

CHANGELOG.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,67 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5-
### [1.0.2](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.2-rc.0...v1.0.2) (2023-02-13)
5+
## [1.1.0-rc.0](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.2...v1.1.0-rc.0) (2023-02-13)
6+
7+
### Features
8+
9+
* **workflow-draft-release-hotfix-pr:** add new workflow for auto creating draft pr on pushing release or hotfix branch ([c539237](https://github.com/ansidev/sample-gitflow-release-workflows/commit/c53923703db4aaa1289092fe76482f98a10e6bea))
610

11+
### Documentations
12+
13+
* **readme:** update README.md ([9175012](https://github.com/ansidev/sample-gitflow-release-workflows/commit/9175012bed48f47fc08e681983ad21f81e8e2f04))
14+
15+
### [1.0.2](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.2-rc.0...v1.0.2) (2023-02-13)
716

817
### Bug Fixes
918

1019
* **github-actions:** fix PR body ([4701d3a](https://github.com/ansidev/sample-gitflow-release-workflows/commit/4701d3a33ea1f9563662ac0ddeb47ceb972e66d6))
1120

1221
### [1.0.2-rc.0](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.7...v1.0.2-rc.0) (2023-02-13)
1322

14-
1523
### Features
1624

1725
* **workflow-release:** auto create merge commit for PR on merging ([bc07fe5](https://github.com/ansidev/sample-gitflow-release-workflows/commit/bc07fe522fc2dbc8ea4171be7404a8870f4dce38))
1826
* **workflow-release:** auto merge PR after creating ([85a272f](https://github.com/ansidev/sample-gitflow-release-workflows/commit/85a272f377da0589b55bbc9420d933237f41ff6e))
1927

20-
2128
### [1.0.1-rc.7](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.6...v1.0.1-rc.7) (2023-02-13)
2229

23-
2430
### Bug Fixes
2531

2632
* **github-actions:** fix failed command gh pr create ([c57d773](https://github.com/ansidev/sample-gitflow-release-workflows/commit/c57d773547c355bbff010a12d602f4abb0cb985d))
2733

2834
### [1.0.1-rc.6](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.5...v1.0.1-rc.6) (2023-02-13)
2935

30-
3136
### Bug Fixes
3237

3338
* **github-actions:** correct command flag value ([95af6a2](https://github.com/ansidev/sample-gitflow-release-workflows/commit/95af6a2f92adb1f3a6709c9225b3028aedbc5987))
3439

3540
### [1.0.1-rc.5](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.4...v1.0.1-rc.5) (2023-02-13)
3641

37-
3842
### Bug Fixes
3943

4044
* **github-actions:** revert wrong changes ([1e044df](https://github.com/ansidev/sample-gitflow-release-workflows/commit/1e044dfd9746afbe7263c484813a8a26920119bf))
4145

4246
### [1.0.1-rc.4](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.3...v1.0.1-rc.4) (2023-02-12)
4347

44-
4548
### Bug Fixes
4649

4750
* **github-actions:** fix fail steps and refactor code ([872d740](https://github.com/ansidev/sample-gitflow-release-workflows/commit/872d740b98dd15adc988079744656814229f37d5))
4851

4952
### [1.0.1-rc.3](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.2...v1.0.1-rc.3) (2023-02-12)
5053

51-
5254
### Bug Fixes
5355

5456
* **github-actions:** remove invalid command flag ([1794f4c](https://github.com/ansidev/sample-gitflow-release-workflows/commit/1794f4cc27e9053e6ddbbccd01d7d0895812d510))
5557

5658
### [1.0.1-rc.2](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.1...v1.0.1-rc.2) (2023-02-12)
5759

58-
5960
### Bug Fixes
6061

6162
* **github-actions:** add missing checkout step ([e20f63a](https://github.com/ansidev/sample-gitflow-release-workflows/commit/e20f63ababd316d413b9573c727c68717b3b480d))
6263

6364
### [1.0.1-rc.1](https://github.com/ansidev/sample-gitflow-release-workflows/compare/v1.0.1-rc.0...v1.0.1-rc.1) (2023-02-12)
6465

65-
6666
### Bug Fixes
6767

6868
* **github-actions:** correct syntax ([dcea1b6](https://github.com/ansidev/sample-gitflow-release-workflows/commit/dcea1b6fde978a05ca3ff8855af26600e7a9f226))

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ Sample Gitflow release workflow using GitHub Actions and official [GitHub CLI](h
77

88
## Features
99

10-
- Auto create and publish a new release on merging changes from `release/**`/`hotfix/**` into `main`.
10+
- Auto create a draft PR on pushing new branch `release/**` or `hotfix/**`.
11+
- Auto add following labels for PR:
12+
- `automated-pr`,
13+
- `release-pr`: if normal release.
14+
- `hotfix-pr`: if hotfix release.
15+
- `pre-release`: if version contains `alpha`, `beta`, `rc`.
16+
- **Note:** You are responsible for preparing release materials: changelog, bump version,... using your favorite tools.
17+
- Auto create and publish a new release on merging changes from `release/**` or `hotfix/**` into `main`.
1118
- Auto create corresponding git tag with the released version.
12-
- Auto create PR and merge changes from `release/**`/`hotfix/**` back into `develop`.
19+
- Auto create PR and merge changes from `release/**` or `hotfix/**` back into `develop`.
1320

1421
## Manual
1522

1623
- Workflows
1724

18-
| Name | Description | File |
19-
| ------- | ------------------ | ------------------------------------------------ |
20-
| Release | Automate releasing | [release.yaml](./.github/workflows/release.yaml) |
25+
| Name | Description | File |
26+
| ----------------------- | ------------------------------ | -------------------------------------------------------------------------------- |
27+
| Release | Automate releasing | [release.yaml](./.github/workflows/release.yaml) |
28+
| Draft Release/Hotfix PR | Automate drafting a release PR | [draft_release_hotfix_pr.yaml](./.github/workflows/draft_release_hotfix_pr.yaml) |
2129

2230
- You have to update below env variables if necessary
2331

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.2
1+
1.1.0-rc.0

0 commit comments

Comments
 (0)