Skip to content

Commit 47489c0

Browse files
committed
chore: onboard repo to AutoVer
1 parent 2931cd6 commit 47489c0

File tree

5 files changed

+325
-0
lines changed

5 files changed

+325
-0
lines changed

.autover/autover.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Aspire.Hosting.AWS",
5+
"Path": "src/Aspire.Hosting.AWS/Aspire.Hosting.AWS.csproj"
6+
}
7+
],
8+
"UseCommitsForChangelog": false,
9+
"UseSameVersionForAllProjects": false,
10+
"DefaultIncrementType": "Patch",
11+
"ChangeFilesDetermineIncrementType": true
12+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Change File Included in PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled]
6+
7+
jobs:
8+
check-files-in-directory:
9+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Release Not Needed') && !contains(github.event.pull_request.labels.*.name, 'Release PR') }}
10+
name: Change File Included in PR
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout PR code
15+
uses: actions/checkout@v3
16+
17+
- name: Get List of Changed Files
18+
id: changed-files
19+
uses: tj-actions/changed-files@4edd678ac3f81e2dc578756871e4d00c19191daf #v45
20+
21+
- name: Check for Change File(s) in .autover/changes/
22+
run: |
23+
DIRECTORY=".autover/changes/"
24+
if echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -q "$DIRECTORY"; then
25+
echo "✅ One or more change files in '$DIRECTORY' are included in this PR."
26+
else
27+
echo "❌ No change files in '$DIRECTORY' are included in this PR."
28+
echo "Refer to the 'Adding a change file to your contribution branch' section of https://github.com/aws/integrations-on-dotnet-aspire-for-aws/blob/main/CONTRIBUTING.md"
29+
exit 1
30+
fi
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 .NET9 which is needed for AutoVer
46+
- name: Setup .NET 9.0
47+
uses: actions/setup-dotnet@v4
48+
with:
49+
dotnet-version: 9.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"

