Skip to content

Release

Release #3

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 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: Prepare next development version
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"
- name: Push changes and tags
run: |
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>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 JitPack build
run: |
curl -s "https://jitpack.io/com/github/wassertim/dynamodb-toolkit/v$NEW_VERSION"