Skip to content

Commit

Permalink
ci: create release PRs using autover
Browse files Browse the repository at this point in the history
  • Loading branch information
philasmar committed Oct 25, 2024
1 parent 054e94d commit 82b8885
Show file tree
Hide file tree
Showing 36 changed files with 1,997 additions and 1,521 deletions.
136 changes: 136 additions & 0 deletions .autover/autover.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"Projects": [
{
"Name": "Amazon.Lambda.Annotations",
"Paths": [
"Libraries/src/Amazon.Lambda.Annotations/Amazon.Lambda.Annotations.csproj",
"Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Amazon.Lambda.Annotations.SourceGenerator.csproj"
]
},
{
"Name": "Amazon.Lambda.APIGatewayEvents",
"Path": "Libraries/src/Amazon.Lambda.APIGatewayEvents/Amazon.Lambda.APIGatewayEvents.csproj"
},
{
"Name": "Amazon.Lambda.ApplicationLoadBalancerEvents",
"Path": "Libraries/src/Amazon.Lambda.ApplicationLoadBalancerEvents/Amazon.Lambda.ApplicationLoadBalancerEvents.csproj"
},
{
"Name": "Amazon.Lambda.AspNetCoreServer",
"Path": "Libraries/src/Amazon.Lambda.AspNetCoreServer/Amazon.Lambda.AspNetCoreServer.csproj"
},
{
"Name": "Amazon.Lambda.AspNetCoreServer.Hosting",
"Path": "Libraries/src/Amazon.Lambda.AspNetCoreServer.Hosting/Amazon.Lambda.AspNetCoreServer.Hosting.csproj"
},
{
"Name": "Amazon.Lambda.CloudWatchEvents",
"Path": "Libraries/src/Amazon.Lambda.CloudWatchEvents/Amazon.Lambda.CloudWatchEvents.csproj"
},
{
"Name": "Amazon.Lambda.CloudWatchLogsEvents",
"Path": "Libraries/src/Amazon.Lambda.CloudWatchLogsEvents/Amazon.Lambda.CloudWatchLogsEvents.csproj"
},
{
"Name": "Amazon.Lambda.CognitoEvents",
"Path": "Libraries/src/Amazon.Lambda.CognitoEvents/Amazon.Lambda.CognitoEvents.csproj"
},
{
"Name": "Amazon.Lambda.ConfigEvents",
"Path": "Libraries/src/Amazon.Lambda.ConfigEvents/Amazon.Lambda.ConfigEvents.csproj"
},
{
"Name": "Amazon.Lambda.ConnectEvents",
"Path": "Libraries/src/Amazon.Lambda.ConnectEvents/Amazon.Lambda.ConnectEvents.csproj"
},
{
"Name": "Amazon.Lambda.Core",
"Path": "Libraries/src/Amazon.Lambda.Core/Amazon.Lambda.Core.csproj"
},
{
"Name": "Amazon.Lambda.DynamoDBEvents",
"Path": "Libraries/src/Amazon.Lambda.DynamoDBEvents/Amazon.Lambda.DynamoDBEvents.csproj"
},
{
"Name": "Amazon.Lambda.KafkaEvents",
"Path": "Libraries/src/Amazon.Lambda.KafkaEvents/Amazon.Lambda.KafkaEvents.csproj"
},
{
"Name": "Amazon.Lambda.KinesisAnalyticsEvents",
"Path": "Libraries/src/Amazon.Lambda.KinesisAnalyticsEvents/Amazon.Lambda.KinesisAnalyticsEvents.csproj"
},
{
"Name": "Amazon.Lambda.KinesisEvents",
"Path": "Libraries/src/Amazon.Lambda.KinesisEvents/Amazon.Lambda.KinesisEvents.csproj"
},
{
"Name": "Amazon.Lambda.KinesisFirehoseEvents",
"Path": "Libraries/src/Amazon.Lambda.KinesisFirehoseEvents/Amazon.Lambda.KinesisFirehoseEvents.csproj"
},
{
"Name": "Amazon.Lambda.LexEvents",
"Path": "Libraries/src/Amazon.Lambda.LexEvents/Amazon.Lambda.LexEvents.csproj"
},
{
"Name": "Amazon.Lambda.LexV2Events",
"Path": "Libraries/src/Amazon.Lambda.LexV2Events/Amazon.Lambda.LexV2Events.csproj"
},
{
"Name": "Amazon.Lambda.Logging.AspNetCore",
"Path": "Libraries/src/Amazon.Lambda.Logging.AspNetCore/Amazon.Lambda.Logging.AspNetCore.csproj"
},
{
"Name": "Amazon.Lambda.MQEvents",
"Path": "Libraries/src/Amazon.Lambda.MQEvents/Amazon.Lambda.MQEvents.csproj"
},
{
"Name": "Amazon.Lambda.PowerShellHost",
"Path": "Libraries/src/Amazon.Lambda.PowerShellHost/Amazon.Lambda.PowerShellHost.csproj"
},
{
"Name": "Amazon.Lambda.RuntimeSupport",
"Path": "Libraries/src/Amazon.Lambda.RuntimeSupport/Amazon.Lambda.RuntimeSupport.csproj"
},
{
"Name": "Amazon.Lambda.S3Events",
"Path": "Libraries/src/Amazon.Lambda.S3Events/Amazon.Lambda.S3Events.csproj"
},
{
"Name": "Amazon.Lambda.Serialization.Json",
"Path": "Libraries/src/Amazon.Lambda.Serialization.Json/Amazon.Lambda.Serialization.Json.csproj"
},
{
"Name": "Amazon.Lambda.Serialization.SystemTextJson",
"Path": "Libraries/src/Amazon.Lambda.Serialization.SystemTextJson/Amazon.Lambda.Serialization.SystemTextJson.csproj"
},
{
"Name": "Amazon.Lambda.SimpleEmailEvents",
"Path": "Libraries/src/Amazon.Lambda.SimpleEmailEvents/Amazon.Lambda.SimpleEmailEvents.csproj"
},
{
"Name": "Amazon.Lambda.SNSEvents",
"Path": "Libraries/src/Amazon.Lambda.SNSEvents/Amazon.Lambda.SNSEvents.csproj"
},
{
"Name": "Amazon.Lambda.SQSEvents",
"Path": "Libraries/src/Amazon.Lambda.SQSEvents/Amazon.Lambda.SQSEvents.csproj"
},
{
"Name": "Amazon.Lambda.TestUtilities",
"Path": "Libraries/src/Amazon.Lambda.TestUtilities/Amazon.Lambda.TestUtilities.csproj"
},
{
"Name": "Amazon.Lambda.TestTool.BlazorTester",
"Paths": [
"Tools/LambdaTestTool/src/Amazon.Lambda.TestTool.BlazorTester/Amazon.Lambda.TestTool.BlazorTester.csproj",
"Tools/LambdaTestTool/src/Amazon.Lambda.TestTool.BlazorTester/Amazon.Lambda.TestTool.BlazorTester60-pack.csproj",
"Tools/LambdaTestTool/src/Amazon.Lambda.TestTool.BlazorTester/Amazon.Lambda.TestTool.BlazorTester70-pack.csproj",
"Tools/LambdaTestTool/src/Amazon.Lambda.TestTool.BlazorTester/Amazon.Lambda.TestTool.BlazorTester80-pack.csproj"
]
}
],
"UseCommitsForChangelog": false,
"UseSameVersionForAllProjects": false,
"DefaultIncrementType": "Patch",
"ChangeFilesDetermineIncrementType": true
}
107 changes: 107 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This GitHub Workflow will create a new release branch that contains the updated C# project versions and changelog.
# The workflow will also create a PR that targets `dev` from the release branch.
name: Create Release PR

