Skip to content

Commit

Permalink
Merge pull request #1 from fathonidf/staging
Browse files Browse the repository at this point in the history
tutorial 9 staging to main
  • Loading branch information
fathonidf authored Nov 22, 2023
2 parents fc03313 + 6a4128d commit aec0645
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 10 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Pre-Release

# Controls when the workflow will run
on:
# Triggers the workflow on pull request events but only for the main branch
pull_request:
branches: [main]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "Build and Pre-Release APK"
releases:
name: Build and Pre-Release APK
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Get packages
run: flutter pub get

- name: Generate Java keystore
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
run: echo "$KEY_JKS" | base64 --decode > release-keystore.jks

- name: Build APK
env:
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: flutter build apk --split-per-abi

- name: Pre-release APK by uploading it to Artifacts
uses: actions/upload-artifact@v3
with:
name: APKS
path: build/app/outputs/flutter-apk/*.apk
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is a basic workflow to help you get started with Actions
name: Release

# Controls when the workflow will run
on:
# Triggers the workflow on push events but only for the main branch
push:
branches: [main]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "Build and Release APK"
releases:
name: Build and Release APK
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Get version from pubspec.yaml
id: version
run: echo "::set-output name=version::$(grep "version:" pubspec.yaml | cut -c10-)"

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Get packages
run: flutter pub get

- name: Generate Java keystore
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
run: echo "$KEY_JKS" | base64 --decode > release-keystore.jks

- name: Build APK
env:
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: flutter build apk --split-per-abi

- name: Get current date
id: date
run: echo "::set-output name=date::$(TZ='Asia/Jakarta' date +'%A %d-%m-%Y %T WIB')"

- name: Release APK
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "build/app/outputs/flutter-apk/*.apk"
body: "Published at ${{ steps.date.outputs.date }}"
name: "v${{ steps.version.outputs.version }}"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.version }}
37 changes: 37 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Staging

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [staging]
pull_request:
branches: [staging]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
name: Analyze
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Get packages
run: flutter pub get

- name: Analyze
run: flutter analyze
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
*.keystore
*.jks
12 changes: 9 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ android {
versionName flutterVersionName
}

signingConfigs {
release {
storeFile file("../../release-keystore.jks")
storePassword = "$System.env.KEY_PASSWORD"
keyAlias = "release"
keyPassword = "$System.env.KEY_PASSWORD"
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: unused_import, prefer_const_constructors

import 'package:flutter/material.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
import 'package:provider/provider.dart';
Expand Down
4 changes: 3 additions & 1 deletion lib/screens/list_product.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: library_private_types_in_public_api, non_constant_identifier_names

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
Expand All @@ -14,7 +16,7 @@ class ProductPage extends StatefulWidget {

class _ProductPageState extends State<ProductPage> {
Future<List<Product>> fetchProduct() async {
// TODO: Ganti URL dan jangan lupa tambahkan trailing slash (/) di akhir URL!
// Ganti URL dan jangan lupa tambahkan trailing slash (/) di akhir URL!
var url = Uri.parse(
'http://127.0.0.1:8000/json/');
var response = await http.get(
Expand Down
4 changes: 3 additions & 1 deletion lib/screens/login.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: library_private_types_in_public_api, use_build_context_synchronously

import 'package:shopping_list/screens/menu.dart';
import 'package:flutter/material.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
Expand Down Expand Up @@ -66,7 +68,7 @@ class _LoginPageState extends State<LoginPage> {
String password = _passwordController.text;

// Cek kredensial
// TODO: Ganti URL dan jangan lupa tambahkan trailing slash (/) di akhir URL!
// Ganti URL dan jangan lupa tambahkan trailing slash (/) di akhir URL!
// Untuk menyambungkan Android emulator dengan Django pada localhost,
// gunakan URL http://10.0.2.2/
final response = await request.login( //"http://daffa-mohamad-tutorial.pbp.cs.ui.ac.id/auth/login/"
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/shoplist_form.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: use_build_context_synchronously

import 'dart:convert';

import 'package:flutter/material.dart';
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/shop_card.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: prefer_const_constructors, use_build_context_synchronously, unnecessary_string_interpolations

import 'package:flutter/material.dart';
import 'package:pbp_django_auth/pbp_django_auth.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -40,7 +42,7 @@ class ShopCard extends StatelessWidget {

else if (item.name == "Logout") {
final response = await request.logout(
// TODO: Ganti URL dan jangan lupa tambahkan trailing slash (/) di akhir URL!
// Ganti URL dan jangan lupa tambahkan trailing slash (/) di akhir URL!
// "http://daffa-mohamad-tutorial.pbp.cs.ui.ac.id/auth/logout/"
"http://127.0.0.1:8000/auth/logout/");
String message = response["message"];
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ packages:
dependency: transitive
description:
name: plugin_platform_interface
sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
url: "https://pub.dev"
source: hosted
version: "2.1.6"
version: "2.1.7"
provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -353,10 +353,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3"
sha256: "7c99c0e1e2fa190b48d25c81ca5e42036d5cac81430ef249027d97b0935c553f"
url: "https://pub.dev"
source: hosted
version: "5.0.9"
version: "5.1.0"
xdg_directories:
dependency: transitive
description:
Expand Down

0 comments on commit aec0645

Please sign in to comment.