diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3ed1d2..835a153 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,35 +7,38 @@ on: workflow_dispatch: # Allows manual triggering of the workflow jobs: - sync_version: + check_version: runs-on: ubuntu-latest - + steps: - uses: actions/checkout@v3 - - - name: Sync version in pubspec.yaml - run: | - # Extract the version from the tag name - VERSION=${GITHUB_REF#refs/tags/} - sed -i "s/^version:.*/version: $VERSION/" pubspec.yaml - - # Configure git - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - # Create a new branch from the current detached HEAD - BRANCH_NAME="update-version-$VERSION" - git checkout -b $BRANCH_NAME - # Commit the change - git commit -am "Update version to match tag $VERSION" + - name: Extract Version from pubspec.yaml + id: extract_version + run: | + # Extract version from pubspec.yaml + VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //') + echo "VERSION=$VERSION" >> $GITHUB_ENV - # Push the branch to the origin - git push origin $BRANCH_NAME + - name: Check if Tag Version Matches pubspec.yaml Version + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/} + PUBSPEC_VERSION=$VERSION + + echo "Tag version: $TAG_VERSION" + echo "pubspec.yaml version: $PUBSPEC_VERSION" + + # Compare the tag version with the pubspec.yaml version + if [ "$TAG_VERSION" != "$PUBSPEC_VERSION" ]; then + echo "Error: Tag version ($TAG_VERSION) does not match pubspec.yaml version ($PUBSPEC_VERSION)" + exit 1 + fi + env: + VERSION: ${{ env.VERSION }} build_android: runs-on: ubuntu-latest - needs: sync_version + needs: check_version steps: - uses: actions/checkout@v3