.github/workflows/sync-main-dev.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# This GitHub Workflow is designed to run automatically after the Release PR, which was created by the `Create Release PR` workflow, is closed.
2+
# This workflow has 2 jobs. One will run if the `Release PR` is successfully merged, indicating that a release should go out.
3+
# The other will run if the `Release PR` was closed and a release is not intended to go out.
4+
name: Sync 'dev' and 'main'
5+
6+
# The workflow will automatically be triggered when any PR is closed.
7+
on:
8+
pull_request:
9+
types: [closed]
10+
11+
permissions:
12+
contents: write
13+
id-token: write
14+
15+
jobs:
16+
# This job will check if the PR was successfully merged, it's source branch is `releases/next-release` and target branch is `dev`.
17+
# This indicates that the merged PR was the `Release PR`.
18+
# This job will synchronize `dev` and `main`, create a GitHub Release and delete the `releases/next-release` branch.
19+
sync-dev-and-main:
20+
name: Sync dev and main
21+
if: |
22+
github.event.pull_request.merged == true &&
23+
github.event.pull_request.head.ref == 'releases/next-release' &&
24+
github.event.pull_request.base.ref == 'dev'
25+
runs-on: ubuntu-latest
26+
steps:
27+
# Assume an AWS Role that provides access to the Access Token
28+
- name: Configure AWS Credentials
29+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 #v4
30+
with:
31+
role-to-assume: ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_ROLE_ARN }}
32+
aws-region: us-west-2
33+
# Retrieve the Access Token from Secrets Manager
34+
- name: Retrieve secret from AWS Secrets Manager
35+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
36+
with:
37+
secret-ids: |
38+
AWS_SECRET, ${{ secrets.RELEASE_WORKFLOW_ACCESS_TOKEN_NAME }}
39+
parse-json-secrets: true
40+
# Checkout a full clone of the repo
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
with:
44+
ref: dev
45+
fetch-depth: 0
46+
token: ${{ env.AWS_SECRET_TOKEN }}
47+
# Install .NET8 which is needed for AutoVer
48+
- name: Setup .NET 9.0
49+
uses: actions/setup-dotnet@v4
50+
with:
51+
dotnet-version: 9.0.x
52+
# Install AutoVer which is needed to retrieve information about the current release.
53+
- name: Install AutoVer
54+
run: dotnet tool install --global AutoVer --version 0.0.24
55+
# Set up a git user to be able to run git commands later on
56+
- name: Setup Git User
57+
run: |
58+
git config --global user.email "[email protected]"
59+
git config --global user.name "aws-sdk-dotnet-automation"
60+
# Retrieve the release name which is needed for the GitHub Release
61+
- name: Read Release Name
62+
id: read-release-name
63+
run: |
64+
version=$(autover changelog --release-name)
65+
echo "VERSION=$version" >> $GITHUB_OUTPUT
66+
# Retrieve the tag name which is needed for the GitHub Release
67+
- name: Read Tag Name
68+
id: read-tag-name
69+
run: |
70+
tag=$(autover changelog --tag-name)
71+
echo "TAG=$tag" >> $GITHUB_OUTPUT
72+
# Retrieve the changelog which is needed for the GitHub Release
73+
- name: Read Changelog
74+
id: read-changelog
75+
run: |
76+
changelog=$(autover changelog --output-to-console)
77+
echo "CHANGELOG<<EOF"$'\n'"$changelog"$'\n'EOF >> "$GITHUB_OUTPUT"
78+
# Merge dev into main in order to synchronize the 2 branches
79+
- name: Merge dev to main
80+
run: |
81+
git fetch origin
82+
git checkout main
83+
git merge dev
84+
git push origin main
85+
# Create the GitHub Release
86+
- name: Create GitHub Release
87+
env:
88+
GITHUB_TOKEN: ${{ env.AWS_SECRET_TOKEN }}
89+
run: |
90+
gh release create "${{ steps.read-tag-name.outputs.TAG }}" --title "${{ steps.read-release-name.outputs.VERSION }}" --notes "${{ steps.read-changelog.outputs.CHANGELOG }}"
91+
# Delete the `releases/next-release` branch
92+
- name: Clean up
93+
run: |
94+
git fetch origin
95+
git push origin --delete releases/next-release
96+
# This job will check if the PR was closed, it's source branch is `releases/next-release` and target branch is `dev`.
97+
# This indicates that the closed PR was the `Release PR`.
98+
# This job will delete the tag created by AutoVer and the release branch.
99+
clean-up-closed-release:
100+
name: Clean up closed release
101+
if: |
102+
github.event.pull_request.merged == false &&
103+
github.event.pull_request.head.ref == 'releases/next-release' &&
104+
github.event.pull_request.base.ref == 'dev'
105+
runs-on: ubuntu-latest
106+
steps:
107+
# Checkout a full clone of the repo
108+
- name: Checkout code
109+
uses: actions/checkout@v4
110+
with:
111+
ref: releases/next-release
112+
fetch-depth: 0
113+
# Install .NET8 which is needed for AutoVer
114+
- name: Setup .NET 9.0
115+
uses: actions/setup-dotnet@v4
116+
with:
117+
dotnet-version: 9.0.x
118+
# Install AutoVer which is needed to retrieve information about the current release.
119+
- name: Install AutoVer
120+
run: dotnet tool install --global AutoVer --version 0.0.24
121+
# Set up a git user to be able to run git commands later on
122+
- name: Setup Git User
123+
run: |
124+
git config --global user.email "[email protected]"
125+
git config --global user.name "aws-sdk-dotnet-automation"
126+
# Retrieve the tag name to be deleted
127+
- name: Read Tag Name
128+
id: read-tag-name
129+
run: |
130+
tag=$(autover changelog --tag-name)
131+
echo "TAG=$tag" >> $GITHUB_OUTPUT
132+
# Delete the tag created by AutoVer and the release branch
133+
- name: Clean up
134+
run: |
135+
git fetch origin
136+
git push --delete origin ${{ steps.read-tag-name.outputs.TAG }}
137+
git push origin --delete releases/next-release

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,51 @@ GitHub provides additional document on [forking a repository](https://help.githu
4040
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
4141

4242

43+
## Adding a `change file` to your contribution branch
44+
45+
Each contribution branch should include a `change file` that contains a changelog message for each project that has been updated, as well as the type of increment to perform for those changes when versioning the project.
46+
47+
A `change file` looks like the following example:
48+
```json
49+
{
50+
"Projects": [
51+
{
52+
"Name": "Aspire.Hosting.AWS",
53+
"Type": "Patch",
54+
"ChangelogMessages": [
55+
"Fixed an issue causing a failure somewhere"
56+
]
57+
}
58+
]
59+
}
60+
```
61+
The `change file` lists all the modified projects, the changelog message for each project as well as the increment type.
62+
63+
These files are located in the repo at .autover/changes/
64+
65+
You can use the `AutoVer` tool to create the change file. You can install it using the following command:
66+
```
67+
dotnet tool install -g AutoVer
68+
```
69+
70+
You can create the `change file` using the following command:
71+
```
72+
autover change --project-name "Aspire.Hosting.AWS" -m "Fixed an issue causing a failure somewhere
73+
```
74+
Note: Make sure to run the command from the root of the repository.
75+
76+
You can update the command to specify which project you are updating.
77+
The available projects are:
78+
* Aspire.Hosting.AWS
79+
80+
The possible increment types are:
81+
* Patch
82+
* Minor
83+
* Major
84+
85+
Note: You do not need to create a new `change file` for every changelog message or project within your branch. You can create one `change file` that contains all the modified projects and the changelog messages.
86+
87+
4388
## Finding contributions to work on
4489
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
4590

0 commit comments

Comments
 (0)