From f24dc54e0b28b1554e54dc88569f5fbe0d7479eb Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 11 Dec 2024 13:04:53 +0000 Subject: [PATCH] chore: update release job a little bit compare `VERSION_NAME` and tag before publishing --- .github/workflows/release.yaml | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1ff3f665..45a5e10f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,20 +6,33 @@ on: jobs: run-on-release: runs-on: ubuntu-latest - + if: github.repository == 'ably/ably-chat-kotlin' steps: - # Ensure the workflow is being run for a published release - - name: Validate Release - run: | - if [ -z "${{ github.event.release.tag_name }}" ]; then - echo "This workflow must be run in the context of a published release."; - exit 1; - fi - echo "Running workflow for release: ${{ github.event.release.tag_name }}"; - - name: Checkout code uses: actions/checkout@v4 + - name: Extract tag + id: tag + run: | + TAG=${GITHUB_REF#refs/tags/v} + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Read VERSION_NAME from gradle.properties + id: version + run: | + VERSION_NAME=$(grep '^VERSION_NAME' gradle.properties | cut -d'=' -f2 | tr -d '[:space:]') + echo "version=$VERSION_NAME" >> $GITHUB_OUTPUT + + - name: Compare version with tag + run: | + if [ "$VERSION" != "$TAG" ]; then + echo "VERSION ($VERSION) does not match tag ($TAG)." + exit 1 + fi + env: + VERSION: ${{ steps.version.outputs.version }} + TAG: ${{ steps.tag.outputs.tag }} + - name: Set up JDK uses: actions/setup-java@v4 with: