Release #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 next 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") | |
NEW_VERSION=$(echo $BASE_VERSION | awk -F. '{print $1"."$2"."($3+1)}') | |
;; | |
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: Push release tag | |
run: | | |
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>v${{ 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") | |
echo "Status response: $status_response" | |
# Debug: Show what we're matching against | |
echo "Checking for pattern: '\"status\" : \"ok\"'" | |
# Use grep for more reliable pattern matching | |
if echo "$status_response" | grep -q '"status" : "ok"'; then | |
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" | |
exit 0 | |
elif echo "$status_response" | grep -q '"status" : "error"'; then | |
echo "β JitPack build failed!" | |
echo "π Check logs at: https://jitpack.io/com/github/wassertim/dynamodb-toolkit/v$NEW_VERSION/build.log" | |
exit 1 | |
elif echo "$status_response" | grep -q '"status" : "building"'; then | |
echo "β³ Build in progress..." | |
else | |
echo "β³ Build queued or starting..." | |
fi | |
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 | |
- name: Finalize release | |
run: | | |
# Calculate next development version | |
NEXT_DEV_VERSION=$(echo $NEW_VERSION | awk -F. '{print $1"."$2"."($3+1)"-SNAPSHOT"}') | |
# 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" | |
# Push to main branch | |
git pull --rebase origin main | |
git push origin main |