Skip to content

Commit

Permalink
Merge pull request #166 from Aiven-Open/jeqo/fix-release-workflows
Browse files Browse the repository at this point in the history
chore: bump release workflows
  • Loading branch information
tvainika authored Jan 30, 2024
2 parents cca11ff + e4fba6e commit 9ace2c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Java SDK
uses: actions/setup-java@2
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
distribution: temurin

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit_hash }}

- name: Check commit title and extract version
env:
COMMIT_HASH: ${{ github.event.inputs.commit_hash }}
run: |
export commit_title=$(git log --pretty=format:%s -1 ${{ github.event.inputs.commit_hash }})
export commit_title=$(git log --pretty=format:%s -1 $COMMIT_HASH
echo "Commit title: $commit_title"
if [[ $commit_title =~ ^Release\ version\ [0-9]*\.[0-9]*\.[0-9]*$ ]]; then
echo "Valid commit title"
Expand All @@ -42,11 +44,13 @@ jobs:
./gradlew clean build
- name: Create tag
env:
VERSION: ${{ env.version }}
run: |
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
git tag -a "v${{ env.version }}" -m "Release version ${{ env.version }}"
git push origin "v${{ env.version }}"
git tag -a "v$VERSION" -m "Release version $VERSION"
git push origin "v$VERSION"
- name: Create release draft
id: create_release
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/release_pr_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,44 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check versions
env:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
SNAPSHOT_VERSION: ${{ github.event.inputs.snapshot_version }}
run: |
echo "Checking release version..."
if echo ${{ github.event.inputs.release_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+$' > /dev/null; then
if echo $RELEASE_VERSION | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+$' > /dev/null; then
echo "Release version is invalid"
exit 1
fi
echo "Checking snapshot version..."
if echo ${{ github.event.inputs.snapshot_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT$' > /dev/null; then
if echo $SNAPSHOT_VERSION | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT$' > /dev/null; then
echo "Snapshot version is invalid"
exit 1
fi
- name: Checkout main
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0

- name: Create release commits
env:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
SNAPSHOT_VERSION: ${{ github.event.inputs.snapshot_version }}
run: |
git config --local user.name "GitHub Action"
git config --local user.email "action@github.com"
sed -i -e "s/^version=.\+$/version=${{ github.event.inputs.release_version }}/g" gradle.properties
sed -i -e "s/^version=.\+$/version=$RELEASE_VERSION/g" gradle.properties
git add gradle.properties
git commit -m "Release version ${{ github.event.inputs.release_version }}"
sed -i -e "s/^version=.\+$/version=${{ github.event.inputs.snapshot_version }}/g" gradle.properties
git commit -m "Release version $RELEASE_VERSION"
sed -i -e "s/^version=.\+$/version=$SNAPSHOT_VERSION/g" gradle.properties
git add gradle.properties
git commit -m "Bump version to ${{ github.event.inputs.snapshot_version }}"
git commit -m "Bump version to $SNAPSHOT_VERSION"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v4
with:
branch: release-${{ github.event.inputs.release_version }}
delete-branch: true
Expand Down

0 comments on commit 9ace2c9

Please sign in to comment.