Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit fe2edaf

Browse files
bors[bot]holzeis
andauthored
Merge #152
152: Release apk r=holzeis a=holzeis Adds the principle release workflow from ItchySats. - Draft release to create a new PR with an updated version in the pubspec (version needs to be provided manually) and change log. - Generate launcher icons for macos, windows, ios and android using flutter_launcher_icons - Build, sign and upload android apk to the job outputs before the actual release will be triggered. - Create a release from the merged release PR using https://github.com/ncipollo/release-action For the git actions I generated a personal GITHUB TOKEN, which we should exchange with a bot user. see example release here - https://github.com/holzeis/10101/releases/tag/0.1.1 resolves #128 Co-authored-by: Richard Holzeis <richard@holzeis.me>
2 parents 73f36a4 + 362fb27 commit fe2edaf

37 files changed

+292
-5
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: "Create release"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
env:
9+
FLUTTER_VERSION: "3.3.1"
10+
11+
jobs:
12+
build:
13+
runs-on: macos-latest
14+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
15+
outputs:
16+
ANDROID_APK_NAME: ${{ steps.build.outputs.ANDROID_APK_NAME }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
# #499, https://github.com/actions/virtual-environments/issues/5595
21+
- name: Configure ndk
22+
run: |
23+
ANDROID_HOME=$HOME/Library/Android/sdk
24+
SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
25+
26+
echo y | $SDKMANAGER "ndk;21.4.7075529"
27+
28+
ln -sfn $ANDROID_HOME/ndk/21.4.7075529 $ANDROID_HOME/ndk-bundle
29+
30+
- uses: actions/setup-java@v3
31+
with:
32+
distribution: "temurin"
33+
java-version: "8.x" # "betterprogramming.pub" says must be java "8"
34+
cache: "gradle"
35+
36+
- uses: subosito/flutter-action@v2
37+
with:
38+
channel: "stable"
39+
flutter-version: ${{ env.FLUTTER_VERSION }}
40+
architecture: x64
41+
42+
- uses: actions/cache@v3
43+
id: cache-deps
44+
with:
45+
path: |
46+
~/.cargo/bin/
47+
~/.cargo/registry/index/
48+
~/.cargo/registry/cache/
49+
~/.cargo/git/db/
50+
./rust/target
51+
key: ${{ runner.os }}-cargo-integrate-android-${{ hashFiles('**/Cargo.lock') }}-${{ steps.checkout.outputs.rustc_hash }}
52+
53+
- name: Install FFI bindings
54+
if: steps.cache-deps.outputs.cache-hit != 'true'
55+
run: cargo install flutter_rust_bridge_codegen
56+
57+
- name: Generate FFI bindings
58+
run: make gen
59+
60+
- name: Add Rust targets
61+
run: rustup target add armv7-linux-androideabi aarch64-linux-android
62+
63+
- name: Install `cargo-ndk`
64+
if: steps.cache-deps.outputs.cache-hit != 'true'
65+
run: cargo install cargo-ndk --force
66+
67+
- name: Build Rust lib
68+
working-directory: ./rust
69+
run: cargo ndk -o ../android/app/src/main/jniLibs build
70+
71+
- name: Parse version from pubspec.yaml
72+
id: version
73+
uses: jbutcher5/read-yaml@1.6
74+
with:
75+
file: "pubspec.yaml"
76+
key-path: '["version"]'
77+
78+
- name: Build Android APK release
79+
id: build
80+
run: |
81+
mkdir keystore
82+
echo $ENCODED_KEYSTORE | base64 -d > keystore/upload-keystore.jks
83+
BUILD_NAME=${{ steps.version.outputs.data }}
84+
BUILD_NUMBER=$(git rev-list HEAD --count)
85+
flutter build apk --build-name=$BUILD_NAME --build-number=$BUILD_NUMBER --release
86+
mv build/app/outputs/flutter-apk/app.apk build/app/outputs/flutter-apk/tentenone-$BUILD_NAME.apk
87+
echo "ANDROID_APK_NAME=$(echo tentenone-$BUILD_NAME.apk)" >> $GITHUB_OUTPUT
88+
env:
89+
SIGNING_KEY_ALIAS: ${{ secrets.ANDROID_UPLOAD_SIGNING_KEY_ALIAS }}
90+
SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_UPLOAD_SIGNING_KEY_PASSWORD }}
91+
SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_UPLOAD_SIGNING_STORE_PASSWORD }}
92+
ENCODED_KEYSTORE: ${{ secrets.ANDROID_UPLOAD_KEYSTORE }}
93+
94+
- name: Upload APK to job
95+
uses: actions/upload-artifact@v3
96+
with:
97+
name: ${{steps.build.outputs.ANDROID_APK_NAME}}
98+
path: build/app/outputs/flutter-apk/${{steps.build.outputs.ANDROID_APK_NAME}}
99+
100+
release:
101+
needs: build
102+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v3
106+
107+
- name: Extract version from branch name
108+
id: extract-version
109+
shell: python
110+
run: |
111+
branch_name = "${{ github.event.pull_request.head.ref }}"
112+
version = branch_name.split("/")[1]
113+
114+
print(f"::set-output name=version::{version}")
115+
116+
- name: Extract changelog section for release
117+
id: changelog
118+
uses: coditory/changelog-parser@v1
119+
with:
120+
version: ${{ steps.extract-version.outputs.version }}
121+
122+
- uses: actions/download-artifact@v3
123+
with:
124+
name: ${{ needs.build.outputs.ANDROID_APK_NAME }}
125+
126+
- name: Create release
127+
uses: ncipollo/release-action@v1
128+
with:
129+
artifacts: ${{ needs.build.outputs.ANDROID_APK_NAME }}
130+
body: ${{ steps.changelog.outputs.description }}
131+
token: ${{ secrets.TENTENONE_GITHUB_TOKEN }}
132+
tag: ${{ steps.extract-version.outputs.version }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: "Draft new release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "The new version in X.Y.Z format."
8+
required: true
9+
10+
jobs:
11+
draft-new-release:
12+
name: "Draft a new release"
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
env:
18+
RELEASE_BRANCH: release/${{ github.event.inputs.version }}
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
token: ${{ secrets.ITCHY_GITHUB_TOKEN }}
23+
24+
- name: Create release branch
25+
run: git checkout -b ${{ env.RELEASE_BRANCH }}
26+
27+
- name: Initialize mandatory git config
28+
run: |
29+
git config user.name "${{ secrets.ITCHY_NAME }}"
30+
git config user.email ${{ secrets.ITCHY_EMAIL }}
31+
32+
- name: Update changelog
33+
uses: thomaseizinger/keep-a-changelog-new-release@v1
34+
with:
35+
version: ${{ github.event.inputs.version }}
36+
37+
- name: Bump pubspec version
38+
uses: fjogeleit/yaml-update-action@v0.11.1
39+
with:
40+
valueFile: "pubspec.yaml"
41+
propertyPath: "version"
42+
value: ${{ github.event.inputs.version }}
43+
commitChange: false
44+
updateFile: true
45+
46+
- name: Commit changelog and manifest files
47+
id: make-commit
48+
run: |
49+
curl -fsSL https://dprint.dev/install.sh | sh
50+
/home/runner/.dprint/bin/dprint fmt
51+
52+
git add CHANGELOG.md pubspec.yaml
53+
git commit --message "Prepare release ${{ github.event.inputs.version }}"
54+
55+
echo "::set-output name=commit::$(git rev-parse HEAD)"
56+
57+
- name: Create pull request
58+
run: |
59+
# Force push to allow for easier re-runs of the action
60+
git push origin ${{ env.RELEASE_BRANCH }} --force
61+
# Use heredoc to define multiline string: https://stackoverflow.com/a/23930212/2489334
62+
BODY=$(cat <<-EOF
63+
Hi @${{ github.actor }}!
64+
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
65+
I've bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
66+
Merging this PR will create a GitHub release!
67+
EOF
68+
)
69+
gh pr create \
70+
--reviewer ${{ github.actor }} \
71+
--title "Release version ${{ github.event.inputs.version }}" \
72+
--head ${{ env.RELEASE_BRANCH }} \
73+
--body "$BODY"
74+
env:
75+
# Using a bot account is important to trigger subsequent workflows.
76+
# See https://devopsdirective.com/posts/2020/07/stupid-github-actions/#2----recursive-action.
77+
GITHUB_TOKEN: ${{ secrets.TENTENONE_GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
bridge_generated.h
1010
**/bridge_generated/
1111
!/rust/src/bridge_generated/mod.rs
12+
13+
// ignore keystores
14+
*.jks

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Initial flutter and flutter rust bridge project setup
13+
- BIP84 wallet derived from a BIP39 seed phrase
14+
- Dashboard view
15+
- Backup seed view
16+
- Mocked CFD trading view

android/app/build.gradle

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ apply plugin: 'com.android.application'
2525
apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

28+
def keystoreProperties = new Properties()
29+
def keystorePropertiesFile = rootProject.file('key.properties')
30+
def local = false;
31+
if (keystorePropertiesFile.exists()) {
32+
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
33+
local = true;
34+
}
35+
2836
android {
2937
compileSdkVersion 31
3038

@@ -50,10 +58,25 @@ android {
5058
versionName flutterVersionName
5159
}
5260

61+
signingConfigs {
62+
release {
63+
storeFile = file("../../keystore/upload-keystore.jks")
64+
storePassword System.getenv("SIGNING_STORE_PASSWORD")
65+
keyAlias System.getenv("SIGNING_KEY_ALIAS")
66+
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
67+
}
68+
debug {
69+
keyAlias keystoreProperties['keyAlias']
70+
keyPassword keystoreProperties['keyPassword']
71+
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
72+
storePassword keystoreProperties['storePassword']
73+
}
74+
}
5375
buildTypes {
5476
release {
55-
// TODO: Add your own signing config for the release build.
56-
// Signing with the debug keys for now, so `flutter run --release` works.
77+
signingConfig signingConfigs.release
78+
}
79+
debug {
5780
signingConfig signingConfigs.debug
5881
}
5982
}

android/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:tools="http://schemas.android.com/tools"
33
package="com.example.frb_example">
4+
5+
<uses-permission
6+
android:name="android.permission.INTERNET" />
7+
48
<!-- NOTE extractNativeLibs is optional; only to have a better backtrace in debug mode. https://github.com/rust-lang/backtrace-rs/issues/442#issuecomment-942279097 -->
59
<application
6-
android:label="frb_example"
10+
android:label="10101"
711
android:icon="@mipmap/ic_launcher"
812
tools:replace="android:extractNativeLibs"
913
android:extractNativeLibs="true">
817 Bytes
Loading
549 Bytes
Loading
898 Bytes
Loading
952 Bytes
Loading

0 commit comments

Comments
 (0)