Skip to content

Commit 1a71c5d

Browse files
authored
feat: release workflow (#89)
1 parent 5c40268 commit 1a71c5d

File tree

3 files changed

+91
-3
lines changed

3 files changed

+91
-3
lines changed

.github/workflows/run-release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version-override:
7+
type: string
8+
required: false
9+
description: 'Optionally specify a custom release version (minor version bump e.g.)'
10+
kn-release:
11+
type: boolean
12+
required: false
13+
default: false
14+
description: 'Whether the release is a KN variant of repo tools or not'
15+
16+
permissions:
17+
id-token: write
18+
contents: write
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout source
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
fetch-tags: true
29+
30+
- name: Resolve new version
31+
id: resolve-new-version
32+
run: |
33+
if [ -n "${{ inputs.version-override }}" ]; then
34+
echo "NEW_VERSION=${{ inputs.version-override }}" >> "$GITHUB_OUTPUT"
35+
exit 0
36+
fi
37+
38+
if [ "${{ inputs.kn-release }}" == "true" ]; then
39+
CURRENT_VERSION=$(git tag --sort=-creatordate | grep -- '-kn$' | head -n 1)
40+
else
41+
CURRENT_VERSION=$(git tag --sort=-creatordate | grep -v -- '-kn$' | head -n 1)
42+
fi
43+
44+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
45+
PATCH_NUMBER=${PATCH%%[^0-9]*}
46+
PATCH_SUFFIX=${PATCH#$PATCH_NUMBER}
47+
((PATCH_NUMBER++))
48+
echo "NEW_VERSION=$MAJOR.$MINOR.$PATCH_NUMBER$PATCH_SUFFIX" >> "$GITHUB_OUTPUT"
49+
50+
- name: Create new version tag
51+
env:
52+
NEW_VERSION: ${{ steps.resolve-new-version.outputs.NEW_VERSION }}
53+
run: |
54+
git config user.name aws-sdk-kotlin-ci
55+
git config user.email "[email protected]"
56+
git tag "$NEW_VERSION"
57+
git push origin "$NEW_VERSION"
58+
59+
- name: Configure AWS credentials
60+
uses: aws-actions/configure-aws-credentials@v4
61+
with:
62+
role-to-assume: ${{ secrets.PUBLISHING_ROLE_ARN }}
63+
aws-region: us-west-2
64+
65+
- name: Run codebuild release job
66+
uses: aws-actions/aws-codebuild-run-build@v1
67+
with:
68+
project-name: publish-aws-kotlin-repo-tools
69+
source-version-override: ${{ steps.resolve-new-version.outputs.NEW_VERSION }}
70+
71+
- name: Delete failed release tag
72+
if: ${{ failure() }}
73+
run: |
74+
git push --delete origin ${{ steps.resolve-new-version.outputs.NEW_VERSION }}

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,27 @@ version that is being released.
2020

2121
To cut a new release:
2222

23+
1. Go to this repo's GitHub actions.
24+
2. Locate the release workflow.
25+
3. Specify whether the release will be of a kn variant (used for Kotlin Native development).
26+
4. If you're doing a minor or major version bump, specify the version override (including "-kn" if a kn variant).
27+
5. Run the workflow.
28+
29+
The workflow will create a tag, push it to this repo and then start a
30+
CodeBuild release job hosted in the shared tools account (e.g. `publish-aws-kotlin-repo-tools`).
31+
32+
<details>
33+
<summary>Old manual release instructions</summary>
34+
2335
1. Create a new tag, e.g. `git tag x.y.z`.
2436
2. Push the tag up `git push origin x.y.z`.
2537
3. Go to the CodeBuild release job hosted in the shared tools account (e.g. `publish-aws-kotlin-repo-tools`).
2638
4. Start a build with overrides.
2739
5. Under `Source` connect your GitHub account (Under `Source` -> `Connection Status` you should see "You are connected to GitHub").
28-
7. Specify the tag you created under `Source Version`.
29-
8. Start the build.
40+
6. Specify the tag you created under `Source Version`.
41+
7. Start the build.
42+
43+
</details>
3044

3145
## Development
3246

scripts/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export AWS_SECRET_ACCESS_KEY=$(echo "${SESSION_CREDS}" | jq -r '.Credentials.Sec
2020
export AWS_SESSION_TOKEN=$(echo "${SESSION_CREDS}" | jq -r '.Credentials.SessionToken')
2121
export RELEASE_S3_URL="s3://$RELEASE_BUCKET/releases"
2222

23-
TEST_KEY="releases/aws/sdk/kotlin/build-plugins/$VERSION/build-plugins-$VERSION.jar"
23+
TEST_KEY="releases/aws/sdk/kotlin/gradle/build-support/$VERSION/build-support-$VERSION.jar"
2424

2525
if aws s3api head-object --bucket $RELEASE_BUCKET --key $TEST_KEY; then
2626
echo "failing release; $VERSION already exists!"

0 commit comments

Comments
 (0)