Skip to content

Go Release Automation #15

Go Release Automation

Go Release Automation #15

Workflow file for this run

name: Go Release Automation
on:
workflow_dispatch:
inputs:
project-name:
description: "Project name (e.g., DynamoDbEncryption)"
required: true
type: string
version:
description: "Version (e.g., v0.1.0)"
required: true
type: string
jobs:
get-dafny-version:
uses: ./.github/workflows/dafny_version.yml
go-release:
needs: get-dafny-version
runs-on: macos-13
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Support longpaths on Git checkout
run: |
git config --global core.longpaths true
# KMS and MPL tests need to use credentials which can call KMS
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
role-session-name: GoRelease-DBESDK-Tests
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update submodules
run: |
git submodule update --init --recursive
- name: Setup Dafny
uses: dafny-lang/[email protected]
with:
dafny-version: ${{ needs.get-dafny-version.outputs.version }}
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.23"
- name: Install Go imports
run: |
go install golang.org/x/tools/cmd/goimports@latest
- name: Install Smithy-Dafny codegen dependencies
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Get release directory name
id: release-dir
run: |
chmod +x ./submodules/MaterialProviders/scripts/go-release-automation.sh
RELEASE_DIR_NAME=$(./submodules/MaterialProviders/scripts/go-release-automation.sh get_release_dir_name "${{ github.event.inputs.project-name }}" "${{ github.event.inputs.version }}")
echo "releaseDirName=$RELEASE_DIR_NAME" >> $GITHUB_OUTPUT
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
with:
config: releases/go/.git-cliff.toml
args: --bump -u --prepend releases/go/${{ steps.release-dir.outputs.releaseDirName }}/CHANGELOG.md
- name: Run Go release automation script
run: |
chmod +x ./submodules/MaterialProviders/scripts/go-release-automation.sh
./submodules/MaterialProviders/scripts/go-release-automation.sh run_release_script ${{ github.event.inputs.project-name }} ${{ github.event.inputs.version }}
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PROJECT_NAME="${{ github.event.inputs.project-name }}"
VERSION="${{ github.event.inputs.version }}"
# Get the release directory name using the sourced function
RELEASE_DIR_NAME="${{ steps.release-dir.outputs.releaseDirName }}"
BRANCH_NAME="golang-release-staging-branch/$RELEASE_DIR_NAME/$VERSION"
DIFF_FILES=$(diff -qr $PROJECT_NAME/runtimes/go/ImplementationFromDafny-go releases/go/$RELEASE_DIR_NAME || true)
# Create PR using GitHub CLI
gh pr create \
--title "chore(go): Release $RELEASE_DIR_NAME Go module $VERSION" \
--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:
$DIFF_FILES
" \
--base main \
--head "$BRANCH_NAME" \
--label "golang" \
--draft