Skip to content

Instantly share code, notes, and snippets.

@vinicioslc
Last active April 19, 2024 15:52
Show Gist options
  • Star 43 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save vinicioslc/b9bd073c8013a726033a999db68a45be to your computer and use it in GitHub Desktop.
Save vinicioslc/b9bd073c8013a726033a999db68a45be to your computer and use it in GitHub Desktop.
Build flutter releases in github actions for production only android for while.
# This is a basic workflow to help you get started with Actions
name: CD Internal-Lane
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
tags:
- "internal-v*.*.*" # on every version tag will build a new android artifact example: v3.1.2+6
jobs:
build:
name: Build Artifacts and Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: "12.x"
- name: Setup Flutter
uses: subosito/flutter-action@v1
with:
flutter-version: "1.17.5"
- name: Decode android/neumodore_key.jks
run: echo "${{ secrets.KEYSTORE_JKS_PROD }}" | base64 --decode > android/keystore.jks
- name: Decode android/key.properties
run: echo "${{ secrets.KEY_PROPERTIES_PROD }}" | base64 --decode > android/key.properties
- uses: olegtarasov/get-tag@v2 # that generate $GIT_TAG_NAME env
id: tagName
with:
tagRegex: 'internal-v([0-9]+.[0-9]+.[0-9]+\+[0-9]+)' # Optional. Returns specified group text as tag name. Full tag string is returned if regex is not defined.
tagRegexGroup: 1 # Optional. Default is 1.
- name: Replace YAML version with tag version
run: |
sed -i 's/99.99.99+99/'$GIT_TAG_NAME'/g' pubspec.yaml|
echo "Tag used version:"$GIT_TAG_NAME
- name: Pub Get Packages
run: flutter pub get
- name: Build APPBUNDLE
run: flutter build appbundle --release
- name: Create Github Release
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/bundle/release/*.aab"
token: ${{ secrets.PERSONAL_RELEASE_TOKEN }}
- name: Save APPBUNDLE to Artifacts
uses: actions/upload-artifact@v2
with:
name: APPBUNDLE
path: build/app/outputs/bundle/release/app-release.aab
release_internal:
name: Release Artifacts to internal track
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get APPBUNDLE from Artifacts
uses: actions/download-artifact@v2
with:
name: APPBUNDLE
- name: Release APPBUNDLE to internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_JSONKEY }}
packageName: com.example.app
releaseFile: app-release.aab
track: internal
whatsNewDirectory: distribution/whatsnew
@Warns
Copy link

Warns commented Feb 3, 2021

@vinicioslc Thanks for sharing, this is quite helpful

@vinicioslc
Copy link
Author

@vinicioslc Thanks for sharing, this is quite helpful

๐Ÿ‘€ thanks

@ariefwijaya
Copy link

ariefwijaya commented Jun 17, 2021

How if we want to build to iOS and upload them to firebase distribution?

@TafadzwaD
Copy link

Thanks for this jewel. For it to work I have to commit my keystore file to github as well??

@GerardoHP
Copy link

Hey man grat work, how can I store a jks file into a secret? Should I convert the file into a string through gpg?

@vinicioslc
Copy link
Author

Hey man grat work, how can I store a jks file into a secret? Should I convert the file into a string through gpg?

you need encode the entire file as base64 save the content to your repository secrets and it will be written before build process to .jks location in step "Decode android/neumodore_key.jks"

@vinicioslc
Copy link
Author

Thanks for this jewel. For it to work I have to commit my keystore file to github as well??

No you will encode to base64 and save it to your repository secrets as mentioned on file step "Decode android/neumodore_key.jks"

@vinicioslc
Copy link
Author

vinicioslc commented Jul 12, 2021

if someone wants send coffee

ko-fi

@TafadzwaD
Copy link

TafadzwaD commented Jul 12, 2021 via email

@vinicioslc
Copy link
Author

vinicioslc commented Jul 12, 2021

Off course I added it

@TafadzwaD
Copy link

TafadzwaD commented Jul 12, 2021 via email

@vinicioslc
Copy link
Author

omg i didn't expect this, thanks a lot!

@TafadzwaD
Copy link

TafadzwaD commented Jul 12, 2021 via email

@TafadzwaD
Copy link

@vinicioslc Let us do it one more time.. This time with PayPal. Drop me your PayPal address. To keep you hanging just know that you will receive it before Christmas..๐Ÿ˜…๐Ÿ˜….

Just showing appreciation for this gist once again..lol. And I will continue doing so from time to time.

@TafadzwaD
Copy link

@vinicioslc Yes I am serious ๐Ÿ˜ƒ. Is there a way you can change the currency to United States Dollar for me on that donation link? I want to avoid exchange rate hassles..lol. I will send as USD then you do what you do.

You can consider it a Christmas present..lol

@vinicioslc
Copy link
Author

@TafadzwaD Sorry, paypal only accepts BRL on this link because the bank account is in my country however there is an alternative.
https://ko-fi.com/vinicioslc
You can submit through the Ko-Fi platform they accept Paypal in USD, which does not charge taxes or take percentages.
You can also leave a Christmas message ehehe ๐Ÿคฉ

@TafadzwaD
Copy link

TafadzwaD commented Dec 1, 2021 via email

@joshpetit
Copy link

joshpetit commented Sep 27, 2022

      - name: Decode android/neumodore_key.jks
        run: echo "${{ secrets.KEYSTORE_JKS_PROD }}" | base64 --decode > android/keystore.jks

      - name: Decode android/key.properties
        run: echo "${{ secrets.KEY_PROPERTIES_PROD }}" | base64 --decode > android/key.properties

Just to make sure this is only required if you don't version control your release keys right?

@vinicioslc
Copy link
Author

@joshpetit yes and are recommended that you don't version control your release keys.

@joshpetit
Copy link

@joshpetit yes and are recommended that you don't version control your release keys.

Oh really? Even for a private repository?

@TafadzwaD
Copy link

@joshpetit Yes it's not recommended even in a private repository.

@vinicioslc
Copy link
Author

vinicioslc commented Sep 27, 2022

@joshpetit
Yes, yes because if the attacker gets access to the repository, once time that it reach here, will get access to the entire publishing workflow, allowing it to scale this attack.

But if its only for test purposes i don't see any problems, like an unimportant app.

@joshpetit Yes it's not recommended even in a private repository.

nice

@joshpetit
Copy link

Oh interesting that makes sense. Thanks!

@TafadzwaD
Copy link

@vinicioslc I haven't forgotten our Christmas tradition.. Anytime your Ko-Fi account will shake๐Ÿ˜‚๐Ÿ˜‚..

@vinicioslc
Copy link
Author

Oh @TafadzwaD thanks dude! I haven't forgotten you <3, you are the best!

@AristideVB
Copy link

Hi @vinicioslc I would also greatly appreciate participating in this Christmas tradition ๐Ÿ˜„ do you think you could make this workflow up to date ?

@TafadzwaD
Copy link

@vinicioslc Sorry the Christmas gift came late๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚. Check your Kofi account!! Better late than never.

@vinicioslc
Copy link
Author

@vinicioslc Sorry the Christmas gift came late๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚. Check your Kofi account!! Better late than never.

I have just replied on ko-fi man ! please see here you are the best!

@TafadzwaD
Copy link

Thanks man!

@mahdi-safdari
Copy link

@TafadzwaD
Hi man, how are you?
I am a Flutter programmer looking for a job. Can I cooperate with you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment