diff --git a/.github/workflows/run-release.yml b/.github/workflows/run-release.yml new file mode 100644 index 00000000..ce98ea3f --- /dev/null +++ b/.github/workflows/run-release.yml @@ -0,0 +1,74 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version-override: + type: string + required: false + description: 'Optionally specify a custom release version (minor version bump e.g.)' + kn-release: + type: boolean + required: false + default: false + description: 'Whether the release is a KN variant of repo tools or not' + +permissions: + id-token: write + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Resolve new version + id: resolve-new-version + run: | + if [ -n "${{ inputs.version-override }}" ]; then + echo "NEW_VERSION=${{ inputs.version-override }}" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if [ "${{ inputs.kn-release }}" == "true" ]; then + CURRENT_VERSION=$(git tag --sort=-creatordate | grep -- '-kn$' | head -n 1) + else + CURRENT_VERSION=$(git tag --sort=-creatordate | grep -v -- '-kn$' | head -n 1) + fi + + IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" + PATCH_NUMBER=${PATCH%%[^0-9]*} + PATCH_SUFFIX=${PATCH#$PATCH_NUMBER} + ((PATCH_NUMBER++)) + echo "NEW_VERSION=$MAJOR.$MINOR.$PATCH_NUMBER$PATCH_SUFFIX" >> "$GITHUB_OUTPUT" + + - name: Create new version tag + env: + NEW_VERSION: ${{ steps.resolve-new-version.outputs.NEW_VERSION }} + run: | + git config user.name aws-sdk-kotlin-ci + git config user.email "aws-kotlin-sdk-automation@amazon.com" + git tag "$NEW_VERSION" + git push origin "$NEW_VERSION" + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.PUBLISHING_ROLE_ARN }} + aws-region: us-west-2 + + - name: Run codebuild release job + uses: aws-actions/aws-codebuild-run-build@v1 + with: + project-name: publish-aws-kotlin-repo-tools + source-version-override: ${{ steps.resolve-new-version.outputs.NEW_VERSION }} + + - name: Delete failed release tag + if: ${{ failure() }} + run: | + git push --delete origin ${{ steps.resolve-new-version.outputs.NEW_VERSION }} diff --git a/README.md b/README.md index 41cae101..f74fbd26 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,27 @@ version that is being released. To cut a new release: +1. Go to this repo's GitHub actions. +2. Locate the release workflow. +3. Specify whether the release will be of a kn variant (used for Kotlin Native development). +4. If you're doing a minor or major version bump, specify the version override (including "-kn" if a kn variant). +5. Run the workflow. + +The workflow will create a tag, push it to this repo and then start a +CodeBuild release job hosted in the shared tools account (e.g. `publish-aws-kotlin-repo-tools`). + +
+Old manual release instructions + 1. Create a new tag, e.g. `git tag x.y.z`. 2. Push the tag up `git push origin x.y.z`. 3. Go to the CodeBuild release job hosted in the shared tools account (e.g. `publish-aws-kotlin-repo-tools`). 4. Start a build with overrides. 5. Under `Source` connect your GitHub account (Under `Source` -> `Connection Status` you should see "You are connected to GitHub"). -7. Specify the tag you created under `Source Version`. -8. Start the build. +6. Specify the tag you created under `Source Version`. +7. Start the build. + +
## Development diff --git a/scripts/release.sh b/scripts/release.sh index 43fabe08..ed271b43 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -20,7 +20,7 @@ export AWS_SECRET_ACCESS_KEY=$(echo "${SESSION_CREDS}" | jq -r '.Credentials.Sec export AWS_SESSION_TOKEN=$(echo "${SESSION_CREDS}" | jq -r '.Credentials.SessionToken') export RELEASE_S3_URL="s3://$RELEASE_BUCKET/releases" -TEST_KEY="releases/aws/sdk/kotlin/build-plugins/$VERSION/build-plugins-$VERSION.jar" +TEST_KEY="releases/aws/sdk/kotlin/gradle/build-support/$VERSION/build-support-$VERSION.jar" if aws s3api head-object --bucket $RELEASE_BUCKET --key $TEST_KEY; then echo "failing release; $VERSION already exists!"