mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-27 22:38:50 +05:00
74 lines
1.9 KiB
YAML
74 lines
1.9 KiB
YAML
stages:
|
|
- build
|
|
- deploy
|
|
|
|
build:apk:
|
|
stage: build
|
|
image: cirrusci/flutter:latest
|
|
script:
|
|
- flutter build apk --release
|
|
artifacts:
|
|
paths:
|
|
- build/app/outputs/flutter-apk/*.apk
|
|
expire_in: 30 days
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: always
|
|
- if: $CI_COMMIT_BRANCH =~ /^dev|main/
|
|
when: on_success
|
|
|
|
deploy:release:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
needs:
|
|
- build:apk
|
|
before_script:
|
|
- apk add --no-cache curl jq
|
|
script:
|
|
- |
|
|
VERSION="${CI_COMMIT_TAG:-v0.0.${CI_PIPELINE_ID}}"
|
|
APK_FILE=$(ls build/app/outputs/flutter-apk/*.apk | head -n1)
|
|
if [ -z "$APK_FILE" ]; then
|
|
echo "No APK found!"
|
|
exit 1
|
|
fi
|
|
|
|
DESCRIPTION="NeoMovies Mobile ${VERSION}
|
|
|
|
Commit: ${CI_COMMIT_SHORT_SHA}
|
|
Branch: ${CI_COMMIT_BRANCH}
|
|
Pipeline: [#${CI_PIPELINE_ID}](${CI_PIPELINE_URL})
|
|
|
|
APK: \`$(basename $APK_FILE)\`"
|
|
|
|
RELEASE_PAYLOAD=$(cat <<EOF
|
|
{
|
|
"name": "NeoMovies ${VERSION}",
|
|
"tag_name": "${VERSION}",
|
|
"description": "${DESCRIPTION}",
|
|
"ref": "${CI_COMMIT_SHA}"
|
|
}
|
|
EOF
|
|
)
|
|
|
|
curl -s --fail -X POST "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases" \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$RELEASE_PAYLOAD" || \
|
|
curl -s -X PUT "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases/${VERSION}" \
|
|
--header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" \
|
|
--header "Content-Type: application/json" \
|
|
--data "$RELEASE_PAYLOAD"
|
|
|
|
echo "Release created/updated: ${CI_PROJECT_URL}/-/releases/${VERSION}"
|
|
echo "APK artifact: ${CI_JOB_URL}/artifacts/browse"
|
|
|
|
artifacts:
|
|
paths:
|
|
- build/app/outputs/flutter-apk/*.apk
|
|
expire_in: 30 days
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: always
|
|
- if: $CI_COMMIT_BRANCH =~ /^dev|main/
|
|
when: on_success |