Skip to content

Commit

Permalink
Check version instead of syncing it automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
FelberMartin authored Aug 30, 2024
1 parent e53dc07 commit c34fe5c
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
# 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
Expand Down

0 comments on commit c34fe5c

Please sign in to comment.