Created
June 11, 2017 09:49
-
-
Save DennisAlund/d42fda18b1415d23bf39a27f12d0f4bc to your computer and use it in GitHub Desktop.
Gitlab CI script for Medium article: https://medium.com/evenbit/e51aba6ba53e
This file contains hidden or 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
| .package_template: &package_template_def | |
| before_script: | |
| - export VERSION_NAME=`egrep '^[[:blank:]]+versionName[[:blank:]]' app/build.gradle | awk '{print $2}' | sed s/\"//g` | |
| - export VERSION_CODE=`egrep '^[[:blank:]]+versionCode[[:blank:]]' app/build.gradle | awk '{print $2}'` | |
| - mkdir -p deliverables | |
| # Store some information about the build | |
| - touch ./deliverables/info.txt | |
| - echo "Build date $(date)" >> ./deliverables/info.txt | |
| - echo "App version name ${VERSION_NAME}" >> ./deliverables/info.txt | |
| - echo "App version code ${VERSION_CODE}" >> ./deliverables/info.txt | |
| - echo "Git branch ${CI_COMMIT_REF_NAME}" >> ./deliverables/info.txt | |
| - echo "Git commit ${CI_COMMIT_SHA}" >> ./deliverables/info.txt | |
| - echo "Gitlab pipeline ${CI_PIPELINE_ID}" >> ./deliverables/info.txt | |
| package_develop: | |
| <<: *package_template_def | |
| stage: package | |
| environment: Development | |
| only: | |
| - develop | |
| script: | |
| - mv app/build/outputs/apk/app-debug.apk ./deliverables/NameOfTheApp-v$VERSION_NAME-$VERSION_CODE-debug.apk | |
| artifacts: | |
| expire_in: 3 days | |
| paths: | |
| - deliverables | |
| package_release: | |
| <<: *package_template_def | |
| stage: package | |
| environment: Release | |
| only: | |
| - master | |
| script: | |
| - mv app/build/outputs/apk/app-release.apk ./deliverables/NameOfTheApp-v$VERSION_NAME-$VERSION_CODE-release.apk | |
| artifacts: | |
| expire_in: 4 weeks | |
| paths: | |
| - deliverables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment