Updated workflow #19
This file contains 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: Flutter Release | |
on: | |
push: | |
branches: | |
- main # Trigger on push to main branch, adjust as needed | |
workflow_dispatch: # Allows manual triggering of the workflow | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the private repository code | |
- name: Check out private repository | |
uses: actions/checkout@v3 | |
with: | |
repository: Smart-Bill-Book/smart-bill-book | |
ref: main | |
token: ${{ secrets.RELEASE_TOKEN }} | |
path: private-repo | |
# Step 2: Set up Flutter environment | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
flutter-version: 3.24.3 | |
working-directory: private-repo | |
- name: List files in current directory | |
run: ls -R | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 17 | |
distribution: "temurin" | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 17 | |
distribution: "temurin" | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: flutter pub get | |
working-directory: private-repo | |
# Step 3.5: Running Build Runner | |
- name: Dart Build Runner | |
run: dart pub run build_runner build --delete-conflicting-outputs | |
working-directory: private-repo | |
# Step 4: Build APK and/or iOS artifacts | |
- name: Build Flutter APK | |
run: flutter build apk --release --dart-define-from-file flavors/smart_store/production.json | |
working-directory: private-repo | |
# Step 5: Check out the release repository | |
- name: Check out release repository | |
uses: actions/checkout@v3 | |
with: | |
repository: Smart-Bill-Book/smart-bill-book-release | |
token: ${{ secrets.RELEASE_TOKEN }} | |
path: release-repo | |
# Step 6: Copy build artifacts to release repository | |
- name: Copy APK to release repository | |
run: cp private-repo/build/app/outputs/flutter-apk/app-release.apk release-repo/ | |
# Step 7: Create a new release in the release repository | |
- name: Push APK to releases | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "release-repo/app-release.apk" | |
tag: v0.0.${{ github.run_number }} | |
commit: main | |
replacesArtifacts: false | |
allowUpdates: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.WORKFLOW_RELEASE_TOKEN }} | |
# Step 8: Upload the APK as a release asset | |
- name: Upload APK to Release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: release-repo/app-release.apk | |
asset_name: app-release.apk | |
asset_content_type: application/vnd.android.package-archive |