-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check version instead of syncing it automatically
- Loading branch information
1 parent
e53dc07
commit c34fe5c
Showing
1 changed file
with
24 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|