diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 14f98ae..2875b36 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -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" @@ -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 diff --git a/.github/workflows/release_pr_workflow.yml b/.github/workflows/release_pr_workflow.yml index 49958b6..7eeca47 100644 --- a/.github/workflows/release_pr_workflow.yml +++ b/.github/workflows/release_pr_workflow.yml @@ -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