|
| 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 }} |
0 commit comments