Merge pull request #69 from doudar/Map_fix #104
This file contains hidden or 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
| name: Build and Release Applications | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| env: | |
| STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }} | |
| STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }} | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.set_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Extract version from pubspec.yaml | |
| id: extract_version | |
| run: | | |
| VERSION=$(grep 'version: ' pubspec.yaml | sed 's/version: //') | |
| echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
| - name: Check if tag exists | |
| id: check_tag | |
| run: | | |
| TAG_EXISTS=$(git tag -l "$VERSION") | |
| if [[ "$TAG_EXISTS" == "$VERSION" ]]; then | |
| SUFFIX=1 | |
| NEW_TAG="$VERSION-$SUFFIX" | |
| while [[ $(git tag -l "$NEW_TAG") == "$NEW_TAG" ]]; do | |
| SUFFIX=$((SUFFIX+1)) | |
| NEW_TAG="$VERSION-$SUFFIX" | |
| done | |
| echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | |
| else | |
| echo "NEW_TAG=$VERSION" >> $GITHUB_ENV | |
| fi | |
| - name: Set output | |
| id: set_version | |
| run: echo "::set-output name=version::$NEW_TAG" | |
| build-and-release: | |
| needs: prepare | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup Java | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v1 | |
| with: | |
| flutter-version: '3.22.3' | |
| # Debug environment variables | |
| - name: Debug Environment Variables | |
| run: | | |
| echo "Checking environment variables (secrets will be masked):" | |
| env | grep -i STRAVA || true | |
| - name: Create env.local.dart | |
| run: | | |
| mkdir -p lib/config | |
| umask 077 | |
| cat > lib/config/env.local.dart << EOL | |
| class Environment { | |
| static const String stravaClientId = '${{ secrets.STRAVA_CLIENT_ID }}'; | |
| static const String stravaClientSecret = '${{ secrets.STRAVA_CLIENT_SECRET }}'; | |
| static bool get hasStravaConfig => | |
| stravaClientId.isNotEmpty && stravaClientSecret.isNotEmpty; | |
| } | |
| EOL | |
| # Verify file exists but don't show contents | |
| ls -l lib/config/env.local.dart | |
| - name: Build Android APK | |
| run: flutter build apk --no-tree-shake-icons | |
| - name: Rename APK to SS2kConfigApp.apk | |
| run: mv build/app/outputs/flutter-apk/app-release.apk build/SS2kConfigApp.apk | |
| - name: Build iOS App | |
| run: flutter build ios --release --no-codesign --no-tree-shake-icons | |
| - name: Build macOS App | |
| run: flutter build macos --release --no-tree-shake-icons | |
| - name: Create artifacts | |
| run: | | |
| mkdir -p artifacts | |
| zip -r artifacts/SS2kConfigApp${{ needs.prepare.outputs.version }}.zip build/SS2kConfigApp.apk build/ios/iphoneos build/macos/Build/Products/Release | |
| # Clean up sensitive files | |
| - name: Clean up env.local.dart | |
| if: always() | |
| run: | | |
| if [ -f lib/config/env.local.dart ]; then | |
| rm lib/config/env.local.dart | |
| echo "Cleaned up env.local.dart" | |
| fi | |
| - name: Archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-artifacts | |
| path: artifacts/ | |
| - name: Get tag info | |
| id: tag_info | |
| run: echo ::set-output name=SOURCE_TAG::${{ needs.prepare.outputs.version }} | |
| - name: Create release | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ steps.tag_info.outputs.SOURCE_TAG }} | |
| name: SmartSpin2kConfigApp ${{ steps.tag_info.outputs.SOURCE_TAG }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| body: ${{ github.event.head_commit.message }} | |
| files: artifacts/SS2kConfigApp${{ needs.prepare.outputs.version }}.zip |