From a0cffd3f246196f8ad6da02130373e674b0c968e Mon Sep 17 00:00:00 2001 From: azamora Date: Tue, 19 Aug 2025 14:06:26 -0400 Subject: [PATCH] updating release to push release images and bumping the version. --- .github/workflows/ci.yml | 5 +- .github/workflows/release.yml | 177 ++++++++++++++++++++++++++++++++++ RELEASE_NOTES.md | 17 ++++ VERSION | 2 +- docker-push.sh | 34 ++++++- 5 files changed, 232 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6846ff9..6e4ec00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,8 @@ on: jobs: build: runs-on: ubuntu-latest + # Skip CI build if this is a tag push (handled by release workflow) + if: startsWith(github.ref, 'refs/tags/') == false env: GO111MODULE: on steps: @@ -83,7 +85,8 @@ jobs: deploy-lambdas: runs-on: ubuntu-latest needs: build - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' + # Skip if this is a tag push (handled by release workflow) + if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') && startsWith(github.ref, 'refs/tags/') == false steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bc1e9f6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,177 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + env: + GO111MODULE: on + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.x' + + - name: Get version from tag + id: version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Update VERSION file + run: echo "${{ steps.version.outputs.VERSION }}" > VERSION + + - name: Install Dependencies + run: make GOBIN=$HOME/gopath/bin deps + + - name: Run Tests + run: make GOBIN=$HOME/gopath/bin test + + - name: Build Project + run: make GOBIN=$HOME/gopath/bin build + + - name: Build Docker Images + run: | + # Build main gogen image with version tag + docker build -t clintsharp/gogen:${{ steps.version.outputs.VERSION }} . + docker tag clintsharp/gogen:${{ steps.version.outputs.VERSION }} clintsharp/gogen:latest + + # Build gogen-api image with version tag + cd gogen-api + docker build -t clintsharp/gogen-api:${{ steps.version.outputs.VERSION }} . + docker tag clintsharp/gogen-api:${{ steps.version.outputs.VERSION }} clintsharp/gogen-api:latest + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Push Docker Images + run: | + # Push main gogen image with version tag and latest + docker push clintsharp/gogen:${{ steps.version.outputs.VERSION }} + docker push clintsharp/gogen:latest + + # Push gogen-api image with version tag and latest + docker push clintsharp/gogen-api:${{ steps.version.outputs.VERSION }} + docker push clintsharp/gogen-api:latest + + - name: Create Release Archive + run: | + # Create archives only if build directories exist + if [ -d "build/linux" ]; then + tar -czf gogen-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz -C build/linux gogen + fi + if [ -d "build/darwin" ]; then + tar -czf gogen-${{ steps.version.outputs.VERSION }}-darwin-amd64.tar.gz -C build/darwin gogen + fi + if [ -d "build/windows" ]; then + tar -czf gogen-${{ steps.version.outputs.VERSION }}-windows-amd64.tar.gz -C build/windows gogen.exe + fi + + - name: Generate Release Notes + id: release_notes + run: | + echo "RELEASE_NOTES<> $GITHUB_OUTPUT + echo "## Release ${{ steps.version.outputs.TAG_NAME }}" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "### Docker Images" >> $GITHUB_OUTPUT + echo "- \`docker pull clintsharp/gogen:${{ steps.version.outputs.VERSION }}\`" >> $GITHUB_OUTPUT + echo "- \`docker pull clintsharp/gogen-api:${{ steps.version.outputs.VERSION }}\`" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "### Latest Tag" >> $GITHUB_OUTPUT + echo "- \`docker pull clintsharp/gogen:latest\`" >> $GITHUB_OUTPUT + echo "- \`docker pull clintsharp/gogen-api:latest\`" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + if [ -f RELEASE_NOTES.md ]; then + cat RELEASE_NOTES.md >> $GITHUB_OUTPUT + else + echo "### Changes in this release" >> $GITHUB_OUTPUT + # Get the previous tag for comparison + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") + if [ -n "$PREV_TAG" ]; then + git log --pretty=format:"- %s" ${PREV_TAG}..HEAD >> $GITHUB_OUTPUT + else + git log --pretty=format:"- %s" -10 >> $GITHUB_OUTPUT + fi + fi + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + name: Release ${{ steps.version.outputs.TAG_NAME }} + body: ${{ steps.release_notes.outputs.RELEASE_NOTES }} + files: | + gogen-*.tar.gz + draft: false + prerelease: false + + # Deploy to production + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Deploy Build Artifacts to S3 + run: | + if [ -d "build" ]; then + aws s3 sync build s3://gogen-artifacts-prod --delete + fi + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Deploy UI + run: | + chmod +x ui/deploy_ui.sh + ui/deploy_ui.sh + + deploy-lambdas: + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Install AWS SAM CLI + run: | + python -m pip install --upgrade pip + pip install aws-sam-cli boto3 botocore awscli + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Deploy Lambda Functions + env: + ROLE_ARN: ${{ secrets.PROD_LAMBDA_ROLE_ARN }} + run: | + cd gogen-api + bash deploy_lambdas.sh \ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 08c881c..77d242c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,22 @@ # Gogen Release Notes +## Version 0.12.1 + +### New Features +- Added automated release cycle with Docker image versioning + - Docker images now tagged with semantic version numbers (e.g., `clintsharp/gogen:0.12.1`) + - Added GitHub Actions workflow for automated releases on version tags + - Both `gogen` and `gogen-api` images are versioned and published to Docker Hub + +### Improvements +- Enhanced CI/CD pipeline to support version-based releases + - CI workflow now skips on tag pushes to avoid conflicts with release workflow + - Updated `docker-push.sh` script to support version tagging + - Release workflow creates GitHub releases with build artifacts + +### Bug Fixes +- Fixed race condition with nil pointer in outputter.go + ## Version 0.12.0 ### Breaking Changes diff --git a/VERSION b/VERSION index ac454c6..34a8361 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.12.0 +0.12.1 diff --git a/docker-push.sh b/docker-push.sh index bb0a5fd..17ea828 100755 --- a/docker-push.sh +++ b/docker-push.sh @@ -1,3 +1,35 @@ #!/bin/bash + +# Script for pushing Docker images with version tags +# Usage: ./docker-push.sh [version] +# If no version is provided, only pushes 'latest' tag + +VERSION=$1 + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin -docker push clintsharp/gogen:latest + +if [ -n "$VERSION" ]; then + echo "Pushing Docker images with version $VERSION..." + + # Tag and push main gogen image + docker tag clintsharp/gogen:latest clintsharp/gogen:$VERSION + docker push clintsharp/gogen:$VERSION + docker push clintsharp/gogen:latest + + # Tag and push gogen-api image if it exists + if docker images | grep -q "clintsharp/gogen-api"; then + docker tag clintsharp/gogen-api:latest clintsharp/gogen-api:$VERSION + docker push clintsharp/gogen-api:$VERSION + docker push clintsharp/gogen-api:latest + fi +else + echo "Pushing Docker images with 'latest' tag only..." + docker push clintsharp/gogen:latest + + # Push gogen-api if it exists + if docker images | grep -q "clintsharp/gogen-api"; then + docker push clintsharp/gogen-api:latest + fi +fi + +echo "Docker push completed successfully!" \ No newline at end of file