invoice/.github/workflows/build.yml

162 lines
6.3 KiB
YAML

name: Build Web
on:
push:
branches:
- master
jobs:
build-main:
name: Build Web - MAIN
env:
commit_secret: ${{secrets.commit_secret}}
commit_email: ${{secrets.commit_email}}
commit_name: ${{secrets.commit_name}}
app_sentry: ${{secrets.app_sentry}}
api_secret: ${{secrets.api_secret}}
sentry_auth_token: ${{secrets.sentry_auth_token}}
sentry_org: ${{secrets.sentry_org}}
sentry_project: ${{secrets.sentry_project}}
sentry_url: ${{secrets.sentry_url}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
#flutter-version: '2.2.3'
channel: 'beta'
- name: Install Sentry
run: |
curl -sL https://sentry.io/get-cli/ | bash
- name: Setup Flutter
run: |
flutter doctor -v
flutter pub get
flutter config --enable-web
- name: Prepare App
run: |
cp lib/.env.dart.example lib/.env.dart
sed -i 's/secret/${{secrets.api_secret}}/g' lib/.env.dart
echo "const FLUTTER_VERSION = const <String, String>" > lib/flutter_version.dart
flutter --version --machine >> lib/flutter_version.dart
echo ";" >> lib/flutter_version.dart
- name: Build Hosted App
run: |
export SENTRY_RELEASE=$(sentry-cli releases propose-version)
sentry-cli --auth-token ${{secrets.sentry_auth_token}} --url ${{secrets.sentry_url}} releases --org ${{secrets.sentry_org}} new $SENTRY_RELEASE --project ${{secrets.sentry_project}}
sentry-cli --auth-token ${{secrets.sentry_auth_token}} --url ${{secrets.sentry_url}} releases --org ${{secrets.sentry_org}} set-commits --auto $SENTRY_RELEASE
flutter build web --dart-define=SENTRY_RELEASE=$SENTRY_RELEASE --source-maps
sed -i '/index.html/d' build/web/flutter_service_worker.js
git config --global user.email ${{secrets.commit_email}}
git config --global user.name ${{secrets.commit_name}}
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/invoiceninja.git
cd invoiceninja
git checkout v5-develop
cp -r ../build/web/* ./public/
rm ./public/index.html
git add .
git commit -m 'Admin Portal - Hosted'
git push
cd ..
sentry-cli --auth-token ${{secrets.sentry_auth_token}} --url ${{secrets.sentry_url}} releases --project ${{secrets.sentry_project}} --org ${{secrets.sentry_org}} files $SENTRY_RELEASE upload-sourcemaps . --ext dart --rewrite
cd ./build/web
sentry-cli --auth-token ${{secrets.sentry_auth_token}} --url ${{secrets.sentry_url}} releases --project ${{secrets.sentry_project}} --org ${{secrets.sentry_org}} files $SENTRY_RELEASE upload-sourcemaps . --ext map --ext js --rewrite
cd ../..
sentry-cli --auth-token ${{secrets.sentry_auth_token}} --url ${{secrets.sentry_url}} releases --org ${{secrets.sentry_org}} finalize $SENTRY_RELEASE
sentry-cli --auth-token ${{secrets.sentry_auth_token}} --url ${{secrets.sentry_url}} releases --org ${{secrets.sentry_org}} deploys $SENTRY_RELEASE new -e production
- name: Build HTML App
run: |
flutter build web --web-renderer html
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/invoiceninja.git invoiceninja_html
cd invoiceninja_html
git checkout v5-develop
cp ../build/web/main.dart.js ./public/main.html.dart.js
git add .
git commit -m 'Admin Portal - HTML'
git push
cd ..
- name: Build Profile App
run: |
flutter build web --profile
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/invoiceninja.git invoiceninja_profile
cd invoiceninja_profile
git checkout v5-develop
cp ../build/web/main.dart.js ./public/main.profile.dart.js
git add .
git commit -m 'Admin Portal - Profile'
git push
cd ..
- name: Build Selfhosted App
run: |
cp lib/utils/oauth.dart.foss lib/utils/oauth.dart
cp lib/ui/app/upgrade_dialog.dart.foss lib/ui/app/upgrade_dialog.dart
cp pubspec.foss.yaml pubspec.yaml
rm pubspec.lock
flutter build web
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/invoiceninja.git invoiceninja_foss
cd invoiceninja_foss
git checkout v5-develop
cp ../build/web/main.dart.js ./public/main.foss.dart.js
cp ../build/web/main.dart.js.map ./public/main.foss.dart.js.map
git add .
git commit -m 'Admin Portal - Selfhosted'
git push
build-next:
name: Build Web - NEXT
needs: build-main
env:
commit_secret: ${{secrets.commit_secret}}
commit_email: ${{secrets.commit_email}}
commit_name: ${{secrets.commit_name}}
api_secret: ${{secrets.api_secret}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
channel: 'beta'
- name: Setup Flutter
run: |
flutter doctor -v
cp pubspec.next.yaml pubspec.yaml
rm pubspec.lock
flutter pub get
flutter config --enable-web
- name: Prepare App
run: |
cp lib/.env.dart.example lib/.env.dart
sed -i 's/secret/${{secrets.api_secret}}/g' lib/.env.dart
echo "const FLUTTER_VERSION = const <String, String>" > lib/flutter_version.dart
flutter --version --machine >> lib/flutter_version.dart
echo ";" >> lib/flutter_version.dart
- name: Build Hosted App
run: |
flutter build web
sed -i '/index.html/d' build/web/flutter_service_worker.js
git config --global user.email ${{secrets.commit_email}}
git config --global user.name ${{secrets.commit_name}}
git clone https://${{secrets.commit_secret}}@github.com/invoiceninja/invoiceninja.git
cd invoiceninja
git checkout v5-develop
cp ../build/web/main.dart.js ./public/main.next.dart.js
git add .
git commit -m 'Admin Portal - Next'
git push
cd ..