Files
godot-ci/.gitlab-ci.yml
2021-10-06 14:40:01 -03:00

155 lines
4.2 KiB
YAML

image: barichello/godot-ci:3.3.4
# NOTE: the `cd` command in each build stage is not necessary if your
# project.godot is at the repo root
# Cache imported assets between runs
cache:
key: import-assets
paths:
- .import/
stages:
- export
- deploy
variables:
EXPORT_NAME: test-project
linux:
stage: export
script:
- mkdir -v -p build/linux
- cd $EXPORT_NAME
- godot -v --export "Linux/X11" ../build/linux/$EXPORT_NAME.x86_64
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/linux
windows:
stage: export
script:
- mkdir -v -p build/windows
- cd $EXPORT_NAME
- godot -v --export "Windows Desktop" ../build/windows/$EXPORT_NAME.exe
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/windows
mac:
stage: export
script:
- mkdir -v -p build/mac
- cd $EXPORT_NAME
- godot -v --export "Mac OSX" ../build/mac/$EXPORT_NAME.zip
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/mac
web:
stage: export
script:
- mkdir -v -p build/web
- cd $EXPORT_NAME
- godot -v --export "HTML5" ../build/web/index.html
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/web
# Android Debug Job. It will use the generated debug.keystore.
android_debug:
stage: export
script:
- mkdir -v -p build/android
- cd $EXPORT_NAME
- godot -v --export-debug "Android Debug" ../build/android/$EXPORT_NAME-debug.apk
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/android
# Android Release Job. You will need to include keystore and password in the GitLab variable settings:
# 1. Take your generated keystore and convert it to Base64:
# Linux & macOS: `base64 release.keystore -w 0`
# Windows: `certutil -encodehex -f release.keystore encoded.txt 0x40000001`
# 2. Go to GitLab Project > Settings > CI/CD > Variables and copy the Base64-encoded keystore value in a new variable `SECRET_RELEASE_KEYSTORE_BASE64` as type variable.
# 3. Create a second variable SECRET_RELEASE_KEYSTORE_USER as type variable with the alias of your keystore as value.
# 4. Create a third variable SECRET_RELEASE_KEYSTORE_PASSWORD as type variable with the password of your keystore as value.
android:
stage: export
rules:
- if: $SECRET_RELEASE_KEYSTORE_BASE64
- if: $SECRET_RELEASE_KEYSTORE_USER
- if: $SECRET_RELEASE_KEYSTORE_PASSWORD
script:
- echo $SECRET_RELEASE_KEYSTORE_BASE64 | base64 --decode > /root/release.keystore
- mkdir -v -p build/android
- cd $EXPORT_NAME
- sed 's@keystore/release=".*"@keystore/release="'/root/release.keystore'"@g' -i export_presets.cfg
- sed 's@keystore/release_user=".*"@keystore/release_user="'$SECRET_RELEASE_KEYSTORE_USER'"@g' -i export_presets.cfg
- sed 's@keystore/release_password=".*"@keystore/release_password="'$SECRET_RELEASE_KEYSTORE_PASSWORD'"@g' -i export_presets.cfg
- godot -v --export "Android" ../build/android/$EXPORT_NAME.apk
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/android
# GitHub Pages Deploy
deploy-github-pages:
stage: deploy
dependencies:
- web
script:
# This ensures the `gh-pages` branch is available.
- git fetch
- git checkout gh-pages
- rm -f *.md
- mv build/web/** .
- git config user.email $GIT_EMAIL
- git config user.name $GIT_USERNAME
- git remote add github $REMOTE_URL
- git add -A
- 'git commit -m "ci: Deploy GitHub Page | $EXPORT_NAME:$CI_JOB_NAME" -m "Deploy from GitLab pipeline #$CI_PIPELINE_ID" || true'
- git push github gh-pages -f
# GitLab Pages Deploy
pages:
stage: deploy
dependencies:
- web
script:
# This ensures the `pages` branch is available.
- git fetch
- git checkout pages
- rm -f *.md
- mv build/web/** ./public
artifacts:
paths:
- public
# Itch.io Deploy
itchio:linux:
stage: deploy
script:
- butler push ./build/linux $ITCHIO_USERNAME/$ITCHIO_GAME:linux
dependencies:
- linux
itchio:windows:
stage: deploy
script:
- butler push ./build/windows $ITCHIO_USERNAME/$ITCHIO_GAME:windows
dependencies:
- windows
itchio:macosx:
stage: deploy
script:
- butler push ./build/mac $ITCHIO_USERNAME/$ITCHIO_GAME:mac
dependencies:
- mac