Skip to content

Commit 6da5f67

Browse files
committed
ci: create release PRs using autover
1 parent 2e5f84b commit 6da5f67

File tree

7 files changed

+700
-469
lines changed

7 files changed

+700
-469
lines changed

.autover/autover.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.ECS.Tools",
5+
"Path": "src/Amazon.ECS.Tools/Amazon.ECS.Tools.csproj"
6+
},
7+
{
8+
"Name": "Amazon.ElasticBeanstalk.Tools",
9+
"Path": "src/Amazon.ElasticBeanstalk.Tools/Amazon.ElasticBeanstalk.Tools.csproj"
10+
},
11+
{
12+
"Name": "Amazon.Lambda.Tools",
13+
"Path": "src/Amazon.Lambda.Tools/Amazon.Lambda.Tools.csproj"
14+
}
15+
],
16+
"UseCommitsForChangelog": false,
17+
"UseSameVersionForAllProjects": false,
18+
"DefaultIncrementType": "Patch",
19+
"ChangeFilesDetermineIncrementType": true
20+
}

.github/workflows/aws-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
pull_request:
66
branches:
7-
- main
7+
- master
88
- dev
99
- 'feature/**'
1010

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This GitHub Workflow will create a new release branch that contains the updated C# project versions and changelog.
2+
# The workflow will also create a PR that targets `dev` from the release branch.
3+
name: Create Release PR
4+
5+
# This workflow is manually triggered when in preparation for a release. The workflow should be dispatched from the `dev` branch.
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
OVERRIDE_VERSION:
10+
description: "Override Version"
11+
type: string
12+
required: false
13+
14+
permissions:
15+
id-token: write
16+
17+
jobs:
18+
release-pr:
19+
name: Release PR
20+
runs-on: ubuntu-latest
21+
22+
env:
23+
INPUT_OVERRIDE_VERSION: ${{ github.event.inputs.OVERRIDE_VERSION }}
24+
25+
steps:
26+
# Assume an AWS Role that provides access to the Access Token
27+
- name: Configure AWS Credentials
28+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4
29+
with:
30+
role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }}
31+
aws-region: us-west-2
32+
# Retrieve the Access Token from Secrets Manager
33+
- name: Retrieve secret from AWS Secrets Manager
34+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
35+
with:
36+
secret-ids: |
37+
AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }}
38+
parse-json-secrets: true
39+
# Checkout a full clone of the repo
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
fetch-depth: '0'
44+
token: ${{ env.AWS_SECRET_TOKEN }}
45+
# Install .NET8 which is needed for AutoVer
46+
- name: Setup .NET 8.0
47+
uses: actions/setup-dotnet@v4
48+
with:
49+
dotnet-version: 8.0.x
50+
# Install AutoVer to automate versioning and changelog creation
51+
- name: Install AutoVer
52+
run: dotnet tool install --global AutoVer --version 0.0.24
53+
# Set up a git user to be able to run git commands later on
54+
- name: Setup Git User
55+
run: |
56+
git config --global user.email "[email protected]"
57+
git config --global user.name "aws-sdk-dotnet-automation"
58+
# Create the release branch which will contain the version changes and updated changelog
59+
- name: Create Release Branch
60+
id: create-release-branch
61+
run: |
62+
branch=releases/next-release
63+
git checkout -b $branch
64+
echo "BRANCH=$branch" >> $GITHUB_OUTPUT
65+
# Update the version of projects based on the change files
66+
- name: Increment Version
67+
run: autover version
68+
if: env.INPUT_OVERRIDE_VERSION == ''
69+
# Update the version of projects based on the override version
70+
- name: Increment Version
71+
run: autover version --use-version "$INPUT_OVERRIDE_VERSION"
72+
if: env.INPUT_OVERRIDE_VERSION != ''
73+
# Update the changelog based on the change files
74+
- name: Update Changelog
75+
run: autover changelog
76+
# Push the release branch up as well as the created tag
77+
- name: Push Changes
78+
run: |
79+
branch=${{ steps.create-release-branch.outputs.BRANCH }}
80+
git push origin $branch
81+
git push origin $branch --tags
82+
# Get the release name that will be used to create a PR
83+
- name: Read Release Name
84+
id: read-release-name
85+
run: |
86+
version=$(autover changelog --release-name)
87+
echo "VERSION=$version" >> $GITHUB_OUTPUT
88+
# Get the changelog that will be used to create a PR
89+
- name: Read Changelog
90+
id: read-changelog
91+
run: |
92+
changelog=$(autover changelog --output-to-console)
93+
echo "CHANGELOG<<EOF"$'\n'"$changelog"$'\n'EOF >> "$GITHUB_OUTPUT"
94+
# Create the Release PR and label it
95+
- name: Create Pull Request
96+
env:
97+
GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }}
98+
run: |
99+
pr_url="$(gh pr create --title "${{ steps.read-release-name.outputs.VERSION }}" --body "${{ steps.read-changelog.outputs.CHANGELOG }}" --base dev --head ${{ steps.create-release-branch.outputs.BRANCH }})"
100+
gh label create "Release PR" --description "A Release PR that includes versioning and changelog changes" -c "#FF0000" -f
101+
gh pr edit $pr_url --add-label "Release PR"

0 commit comments

Comments
 (0)