Skip to content

Deploy

Deploy #22

name: Deploy
on:
workflow_dispatch:
inputs:
build_android:
description: 'Build and Deploy Android'
required: true
type: boolean
default: true
jobs:
job-linux:
runs-on: ubuntu-latest
steps:
- uses: subosito/[email protected]
with:
channel: 'stable'
architecture: x64
- uses: actions/checkout@v2
with:
lfs: 'true'
- name: Update dependencies
run: |
flutter config --enable-linux-desktop
flutter doctor
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev libblkid-dev tree
flutter doctor
flutter pub get
# This is to give an offset since builds before this repo were in the 100's
- name: Generate run number with offset
env:
NUM: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($NUM + 200))" >> $GITHUB_ENV
- name: Generate app build name
shell: bash
run: echo "##[set-output name=name;]$(echo sweet_$BUILD_NUMBER)"
id: app_build
- name: Building ${{ steps.app_build.outputs.name }} Linux
run: flutter build linux --release --verbose
- name: 'Zipping build'
run: |
pushd build/linux/x64/release/bundle/
zip -r ${{ steps.app_build.outputs.name }}-linux.zip ./*
popd
mv build/linux/x64/release/bundle/${{ steps.app_build.outputs.name }}-linux.zip ./${{ steps.app_build.outputs.name }}-linux.zip
- name: 'Uploading artifact'
uses: actions/[email protected]
with:
name: ${{ steps.app_build.outputs.name }}-linux
path: ${{ steps.app_build.outputs.name }}-linux.zip
retention-days: 5
# WINDOWS
job-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
lfs: 'true'
- uses: subosito/[email protected]
with:
channel: 'stable'
architecture: x64
- name: Update dependencies
run: |
flutter config --enable-windows-desktop
flutter pub get
# This is to give an offset since builds before this repo were in the 100's
- name: Generate run number with offset
shell: bash
env:
NUM: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($NUM + 200))" >> $GITHUB_ENV
- name: Generate app build name
shell: bash
run: echo "##[set-output name=name;]$(echo sweet_$BUILD_NUMBER)"
id: app_build
- name: Update Windows build number
shell: bash
run: |
VERSION_FROM_PUBSPEC=$(sed -n -e '/version: / s///p' pubspec.yaml | tr -d '\r\n')
VERSION=$(echo -n $VERSION_FROM_PUBSPEC | sed -E -e "s/((([0-9])+\.([0-9])+\.([0-9])+)\+(([0-9])+))/\2+$BUILD_NUMBER/")
echo "Setting windows version to $VERSION"
sed -i -E -e "s/((([0-9])+\.([0-9])+\.([0-9])+(([\+])([0-9])+)?))/$VERSION/" windows/runner/Runner.rc
- name: Building ${{ steps.app_build.outputs.name }} Windows
run: flutter build windows --release
- name: 'Zipping build'
uses: vimtor/action-zip@v1
with:
dest: ${{ steps.app_build.outputs.name }}-windows.zip
files: build/windows/x64/runner/Release
- name: 'Uploading artifact'
uses: actions/[email protected]
with:
name: ${{ steps.app_build.outputs.name }}-windows
path: ${{ steps.app_build.outputs.name }}-windows.zip
retention-days: 5
job-apple:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
lfs: 'true'
- uses: subosito/[email protected]
with:
channel: 'stable'
architecture: x64
- name: Update dependencies
run: |
flutter config --enable-macos-desktop
flutter pub get
# This is to give an offset since builds before this repo were in the 100's
- name: Generate run number with offset
env:
NUM: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($NUM + 200))" >> $GITHUB_ENV
- name: Generate app build name
shell: bash
run: echo "##[set-output name=name;]$(echo sweet_$BUILD_NUMBER)"
id: app_build
# - name: Building ${{ steps.app_build.outputs.name }} iOS
# run: flutter build ios --build-number $BUILD_NUMBER --release --no-codesign --config-only
# - name: Setup Ruby
# uses: ruby/[email protected]
# with:
# bundler-cache: true
# - name: Build and upload to TestFlight
# run: |
# bundle install
# bundle exec fastlane ios beta
# env:
# SWEET_MATCH_ACCESS_TOKEN: ${{ secrets.SWEET_MATCH_ACCESS_TOKEN }}
# MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
# FASTLANE_USER: ${{ secrets.FASTLANE_APPLE_ID }}
# FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
# FASTLANE_APPLE_ID: ${{ secrets.FASTLANE_APPLE_ID }}
# FASTLANE_ITC_TEAM_ID: ${{ secrets.FASTLANE_ITC_TEAM_ID }}
# FASTLANE_TEAM_ID: ${{ secrets.FASTLANE_TEAM_ID }}
- name: Building ${{ steps.app_build.outputs.name }} MacOS
run: flutter build macos --build-number $BUILD_NUMBER --release
- name: 'Zipping build'
run: |
pushd build/macos/Build/Products/Release/
zip -r ${{ steps.app_build.outputs.name }}-macos.zip SWEET.app
popd
mv build/macos/Build/Products/Release/${{ steps.app_build.outputs.name }}-macos.zip ./${{ steps.app_build.outputs.name }}-macos.zip
- name: 'Uploading artifact'
uses: actions/[email protected]
with:
name: ${{ steps.app_build.outputs.name }}-macos
path: ${{ steps.app_build.outputs.name }}-macos.zip
retention-days: 5
job-android:
runs-on: ubuntu-latest
if: ${{ inputs.build_android }}
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
steps:
- uses: actions/checkout@v2
with:
lfs: 'true'
- name: Decode Upload keystore
working-directory: ./android
run: |
echo "${{ secrets.UPLOAD_KEYSTORE }}" > key.jks.asc
gpg -d --passphrase ${{ secrets.UPLOAD_KEYSTORE_PASSPHRASE }} --batch key.jks.asc > key.jks
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/[email protected]
with:
channel: 'stable'
architecture: x64
- name: Update dependencies
run: flutter pub get
# This is to give an offset since builds before this repo were in the 100's
- name: Generate run number with offset
env:
NUM: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($NUM + 200))" >> $GITHUB_ENV
- name: Generate app build name
shell: bash
run: echo "##[set-output name=name;]$(echo sweet_$BUILD_NUMBER)"
id: app_build
- name: Building ${{ steps.app_build.outputs.name }}.aab
run: flutter build appbundle --build-number $BUILD_NUMBER --release
- name: Setup Ruby
uses: ruby/[email protected]
with:
bundler-cache: true
- name: Upload to Play Store
run: |
bundle install --jobs 4 --retry 3
bundle exec fastlane android upload_playstore
env:
SWEET_JSON_KEY_DATA: ${{ secrets.SWEET_JSON_KEY_DATA }}
AAB_PATH: build/app/outputs/bundle/release/app-release.aab
upload-release-s3:
needs: [job-linux, job-apple, job-windows]
runs-on: ubuntu-latest
steps:
# This is to give an offset since builds before this repo were in the 100's
- name: Generate run number with offset
env:
NUM: ${{ github.run_number }}
run: |
echo "BUILD_NUMBER=$(($NUM + 200))" >> $GITHUB_ENV
- name: Generate app build name
shell: bash
run: echo "##[set-output name=name;]$(echo sweet_$BUILD_NUMBER)"
id: app_build
- name: 'Download Linux artifact'
uses: actions/[email protected]
with:
name: ${{ steps.app_build.outputs.name }}-linux
- name: 'Download MacOS artifact'
uses: actions/[email protected]
with:
name: ${{ steps.app_build.outputs.name }}-macos
- name: 'Download Windows artifact'
uses: actions/[email protected]
with:
name: ${{ steps.app_build.outputs.name }}-windows
- name: Upload Windows releases to S3
uses: a-sync/[email protected]
env:
AWS_REGION: 'us-west-1'
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FILE: './${{ steps.app_build.outputs.name }}-windows.zip'
S3_KEY: '/releases/${{ steps.app_build.outputs.name }}-windows.zip'
- name: Upload MacOS releases to S3
uses: a-sync/[email protected]
env:
AWS_REGION: 'us-west-1'
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FILE: './${{ steps.app_build.outputs.name }}-macos.zip'
S3_KEY: '/releases/${{ steps.app_build.outputs.name }}-macos.zip'
- name: Upload Linux releases to S3
uses: a-sync/[email protected]
env:
AWS_REGION: 'us-west-1'
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FILE: './${{ steps.app_build.outputs.name }}-linux.zip'
S3_KEY: '/releases/${{ steps.app_build.outputs.name }}-linux.zip'