-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (79 loc) · 3.92 KB
/
release-cut.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
## This Action creates a `release-*` branch off of the `main` branch
## - The new `release-*` branch will match the next semantic version (based on git tags)
name: "Release-Cut"
# Workflow runs when manually triggered using the UI or API
on: workflow_dispatch
# This Workflow should cut a `release-*` branch from `develop` and create a PR into `main`
jobs:
cut-release:
runs-on: ubuntu-latest
# TODO: Should we create step that sets "variables" for action (main branch, release commit user)
steps:
- uses: actions/[email protected]
with:
## This is a Personal Access Token from Admin User that allows us to bypass branch protections on develop
token: ${{ secrets.PAT }}
fetch-depth: 0
# NOTE: Update CHANGELOG_PREFIX_LIST to configure the lines you wan to include in the changelog (body of release PR)
- name: "Get Release Info"
id: version
run: |
git fetch --all --tags;
git checkout main;
git checkout develop;
cd scripts/release;
unzip git-mkver-linux.zip;
cd ../..;
echo "##[set-output name=major;]$(./scripts/release/git-mkver-linux next --format '{Major}')";
echo "##[set-output name=minor;]$(./scripts/release/git-mkver-linux next --format '{Minor}')";
echo "##[set-output name=patch;]$(./scripts/release/git-mkver-linux next --format '{Patch}')";
CHANGELOG=$(git log --format=%s main..HEAD | grep -i -E "^($CHANGELOG_PREFIX_LIST)" | sed "s/^/ - /")
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo "##[set-output name=changelog;]$(echo $CHANGELOG)";
env:
CHANGELOG_PREFIX_LIST: "feature|feat|fix|bugfix|bug"
# Attempts to cut a release branch
# fails if there are no `feat|feature` commits since last release
- name: "Cut Release Branch"
run: |
./scripts/release/release-cut-check.sh
git config --global user.name 'Release Cut'
git config --global user.email '[email protected]'
git checkout -b $RELEASE_BRANCH;
./scripts/release/update-versions.sh $RELEASE_VERSION;
git commit -a -m "update version for $RELEASE_BRANCH";
git push --set-upstream origin $RELEASE_BRANCH;
env:
RELEASE_BRANCH: release-${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}
RELEASE_VERSION: ${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}
# Note: see https://github.com/repo-sync/pull-request#advanced-options for all options
- name: Create Pull Request
uses: repo-sync/[email protected]
with:
github_token: ${{ secrets.PAT }}
source_branch: release-${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}
destination_branch: "main"
pr_title: release-${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}
pr_body: ${{ steps.version.outputs.changelog }}
pr_label: "- release -"
# Note: This increments minor version only, for now major releases will be done manually
# until we figure out a better method
- name: "Generate Next Version Number"
id: next_version
run: |
echo "##[set-output name=minor;]$(($MINOR_VERSION+1))"
env:
MINOR_VERSION: ${{ steps.version.outputs.minor }}
- name: "Update File Versions" # in repo
run: |
git config --global user.name 'Release Cut'
git config --global user.email '[email protected]'
git checkout develop;
./scripts/release/update-versions.sh $NEXT_VERSION;
git commit -a -m "update version after $RELEASE_BRANCH";
git push;
env:
NEXT_VERSION: ${{ steps.version.outputs.major }}.${{ steps.next_version.outputs.minor }}-SNAPSHOT
RELEASE_BRANCH: release-${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}