Skip to content

Commit

Permalink
Extract build name and version from pubspec
Browse files Browse the repository at this point in the history
  • Loading branch information
FelberMartin authored Aug 30, 2024
1 parent c34fe5c commit b6a5ee6
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,29 @@ on:
workflow_dispatch: # Allows manual triggering of the workflow

jobs:
check_version:
extract_version:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Extract Version from pubspec.yaml
- name: Extract version from pubspec.yaml
id: extract_version
run: |
# Extract version from pubspec.yaml
# Extract version string from pubspec.yaml
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- 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 }}
# Split VERSION into version name and build number
BUILD_NAME=$(echo $VERSION | cut -d "+" -f 1)
BUILD_NUMBER=$(echo $VERSION | cut -d "+" -f 2)
# Set the extracted values as environment variables
echo "BUILD_NAME=$BUILD_NAME" >> $GITHUB_ENV
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
build_android:
runs-on: ubuntu-latest
needs: check_version
needs: extract_version

steps:
- uses: actions/checkout@v3
Expand All @@ -59,14 +50,14 @@ jobs:
- name: Build Android APK
run: |
flutter build apk --release --no-tree-shake-icons \
--build-name=${{ github.ref_name }} \
--build-number=${{ github.run_number }}
--build-name=${{ env.BUILD_NAME }} \
--build-number=${{ env.BUILD_NUMBER }}
- name: Build Android App Bundle
run: |
flutter build appbundle --release --no-tree-shake-icons \
--build-name=${{ github.ref_name }} \
--build-number=${{ github.run_number }}
--build-name=${{ env.BUILD_NAME }} \
--build-number=${{ env.BUILD_NUMBER }}
- name: Upload APK
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -111,8 +102,8 @@ jobs:
run: |
fastlane run unlock_keychain
flutter build ipa --release --no-tree-shake-icons \
--build-name=${{ github.ref_name }} \
--build-number=${{ github.run_number }}
--build-name=${{ env.BUILD_NAME }} \
--build-number=${{ env.BUILD_NUMBER }}
- name: Upload IPA
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit b6a5ee6

Please sign in to comment.