-
Notifications
You must be signed in to change notification settings - Fork 50
143 lines (136 loc) · 5.54 KB
/
update-release-branch.yml
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
134
135
136
137
138
139
140
141
142
143
name: Update release branch
on:
workflow_dispatch:
inputs:
commit_message:
description: |
The merge commit message to use for non fast-forward merges.
required: false
type: string
dry_run:
description: Dry runs will only attempt to merge but the result will not be pushed to the release branch
required: true
type: boolean
default: false
schedule:
- cron: "0 7 * * 1-5" # At 07:00 UTC (00:00 PST, 03:00 EST), Monday through Friday
permissions:
id-token: write
contents: read
concurrency:
group: release-manual-${{ github.ref }}
cancel-in-progress: true
env:
DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }}
jobs:
update-release:
runs-on: ubuntu-latest
steps:
- name: Set start timestamp
id: start
run: printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
- name: Setup kat
uses: awslabs/aws-kotlin-repo-tools/.github/actions/setup-kat@main
- uses: actions/checkout@v4
with:
ref: 'main'
fetch-depth: 0
token: ${{ secrets.CI_USER_PAT }}
- name: Configure Git
shell: bash
run: |
git config user.name aws-sdk-kotlin-ci
git config user.email "[email protected]"
- name: Configure JDK
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
cache: 'gradle'
- name: Configure Gradle
uses: awslabs/aws-kotlin-repo-tools/.github/actions/configure-gradle@main
- name: Check merge base
shell: bash
run: |
git status
git branch -vv
git fetch
main_sha=$(git rev-parse main)
release_sha=$(git rev-parse origin/release)
echo "main_sha=$main_sha" >> $GITHUB_ENV
echo "release_sha=$release_sha" >> $GITHUB_ENV
if git merge-base --is-ancestor $main_sha $release_sha; then
echo "main@$main_sha already exists in origin/release, nothing to update";
echo "MERGE_NEEDED=false" >> $GITHUB_ENV;
else
echo "MERGE_NEEDED=true" >> $GITHUB_ENV
fi
- name: Release Check - snapshot versions
if: env.MERGE_NEEDED == 'true'
run: |
# We aren't releasable if we (1) directly depend on a snapshot version of a dependency OR (2) can't build the project without unreleased changes
if grep -q -i snapshot ./gradle/libs.versions.toml; then
echo "::error ::found snapshot version in libs.versions.toml"
exit 1
fi
- name: Release Check - build
if: env.MERGE_NEEDED == 'true'
run: |
# Our CI is implemented as a "live at HEAD" model where we build against the latest of all our 1P deps (either
# main branch or matching branch name). Double check that without this "live at HEAD" mode we still build
# successfully (which is how it is built during release).
# This should help prevent the cases where we forgot to bump smithy-kotlin versions and don't catch it
# because CI is masking it
./gradlew -Paws.kotlin.native=false test jvmTest
- name: Release Check - build an SDK client
if: env.MERGED_NEEDED == 'true'
shell: bash
run: |
# Additionally generate and build a service client to confirm that codegen and build works
# without "live at HEAD" mode.
./gradlew -Paws.services=s3 -Paws.kotlin.native=false bootstrap;
./gradlew -Paws.kotlin.native=false build;
- name: Merge
if: env.MERGE_NEEDED == 'true'
shell: bash
run: |
echo "merging main @ $main_sha into release @ $release_sha";
# Getting rid of the Gradle URL config changes caused by "Configure Gradle"
git stash -- gradle/wrapper/gradle-wrapper.properties
git switch release;
input_message=${{ inputs.commit_message }}
message=${input_message:-"Merging main into release"}
echo "message=$message"
git merge -m "$message" main;
if [ "${{ env.DRY_RUN }}" == "true" ]; then
echo "dry run, skipping push to remote";
git log -n 10 --oneline;
else
echo "pushing changes to release branch";
git push origin release;
fi
- name: Calculate duration
id: end
run: |
printf -v now '%(%s)T'
duration=$(( now - ${{ steps.start.outputs.timestamp }} ))
echo "duration=$duration" >> "$GITHUB_OUTPUT"
- name: Emit metrics
if: always() # run this step even if previous steps failed or the job is canceled
uses: awslabs/aws-kotlin-repo-tools/.github/actions/emit-metrics@main
with:
namespace: CI Metrics
dimensions: |
Product=aws-sdk-kotlin
Trigger=${{ github.event_name == 'schedule' && 'schedule' || 'manual' }}
metrics: |
ReleaseMergeAttempted:1:Count
ReleaseMergeSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count
ReleaseMergeCanceled:${{ job.status == 'cancelled' && '1' || '0' }}:Count
ReleaseMergeFailed:${{ job.status == 'failure' && '1' || '0' }}:Count
ReleaseMergeDuration:${{ steps.end.outputs.duration }}:Seconds