From d1871ccb69c478f4651bf5f8b984052230e3af51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Mon, 13 Jan 2025 09:44:38 +0100 Subject: [PATCH] Split tag and publish CI/CD steps --- .gitlab-ci.yml | 45 +++++++++++++++++++++++++++++++++------------ CHANGELOG.md | 4 ++++ pubspec.yaml | 2 +- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 143ac8a..d9e9a93 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,17 @@ image: ghcr.io/cirruslabs/flutter:latest stages: - - build-debug - - release + - publish-check + - release-tag + - release-publish -android:build-debug: - stage: build-debug +# Check flutter package +package:publish-check: + stage: publish-check except: - tags - master script: - # Check flutter package - VERSION_NAME="$(grep '^version:' pubspec.yaml | cut -d' ' -f2)" - echo "${VERSION_NAME}" - TAG_NAME="${VERSION_NAME}" @@ -24,15 +25,20 @@ android:build-debug: - flutter pub publish --dry-run interruptible: true -application:release: - stage: release +# Create git tag on new release +package:release-tag: + stage: release-tag + image: + name: alpine/git + entrypoint: [""] only: - master except: - tags dependencies: - - android:build-debug + - package:publish-check script: + - apk --no-cache add curl - git config user.email "${GITLAB_USER_EMAIL}" - git config user.name "${GITLAB_USER_NAME}" - git remote set-url origin https://oauth2:${GITLAB_ACCESS_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH} @@ -46,9 +52,24 @@ application:release: else git tag -a "${TAG_NAME}" -m "Release ${VERSION_NAME}" git push origin "${TAG_NAME}" - flutter clean - flutter packages get - echo "${PRIVATE_PACKAGES_REPOSITORY_KEY}" | flutter pub token add https://pub.harrault.fr - flutter pub publish --force curl --silent -d "{\"token\": \"${JABBER_NOTIFICATION_TOKEN}\", \"message\": \"New tag for ${CI_PROJECT_PATH}: ${TAG_NAME}\"}" -H "Content-Type: application/json" -X POST ${JABBER_NOTIFICATION_URL} fi + +# Publish package to private repository +package:release-publish: + stage: release-publish + only: + - master + except: + - tags + dependencies: + - package:release-tag + script: + - echo "${PRIVATE_PACKAGES_REPOSITORY_KEY}" | flutter pub token add https://pub.harrault.fr + - VERSION_NAME="$(grep '^version:' pubspec.yaml | cut -d' ' -f2)" + - echo "${VERSION_NAME}" + - flutter clean + - flutter packages get + - flutter pub publish --force + - > + curl --silent -d "{\"token\": \"${JABBER_NOTIFICATION_TOKEN}\", \"message\": \"New package published for ${CI_PROJECT_PATH}: ${VERSION_NAME}\"}" -H "Content-Type: application/json" -X POST ${JABBER_NOTIFICATION_URL} diff --git a/CHANGELOG.md b/CHANGELOG.md index 077a2e6..bcf9e12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.3 + +- Split tag and publish CI/CD steps, minor CI/CD improvements + ## 1.0.2 - Fix publish to private repository diff --git a/pubspec.yaml b/pubspec.yaml index 6960932..1108353 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: "Flutter custom toolbox for org.benoitharrault.* projects." publish_to: https://pub.harrault.fr/ -version: 1.0.2 +version: 1.0.3 homepage: https://git.harrault.fr/android/flutter-toolbox -- GitLab