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 'master'
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 `master`, create a GitHub Release and delete the `releases/next-release` branch.
19
+ sync-dev-and-main :
20
+ name : Sync dev and master
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 8.0
49
+ uses : actions/setup-dotnet@v4
50
+ with :
51
+ dotnet-version : 8.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.21
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 master in order to synchronize the 2 branches
79
+ - name : Merge dev to master
80
+ run : |
81
+ git fetch origin
82
+ git checkout master
83
+ git merge dev
84
+ git push origin master
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 8.0
115
+ uses : actions/setup-dotnet@v4
116
+ with :
117
+ dotnet-version : 8.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.21
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
0 commit comments