Skip to content

Commit 1547b50

Browse files
committed
1
1 parent 7d57d12 commit 1547b50

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: release-from-branch
2+
on:
3+
push:
4+
branches:
5+
- 'release/*'
6+
7+
# Declare default permissions as read only.
8+
permissions: read-all
9+
10+
jobs:
11+
release:
12+
if: github.repository_owner == 'flutter'
13+
name: release-from-branch
14+
permissions:
15+
# Release needs to push a tag back to the repo.
16+
contents: write
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: "Install Flutter"
20+
# Github Actions don't support templates so it is hard to share this snippet with another action
21+
# If we eventually need to use this in more workflow, we could create a shell script that contains this
22+
# snippet.
23+
#
24+
# This uses a pinned version of Flutter rather than `stable` so that it is
25+
# not subject to out-of-band failures when new releases happen. It does
26+
# not use the auto-rolled pin because there's no way for the autoroller
27+
# to test the actual release flow, so changes would still show up in
28+
# post-submit. A manually-rolled pin means that any changes here must be
29+
# made deliberately, so that the person updating it knows to watch the
30+
# next actual auto-release to ensure that it works, and knows to revert
31+
# the change if it doesn't.
32+
run: |
33+
cd $HOME
34+
git clone https://github.com/flutter/flutter.git --depth 1 -b 3.35.0 _flutter
35+
echo "$HOME/_flutter/bin" >> $GITHUB_PATH
36+
cd $GITHUB_WORKSPACE
37+
# Checks out a copy of the repo.
38+
- name: Check out code
39+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
40+
with:
41+
fetch-depth: 0 # Fetch all history so the tool can get all the tags to determine version.
42+
- name: Set up tools
43+
run: dart pub get
44+
working-directory: ${{ github.workspace }}/script/tool
45+
46+
# Give some time for LUCI checks to start becoming populated.
47+
# Because of latency in Github Webhooks, we need to wait for a while
48+
# before being able to look at checks scheduled by LUCI.
49+
- name: Give webhooks a minute
50+
run: sleep 60s
51+
shell: bash
52+
53+
# The next step waits for all tests, but when there are issues with the
54+
# hooks it can take a long time for the tests to even be registered. If
55+
# "Wait on all tests" runs before that happens, it will pass immediately
56+
# because there doesn't appear to be anything to wait for. To avoid that,
57+
# explicitly wait for one LUCI test by name first.
58+
- name: Wait for test check-in
59+
uses: lewagon/wait-on-check-action@0dceb95e7c4cad8cc7422aee3885998f5cab9c79
60+
with:
61+
ref: ${{ github.sha }}
62+
check-name: 'Linux ci_yaml packages roller'
63+
repo-token: ${{ secrets.GITHUB_TOKEN }}
64+
wait-interval: 30 # seconds
65+
allowed-conclusions: success,neutral
66+
# verbose:true will produce too many logs that hang github actions web UI.
67+
verbose: false
68+
69+
# This workflow should be the last to run. So wait for all the other tests to succeed.
70+
- name: Wait on all tests
71+
uses: lewagon/wait-on-check-action@0dceb95e7c4cad8cc7422aee3885998f5cab9c79
72+
with:
73+
ref: ${{ github.sha }}
74+
running-workflow-name: 'release-from-branch'
75+
repo-token: ${{ secrets.GITHUB_TOKEN }}
76+
wait-interval: 180 # seconds
77+
allowed-conclusions: success,neutral
78+
# verbose:true will produce too many logs that hang github actions web UI.
79+
verbose: false
80+
81+
- name: run release
82+
run: |
83+
git config --global user.name ${{ secrets.USER_NAME }}
84+
git config --global user.email ${{ secrets.USER_EMAIL }}
85+
dart ./script/tool/lib/src/main.dart publish --all-changed --batch-release --base-sha=HEAD~ --skip-confirmation --remote=origin
86+
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}

script/tool/lib/src/publish_command.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class PublishCommand extends PackageLoopingCommand {
9999
static const String _pubFlagsOption = 'pub-publish-flags';
100100
static const String _remoteOption = 'remote';
101101
static const String _allChangedFlag = 'all-changed';
102+
static const String _batchReleaseFlag = 'batch-release';
102103
static const String _dryRunFlag = 'dry-run';
103104
static const String _skipConfirmationFlag = 'skip-confirmation';
104105
static const String _tagForAutoPublishFlag = 'tag-for-auto-publish';
@@ -182,6 +183,16 @@ class PublishCommand extends PackageLoopingCommand {
182183
.toList();
183184

184185
for (final String pubspecPath in changedPubspecs) {
186+
// Read the ci_config.yaml file
187+
final File ciConfigFile = File(pubspecPath).parent.childFile('ci_config.yaml');
188+
final String ciConfigContent = ciConfigFile.readAsStringSync();
189+
final Map<String, dynamic> ciConfig =
190+
yaml.loadYaml(ciConfigContent) as Map<String, dynamic>;
191+
// Skip the package if batch release flag is not set to match the ci_config.yaml
192+
if(getBoolArg(_batchReleaseFlag) != ciConfig['release']['batch'] )
193+
{
194+
continue;
195+
}
185196
// git outputs a relativa, Posix-style path.
186197
final File pubspecFile = childFileWithSubcomponents(
187198
packagesDir.fileSystem.directory((await gitDir).path),

0 commit comments

Comments
 (0)