name: Fastlane
 
on: [push, pull_request]
 
jobs:
  build-android:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v4
      with:
        distribution: 'zulu' # See 'Supported distributions' for available options
        java-version: '17'
    - name: Set outputs
      id: vars
      run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
    - name: Set up Ruby 2.7
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: 2.7
    - name: Install fastlane
      run: bundle install -j 6
    - name: Install Node dependencies
      run: npm install
    - name: Generate APK
      env:
        SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
        SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
        SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
        SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
        SENTRY_URL: ${{ secrets.SENTRY_URL }}
        SENTRY_DISABLE_AUTO_UPLOAD: true
      run: bundle exec fastlane android build
    - name: Upload artifact
      uses: actions/upload-artifact@v2
      with:
        name: jellyfin-audio-player-android-${{ steps.vars.outputs.sha_short }}.apk
        path: android/app/build/outputs/**/*.apk
