From 9e3d55dd9544b31b1f2345153bc2b56046c6578c Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Thu, 29 Aug 2024 20:54:43 +0200 Subject: [PATCH] github action build_release another attempt to fix release process with README.md update (#14) --- .github/workflows/build-branch.yml | 4 ++++ .github/workflows/build-main.yml | 3 +++ .github/workflows/build-release.yml | 21 +++++++++++++++++++-- .github/workflows/updater.yml | 3 ++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-branch.yml b/.github/workflows/build-branch.yml index 45103c0..9b8ecae 100644 --- a/.github/workflows/build-branch.yml +++ b/.github/workflows/build-branch.yml @@ -6,18 +6,22 @@ on: pull_request: branches-ignore: - main + jobs: build_branch: runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v4.1.7 + - name: Setup Java uses: actions/setup-java@v4.2.2 with: distribution: 'temurin' java-version: 22 + - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Build run: ./gradlew build diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 94f0a29..f41859e 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -9,13 +9,16 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4.1.7 + - name: Setup Java uses: actions/setup-java@v4.2.2 with: distribution: 'temurin' java-version: 22 + - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Build run: ./gradlew build sourcesJar javadocJar publish env: diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index f59b813..b9875ec 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -15,17 +15,21 @@ jobs: VERSION=${GITHUB_REF_NAME#v} echo Version: $VERSION echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Checkout sources uses: actions/checkout@v4.1.7 with: fetch-depth: 0 + - name: Setup Java uses: actions/setup-java@v4.2.2 with: distribution: 'temurin' java-version: 22 + - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Build run: ./gradlew -Pversion=${VERSION} build sourcesJar javadocJar publishToSonatype closeAndReleaseSonatypeStagingRepository env: @@ -35,10 +39,23 @@ jobs: ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} ORG_GRADLE_PROJECT_sonatypeUser: ${{ secrets.SONATYPE_USER }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} - - name: Switch to branch HEAD - run: git checkout $(git branch --contains ${{ github.event.release.tag_name }}) + + - name: Find branch from tag + id: find-branch + run: | + BRANCH=$(git branch -r --contains ${{ github.event.release.tag_name }} | grep -v '\->' | sed 's/origin\///' | head -n 1) + if [ -z "$BRANCH" ]; then + echo "Branch not found for tag $TAG" + exit 1 + fi + echo "::set-output name=branch::$BRANCH" + + - name: Checkout branch HEAD + run: git checkout ${{ steps.find-branch.outputs.branch }} + - name: Update README run: sed -i 's/com\.xemantic\.kotlin:xemantic-kotlin-swing-dsl-\(core\|test\):[0-9]\+\(\.[0-9]\+\)*\>/com.xemantic.kotlin:xemantic-kotlin-swing-dsl-\1:${VERSION}/g' README.md + - name: Commit README uses: stefanzweifel/git-auto-commit-action@v5 with: diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index 6b1d7aa..58b652e 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -11,7 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.7 + - name: Git checkout + uses: actions/checkout@v4.1.7 with: # [Required] Access token with `workflow` scope. token: ${{ secrets.WORKFLOW_SECRET }}