Skip to content

Commit

Permalink
ci: use autover for automated versioning and changelog generation
Browse files Browse the repository at this point in the history
  • Loading branch information
philasmar committed Sep 12, 2024
1 parent d0848d1 commit da8b3eb
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 189 deletions.
19 changes: 19 additions & 0 deletions .autover/autover.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Projects": [
{
"Name": "AWS.Deploy.CLI",
"Path": "src/AWS.Deploy.CLI/AWS.Deploy.CLI.csproj"
},
{
"Name": "AWS.Deploy.Recipes.CDK.Common",
"Path": "src/AWS.Deploy.Recipes.CDK.Common/AWS.Deploy.Recipes.CDK.Common.csproj"
},
{
"Name": "AWS.Deploy.ServerMode.Client",
"Path": "src/AWS.Deploy.ServerMode.Client/AWS.Deploy.ServerMode.Client.csproj"
}
],
"UseCommitsForChangelog": false,
"DefaultIncrementType": "Patch",
"ChangeFilesDetermineIncrementType": true
}
22 changes: 0 additions & 22 deletions .chglog/CHANGELOG.tpl.md

This file was deleted.

52 changes: 0 additions & 52 deletions .chglog/config.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: AWS CodeBuild CI
name: AWS CI

on:
# Manually trigger on specific branches
workflow_dispatch:
push:
branches:
- dev
pull_request:
branches:
- main
Expand All @@ -16,7 +13,7 @@ permissions:
id-token: write

jobs:
run-integration-tests:
run-ci:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
Expand All @@ -25,30 +22,22 @@ jobs:
role-to-assume: ${{ secrets.CI_MAIN_TESTING_ACCOUNT_ROLE_ARN }}
role-duration-seconds: 7200
aws-region: us-west-2

- name: Setup .NET Core 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Invoke Load Balancer Lambda
id: lambda
shell: pwsh
run: |
aws lambda invoke response.json --function-name "${{ secrets.CI_TESTING_LOAD_BALANCER_LAMBDA_NAME }}" --cli-binary-format raw-in-base64-out --payload '{"Roles": "${{ secrets.CI_TEST_RUNNER_ACCOUNT_ROLES }}", "ProjectName": "${{ secrets.CI_TESTING_CODE_BUILD_PROJECT_NAME }}", "Branch": "${{ github.sha }}"}'
$roleArn=$(cat ./response.json)
"roleArn=$($roleArn -replace '"', '')" >> $env:GITHUB_OUTPUT
- name: Configure Test Runner Credentials
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4
with:
role-to-assume: ${{ steps.lambda.outputs.roleArn }}
role-duration-seconds: 7200
aws-region: us-west-2

- name: Run CodeBuild
- name: Run Tests on AWS
id: codebuild
uses: aws-actions/aws-codebuild-run-build@v1.0.3
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: ${{ secrets.CI_TESTING_CODE_BUILD_PROJECT_NAME }}
env-vars-for-codebuild: CODECOV_TOKEN
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# 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.21
# 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 != ''
# 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"
79 changes: 0 additions & 79 deletions .github/workflows/prepare-release.yml

This file was deleted.

Loading

0 comments on commit da8b3eb

Please sign in to comment.