forked from flutter/devtools
-
Notifications
You must be signed in to change notification settings - Fork 2
133 lines (113 loc) · 4.42 KB
/
daily-dev-bump.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Bump Dev Version
on:
workflow_dispatch: # Allows for manual triggering if needed
inputs:
updateType:
description: "Update Type"
required: true
default: "dev"
type: choice
options:
- dev
- patch+dev
- minor+dev
- major+dev
draft:
description: "PR as Draft"
required: false
type: boolean
default: false
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 8 * * *" # Run every day at midnight Pacific Time
permissions:
contents: write
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
flutter-prep:
uses: ./.github/workflows/flutter-prep.yaml
bump-version:
needs: flutter-prep
if: ${{ github.repository == 'flutter/devtools' }}
name: Bump Version
runs-on: ubuntu-latest
steps:
- name: git clone devtools
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac
with:
ref: master
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
- name: Load Cached Flutter SDK
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
with:
path: |
./tool/flutter-sdk
key: flutter-sdk-${{ runner.os }}-${{ needs.flutter-prep.outputs.latest_flutter_candidate }}
- name: setup git config
run: |
git config user.name "DevTools Workflow Bot"
git config user.email "[email protected]"
- name: Bump the Version
id: version-bump
run: |
set -ex
pushd tool/
dart pub get
popd
# Ensure the devtools_tool command is available
export PATH="$PATH":`pwd`/tool/bin
ORIGINAL_VERSION=$(devtools_tool update-version current-version | tail -1)
if [ -z "$UPDATE_TYPE" ]; then
# If $UPDATE_TYPE is not set, then assume it is dev
UPDATE_TYPE="dev"
fi
# If there is a major, minor, or patch bump, do it.
if [ "$UPDATE_TYPE" == "patch+dev" ]; then
devtools_tool update-version auto --type patch
devtools_tool update-version auto --type dev
elif [ "$UPDATE_TYPE" == "minor+dev" ]; then
devtools_tool update-version auto --type minor
devtools_tool update-version auto --type dev
elif [ "$UPDATE_TYPE" == "major+dev" ]; then
devtools_tool update-version auto --type major
devtools_tool update-version auto --type dev
elif [ "$UPDATE_TYPE" == "dev" ]; then
if ! echo "$ORIGINAL_VERSION" | grep -Eq "\-dev\.[0-9]+" ; then
ERROR_DESCRIPTION="Doing \
a Dev bump on a release version ($ORIGINAL_VERSION) is not supported. \
Ensure that that current version has been properly bumped to a '-dev.*' \
pre-release version, in order to continue daily dev bumps."
echo "::error ,title=Cannot do a dev bump on a Release Version ($ORIGINAL_VERSION)::$ERROR_DESCRIPTION"
exit 1;
fi
devtools_tool update-version auto --type dev
else
echo "ERROR: UNEXPECTED UPDATE TYPE: $UPDATE_TYPE"
exit 1
fi
NEW_VERSION=$(devtools_tool update-version current-version | tail -1)
echo "COMMIT_MESSAGE=Updating from $ORIGINAL_VERSION to $NEW_VERSION" >> $GITHUB_OUTPUT
env:
UPDATE_TYPE: ${{ inputs.updateType }}
- name: Create the PR
run: |
set -ex
BRANCH_NAME="auto-bump-$(date +%s)"
# Stage the file, commit and push
git checkout -b "$BRANCH_NAME"
git commit -a -m "$COMMIT_MESSAGE"
git push -u origin "$BRANCH_NAME"
if [ "$IS_DRAFT" == "true" ]; then
CREATION_FLAGS="--draft"
fi
PR_URL=$(gh pr create --title "$COMMIT_MESSAGE" --body "Automated Version Bump" $CREATION_FLAGS)
# Change github credentials back to the actions bot.
GH_TOKEN="$ORIGINAL_GH_TOKEN"
gh pr edit $PR_URL $FLAGS --add-label "autosubmit"
env:
COMMIT_MESSAGE: ${{ steps.version-bump.outputs.COMMIT_MESSAGE }}
GH_TOKEN: ${{ secrets.DEVTOOLS_WORKFLOW_BOT_TOKEN }}
ORIGINAL_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IS_DRAFT: ${{ inputs.draft == true }}