Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump release workflows #166

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "[email protected]"
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 "[email protected]"
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
Loading