Skip to content

Instantly share code, notes, and snippets.

@DennisAlund
Created June 11, 2017 09:49
Show Gist options
  • Select an option

  • Save DennisAlund/d42fda18b1415d23bf39a27f12d0f4bc to your computer and use it in GitHub Desktop.

Select an option

Save DennisAlund/d42fda18b1415d23bf39a27f12d0f4bc to your computer and use it in GitHub Desktop.
Gitlab CI script for Medium article: https://medium.com/evenbit/e51aba6ba53e
.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