# This workflow is manually triggered when in preparation for a release. The workflow should be dispatched from the `dev` branch.
on:
workflow_dispatch:
inputs:
OVERRIDE_VERSION:
description: "Override Version"
type: string
required: false

permissions:
id-token: write

jobs:
release-pr:
name: Release PR
runs-on: ubuntu-latest

env:
INPUT_OVERRIDE_VERSION: ${{ github.event.inputs.OVERRIDE_VERSION }}

steps:
# Assume an AWS Role that provides access to the Access Token
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4
with:
role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }}
aws-region: us-west-2
# Retrieve the Access Token from Secrets Manager
- name: Retrieve secret from AWS Secrets Manager
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }}
parse-json-secrets: true
# Checkout a full clone of the repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
token: ${{ env.AWS_SECRET_TOKEN }}
# Install .NET8 which is needed for AutoVer
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# Install AutoVer to automate versioning and changelog creation
- name: Install AutoVer
run: dotnet tool install --global AutoVer --version 0.0.24
# Set up a git user to be able to run git commands later on
- name: Setup Git User
run: |
git config --global user.email "[email protected]"
git config --global user.name "aws-sdk-dotnet-automation"
# Create the release branch which will contain the version changes and updated changelog
- name: Create Release Branch
id: create-release-branch
run: |
branch=releases/next-release
git checkout -b $branch
echo "BRANCH=$branch" >> $GITHUB_OUTPUT
# Update the version of projects based on the change files
- name: Increment Version
run: autover version
if: env.INPUT_OVERRIDE_VERSION == ''
# Update the version of projects based on the override version
- name: Increment Version
run: autover version --use-version "$INPUT_OVERRIDE_VERSION"
if: env.INPUT_OVERRIDE_VERSION != ''
# Build the solution for the Source Generator to update the CloudFormation templates
- name: Commit Template Changes
run: |
dotnet build Libraries/Libraries.sln -c Release
git add "*.template"
git commit -m "Update test app CloudFormation templates"
# Update the changelog based on the change files
- name: Update Changelog
run: autover changelog
# Push the release branch up as well as the created tag
- name: Push Changes
run: |
branch=${{ steps.create-release-branch.outputs.BRANCH }}
git push origin $branch
git push origin $branch --tags
# Get the release name that will be used to create a PR
- name: Read Release Name
id: read-release-name
run: |
version=$(autover changelog --release-name)
echo "VERSION=$version" >> $GITHUB_OUTPUT
# Get the changelog that will be used to create a PR
- name: Read Changelog
id: read-changelog
run: |
changelog=$(autover changelog --output-to-console)
echo "CHANGELOG<<EOF"$'\n'"$changelog"$'\n'EOF >> "$GITHUB_OUTPUT"
# Create the Release PR and label it
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }}
run: |
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 }})"
gh label create "Release PR" --description "A Release PR that includes versioning and changelog changes" -c "#FF0000" -f
gh pr edit $pr_url --add-label "Release PR"
Loading

0 comments on commit 82b8885

Please sign in to comment.