Skip to content

Release

Release #26

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Configure Git
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
- name: Build and test main library
run: mvn clean install
- name: Test integration tests
run: |
cd integration-tests
mvn clean test
- name: Prepare release
run: |
# Determine release version based on input
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=dynamodb-toolkit.version -q -DforceStdout)
BASE_VERSION=$(echo $CURRENT_VERSION | sed 's/-SNAPSHOT//')
case "${{ github.event.inputs.version_type }}" in
"major")
NEW_VERSION=$(echo $BASE_VERSION | awk -F. '{print ($1+1)".0.0"}')
;;
"minor")
NEW_VERSION=$(echo $BASE_VERSION | awk -F. '{print $1"."($2+1)".0"}')
;;
"patch")
# For patch releases, use the current SNAPSHOT version (just remove -SNAPSHOT)
NEW_VERSION=$BASE_VERSION
;;
esac
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "Releasing version: $NEW_VERSION"
- name: Update version
run: |
# Update version property in both pom.xml files
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEW_VERSION<\/dynamodb-toolkit.version>/" pom.xml
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEW_VERSION<\/dynamodb-toolkit.version>/" integration-tests/pom.xml
- name: Build and verify
run: |
mvn clean install
cd integration-tests && mvn clean compile
- name: Commit and tag release
run: |
git add pom.xml integration-tests/pom.xml
git commit -m "Release version $NEW_VERSION"
git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"
- name: Prepare next development version
run: |
# Calculate next development version based on the version type
case "${{ github.event.inputs.version_type }}" in
"major")
NEXT_DEV_VERSION=$(echo $NEW_VERSION | awk -F. '{print $1".1.0-SNAPSHOT"}')
;;
"minor")
NEXT_DEV_VERSION=$(echo $NEW_VERSION | awk -F. '{print $1"."$2".1-SNAPSHOT"}')
;;
"patch")
NEXT_DEV_VERSION=$(echo $NEW_VERSION | awk -F. '{print $1"."$2"."($3+1)"-SNAPSHOT"}')
;;
esac
# Update to next development version
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEXT_DEV_VERSION<\/dynamodb-toolkit.version>/" pom.xml
sed -i "s/<dynamodb-toolkit.version>.*<\/dynamodb-toolkit.version>/<dynamodb-toolkit.version>$NEXT_DEV_VERSION<\/dynamodb-toolkit.version>/" integration-tests/pom.xml
git add pom.xml integration-tests/pom.xml
git commit -m "Bump to next development version $NEXT_DEV_VERSION"
- name: Push changes and tags
run: |
# Pull latest changes to avoid conflicts
git pull --rebase origin main
git push origin main
git push origin "v$NEW_VERSION"
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: Release v${{ env.NEW_VERSION }}
body: |
## Changes in v${{ env.NEW_VERSION }}
This release was automatically generated.
### JitPack Usage
Add this dependency to your `pom.xml`:
```xml
<dependency>
<groupId>com.github.wassertim</groupId>
<artifactId>dynamodb-toolkit</artifactId>
<version>${{ env.NEW_VERSION }}</version>
</dependency>
```
Don't forget to add the JitPack repository:
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```
draft: false
prerelease: false
- name: Trigger and monitor JitPack build
run: |
echo "πŸš€ Triggering JitPack build for v$NEW_VERSION"
# Trigger the build
trigger_response=$(curl -s "https://jitpack.io/com/github/wassertim/dynamodb-toolkit/v$NEW_VERSION")
echo "Trigger response: $trigger_response"
# Check build status with polling
echo "πŸ“‹ Monitoring build status..."
max_attempts=20 # 10 minutes max (30s * 20)
attempt=1
while [ $attempt -le $max_attempts ]; do
echo "πŸ” Checking build status (attempt $attempt/$max_attempts)..."
# Check build status via the builds API
status_response=$(curl -s "https://jitpack.io/api/builds/com.github.wassertim/dynamodb-toolkit/v$NEW_VERSION")
# Parse status and show clean output
status=$(echo "$status_response" | grep -o '"status" : "[^"]*"' | cut -d'"' -f4)
case "$status" in
"ok")
echo "βœ… JitPack build completed successfully!"
echo "πŸ“¦ Artifact available at: https://jitpack.io/#wassertim/dynamodb-toolkit/v$NEW_VERSION"
echo "πŸ”— Build log: https://jitpack.io/com/github/wassertim/dynamodb-toolkit/v$NEW_VERSION/build.log"
# Now that JitPack succeeded, update README with new version
echo "πŸ“ Updating README.md with confirmed working version..."
sed -i "s/<version>[^<]*<\/version>/<version>$NEW_VERSION<\/version>/" README.md
# Check if README actually changed
if git diff --quiet README.md; then
echo "πŸ“„ README.md already has correct version v$NEW_VERSION"
else
git add README.md
git commit -m "Update README.md to version $NEW_VERSION after JitPack success"
git push origin main
echo "πŸ“ README.md updated successfully"
fi
echo "πŸŽ‰ Release $NEW_VERSION completed successfully!"
exit 0
;;
"error"|"Error")
echo "❌ JitPack build failed!"
echo "πŸ”— Check logs at: https://jitpack.io/com/github/wassertim/dynamodb-toolkit/v$NEW_VERSION/build.log"
exit 1
;;
"none")
echo "⏳ Build in progress..."
;;
"tagNotFound")
echo "⚠️ Tag not found yet, waiting for Git sync..."
;;
"")
echo "⚠️ Unable to parse status from response"
;;
*)
echo "⚠️ Unknown build status: $status"
echo "πŸ”— Check manually at: https://jitpack.io/#wassertim/dynamodb-toolkit/v$NEW_VERSION"
;;
esac
if [ $attempt -eq $max_attempts ]; then
echo "⏰ Build timeout reached (10 minutes)"
echo "πŸ”— Check status manually at: https://jitpack.io/#wassertim/dynamodb-toolkit"
exit 1
fi
sleep 30
attempt=$((attempt + 1))
done