|
| 1 | +name: Go Release Automation |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + project-name: |
| 7 | + description: "Project name (e.g., DynamoDbEncryption)" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + version: |
| 11 | + description: "Version (e.g., v0.1.0)" |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +jobs: |
| 16 | + get-dafny-version: |
| 17 | + uses: ./.github/workflows/dafny_version.yml |
| 18 | + |
| 19 | + go-release: |
| 20 | + needs: get-dafny-version |
| 21 | + runs-on: macos-13 |
| 22 | + permissions: |
| 23 | + contents: write |
| 24 | + pull-requests: write |
| 25 | + id-token: write |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Support longpaths on Git checkout |
| 29 | + run: | |
| 30 | + git config --global core.longpaths true |
| 31 | +
|
| 32 | + # KMS and MPL tests need to use credentials which can call KMS |
| 33 | + - name: Configure AWS Credentials |
| 34 | + uses: aws-actions/configure-aws-credentials@v4 |
| 35 | + with: |
| 36 | + aws-region: us-west-2 |
| 37 | + role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2 |
| 38 | + role-session-name: GoRelease-DBESDK-Tests |
| 39 | + |
| 40 | + - name: Checkout repository |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + - name: Update submodules |
| 47 | + run: | |
| 48 | + git submodule update --init --recursive |
| 49 | +
|
| 50 | + - name: Setup Dafny |
| 51 | + uses: dafny-lang/[email protected] |
| 52 | + with: |
| 53 | + dafny-version: ${{ needs.get-dafny-version.outputs.version }} |
| 54 | + |
| 55 | + - name: Install Go |
| 56 | + uses: actions/setup-go@v5 |
| 57 | + with: |
| 58 | + go-version: "1.23" |
| 59 | + |
| 60 | + - name: Install Go imports |
| 61 | + run: | |
| 62 | + go install golang.org/x/tools/cmd/goimports@latest |
| 63 | +
|
| 64 | + - name: Install Smithy-Dafny codegen dependencies |
| 65 | + uses: ./.github/actions/install_smithy_dafny_codegen_dependencies |
| 66 | + |
| 67 | + - name: Configure Git |
| 68 | + run: | |
| 69 | + git config --global user.name "GitHub Actions" |
| 70 | + git config --global user.email "[email protected]" |
| 71 | +
|
| 72 | + - name: Get release directory name |
| 73 | + id: release-dir |
| 74 | + run: | |
| 75 | + chmod +x ./scripts/go-release-automation.sh |
| 76 | + RELEASE_DIR_NAME=$(./scripts/go-release-automation.sh get_release_dir_name "${{ github.event.inputs.project-name }}" "${{ github.event.inputs.version }}") |
| 77 | + echo "releaseDirName=$RELEASE_DIR_NAME" >> $GITHUB_OUTPUT |
| 78 | +
|
| 79 | + - name: Generate a changelog |
| 80 | + uses: orhun/git-cliff-action@v4 |
| 81 | + with: |
| 82 | + config: releases/go/.git-cliff.toml |
| 83 | + args: --bump -u --prepend releases/go/${{ steps.release-dir.outputs.releaseDirName }}/CHANGELOG.md |
| 84 | + |
| 85 | + - name: Run Go release automation script |
| 86 | + run: | |
| 87 | + chmod +x ./scripts/go-release-automation.sh |
| 88 | + ./scripts/go-release-automation.sh run_release_script ${{ github.event.inputs.project-name }} ${{ github.event.inputs.version }} |
| 89 | +
|
| 90 | + - name: Create Pull Request |
| 91 | + env: |
| 92 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + run: | |
| 94 | + PROJECT_NAME="${{ github.event.inputs.project-name }}" |
| 95 | + VERSION="${{ github.event.inputs.version }}" |
| 96 | +
|
| 97 | + # Get the release directory name using the sourced function |
| 98 | + RELEASE_DIR_NAME="${{ steps.release-dir.outputs.releaseDirName }}" |
| 99 | +
|
| 100 | + BRANCH_NAME="golang-release-staging-branch/$RELEASE_DIR_NAME/$VERSION" |
| 101 | +
|
| 102 | + DIFF_FILES=$(diff -qr $PROJECT_NAME/runtimes/go/ImplementationFromDafny-go releases/go/$RELEASE_DIR_NAME || true) |
| 103 | +
|
| 104 | + # Create PR using GitHub CLI |
| 105 | + gh pr create \ |
| 106 | + --title "chore(go): Release $RELEASE_DIR_NAME Go module $VERSION" \ |
| 107 | + --body "This PR was automatically created by the Go Release Automation workflow. It releases version $VERSION of the $RELEASE_DIR_NAME Go module. The diff between $PROJECT_NAME/runtimes/go/ImplementationFromDafny-go and releases/go/$RELEASE_DIR_NAME is below: |
| 108 | +
|
| 109 | + $DIFF_FILES |
| 110 | + " \ |
| 111 | + --base main \ |
| 112 | + --head "$BRANCH_NAME" \ |
| 113 | + --label "golang" \ |
| 114 | + --draft |
0 commit comments