Skip to content

Commit

Permalink
Fix github actions flutter signed workflows for versioning flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pratul committed Feb 21, 2023
1 parent 9cb408d commit 4702f06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
33 changes: 2 additions & 31 deletions templates/info/github-flutter-signed
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,9 @@ keyPassword=anotherStrongPassword</pre>
</ul>
</p>

<h3>Reading keystore data in build.gradle</h3>
<h3>Reading signing data during Flutter build</h3>
<p>
Next, must modify your <code>build.gradle</code> file so that Gradle knows it has to read the keystore and associated <code>key.properties</code> data while creating a release build.
</p>
<p>
Add this <i>before</i> the <code>android</code> block of your app's <code>build.gradle</code> file. Note that this is the build file inside the <code>app</code> folder, and not the file in the root of the project.
</p>
<pre>
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}</pre>
<p>
Now, <i>inside</i> the <code>android</code> block, add these two blocks: <code>signingConfig</code> and <code>buildTypes</code>. If you already have either or both of those blocks, just add the <code>release</code> block to your existing block(s).
</p>
<pre>
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}</pre>
<p>
That's all! Now when you run a release build, Gradle knows it has to use the <code>signingConfig.release</code> information, where it will read the storeFile, storePassword, keyAlias, and keyPassword from your <code>key.properties</code> file.
As long as you don't change the location of the files in the generated workflow below, Flutter will automatically pick up the signing configuration and create a valid release build.
</p>
</p>

Expand Down
7 changes: 6 additions & 1 deletion templates/workflows/github-flutter-signed
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ jobs:
{%- when PublishingFormat::Aab %}
{%- let pf = "appbundle" %}
{%- endmatch %}

{% if show_versions -%}
- name: Create the build
run: flutter build {{ pf }} --release {% raw -%}--build-number=${{ github.event.inputs.versionCode }} --build-name=${{ github.event.inputs.versionName }}{%- endraw %}

{% else -%}
- name: Create the build
run: flutter build {{ pf }} --release
{% endif %}
- name: Upload generated build to artifacts
uses: actions/upload-artifact@v3
with:
Expand Down

0 comments on commit 4702f06

Please sign in to comment.