[neon/snap-packaging/kcalc-snap/release.beta] debian: test publishing for neon-core snaps
Carlos De Maine
null at kde.org
Wed Nov 27 03:08:20 GMT 2024
Git commit 71c0648e3fb726c44571c5f239258888fae49213 by Carlos De Maine.
Committed on 27/11/2024 at 03:08.
Pushed by carlosdem into branch 'release.beta'.
test publishing for neon-core snaps
M +8 -3 debian/.gitlab-ci-neon.yml
A +47 -0 debian/snap-base-proto.yml
A +103 -0 debian/snap-snapcraft-core-lxd-proto.yml
https://invent.kde.org/neon/snap-packaging/kcalc-snap/-/commit/71c0648e3fb726c44571c5f239258888fae49213
diff --git a/debian/.gitlab-ci-neon.yml b/debian/.gitlab-ci-neon.yml
index e5daaa5..509f7cc 100644
--- a/debian/.gitlab-ci-neon.yml
+++ b/debian/.gitlab-ci-neon.yml
@@ -1,7 +1,12 @@
-# SPDX-FileCopyrightText: None
+# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: CC0-1.0
+#include:
+# - project: sysadmin/ci-utilities
+# file:
+# - /gitlab-templates/snap-snapcraft-destructive.yml
+# - /gitlab-templates/snap-snapcraft-lxd.yml
include:
- project: sysadmin/ci-utilities
- file:
- - /gitlab-templates/snap-snapcraft-lxd.yml
+ - local: debian/snap-snapcraft-core-lxd-proto.yml
+ - local: debian/snap-base-proto.yml
diff --git a/debian/snap-base-proto.yml b/debian/snap-base-proto.yml
new file mode 100644
index 0000000..050306d
--- /dev/null
+++ b/debian/snap-base-proto.yml
@@ -0,0 +1,47 @@
+.snap_base:
+ stage: deploy
+ tags:
+ - Snap
+ variables:
+ KDE_SNAP_MODULE_NAME: ${CI_PROJECT_NAME}
+ KDE_SNAP_BRANCH: ${CI_COMMIT_REF_NAME}
+ SNAPCRAFT_BUILD_ENVIRONMENT: "lxd"
+ SNAPCRAFT_MANAGED_MODE: "y"
+ interruptible: true
+ before_script:
+ - git clone https://invent.kde.org/sysadmin/ci-utilities.git --depth=1
+ - git clone https://invent.kde.org/sysadmin/repo-metadata.git ci-utilities/repo-metadata/ --depth=1
+ script:
+ - git config --global --add safe.directory $CI_PROJECT_DIR
+ artifacts:
+ name: Snap deploy artifacts
+ expose_as: 'KDE neon snaps deploying artifacts'
+ when: always
+ paths:
+ - "kde-ci-packages/"
+ - "task.log"
+ - "task-debug.log"
+ - "deploy.env"
+ expire_in: 7 days
+
+.snap_publish:
+ stage: publish
+ tags:
+ - Snap
+ rules:
+ # run the job on mainline branches of mainline repositories
+ - if: $KDECI_SECURE_SERVICES_KEY
+ when: on_success
+ # or when triggered manually we don't want the manual job to block the pipeline
+ - when: manual
+ allow_failure: true
+ variables:
+ GIT_STRATEGY: none
+ interruptible: true
+ artifacts:
+ name: Snap publish artifacts
+ expose_as: 'KDE neon snaps publishing artifacts'
+ when: always
+ paths:
+ - "publish.log"
+ expire_in: 7 days
diff --git a/debian/snap-snapcraft-core-lxd-proto.yml b/debian/snap-snapcraft-core-lxd-proto.yml
new file mode 100644
index 0000000..7ab6882
--- /dev/null
+++ b/debian/snap-snapcraft-core-lxd-proto.yml
@@ -0,0 +1,103 @@
+include:
+ #- /gitlab-templates/blocks/snap-base.yml
+ - /gitlab-templates/blocks/workflow.yml
+
+snap_snapcraft_core_lxd:
+ extends: .snap_base
+ stage: deploy
+ inherit:
+ default: true
+ before_script:
+ # double check lxd instances that can pollute subsequent rebuilds in the persistent vm have been cleaned up
+ # being snapcraft, of course different builds are in different projects, work around that with an if else ...
+ - |
+ if [ "$SNAP_BUILD_TYPE" == "legacy" ]; then
+ # firstly remove any snapcraft-created LXD containers
+ for c in $(lxc storage info default | awk '{print $2}' | grep snapcraft-);
+ do lxc delete --force $c
+ done
+ # then remove any snapcraft-created LXD base-instances
+ for d in $(lxc storage info default | awk '{print $2}' | grep base-instance-snapcraft-);
+ do lxc delete --force $d
+ done
+ else
+ # firstly remove any snapcraft-created LXD containers
+ for c in $(lxc storage info default | awk '{print $2}' | grep snapcraft-);
+ do lxc delete --force $c --project snapcraft
+ done
+ # then remove any snapcraft-created LXD base-instances
+ for d in $(lxc storage info default | awk '{print $2}' | grep base-instance-snapcraft-);
+ do lxc delete --force $d --project snapcraft
+ done
+ fi
+ script:
+ # clean
+ - snapcraft clean
+ # Force usage of LXD for building Snaps
+ - echo building $KDE_SNAP_MODULE_NAME with LXD...
+ - snapcraft --use-lxd --verbose 2>&1 | tee task.log
+ # Make the artifacts dir
+ - mkdir -p $CI_PROJECT_DIR/kde-ci-packages/
+ # copy the snap to the artifacts dir
+ - cp -vf ./*.snap $CI_PROJECT_DIR/kde-ci-packages/
+ - echo $KDE_SNAP_BRANCH >> deploy.env
+ after_script:
+ # clean up lxd instances that can pollute subsequent rebuilds in the persistent vm
+ # being snapcraft, of course different builds are in different projects, work around that with an if else ...
+ - |
+ if [ "$SNAP_BUILD_TYPE" == "legacy" ]; then
+ # firstly remove any snapcraft-created LXD containers
+ for c in $(lxc storage info default | awk '{print $2}' | grep snapcraft-);
+ do lxc delete --force $c
+ done
+ # then remove any snapcraft-created LXD base-instances
+ for d in $(lxc storage info default | awk '{print $2}' | grep base-instance-snapcraft-);
+ do lxc delete --force $d
+ done
+ else
+ # firstly remove any snapcraft-created LXD containers
+ for c in $(lxc storage info default | awk '{print $2}' | grep snapcraft-);
+ do lxc delete --force $c --project snapcraft
+ done
+ # then remove any snapcraft-created LXD base-instances
+ for d in $(lxc storage info default | awk '{print $2}' | grep base-instance-snapcraft-);
+ do lxc delete --force $d --project snapcraft
+ done
+ fi
+ allow_failure: true
+ interruptible: true
+
+snap_snapcraft_core_publish:
+ extends: .snap_publish
+ stage: publish
+ needs: [snap_snapcraft_core_lxd]
+ script:
+ - export KDE_SNAP_BRANCH=$(cat deploy.env)
+ - |
+ # set the channel for the snap dependent on which branch we are building
+ # master = edge
+ if [ "$KDE_SNAP_BRANCH" == "master" ]; then
+ export KDE_SNAP_CHANNEL="edge"
+ # release.beta = beta
+ elif [ "$KDE_SNAP_BRANCH" == "release.beta/" ]; then
+ export KDE_SNAP_CHANNEL="beta"
+ # release.candidate = candidate
+ elif [ "$KDE_SNAP_BRANCH" == "release.candidate" ]; then
+ export KDE_SNAP_CHANNEL="candidate"
+ # release.stable = stable
+ elif [ "$KDE_SNAP_BRANCH" == "release.stable" ]; then
+ export KDE_SNAP_CHANNEL="stable"
+ # don't publish work branches
+ export KDE_SNAP_CHANNEL="no_publish"
+ echo "we don't publish work branches to the snap store, you can download your snap from this jobs artifacts"
+ else
+ # don't publish anything else either
+ export KDE_SNAP_CHANNEL="no_publish"
+ echo "we only publish recognised branches to the snap store"
+ fi
+ if [ "$KDE_SNAP_CHANNEL" != "no_publish" ]
+ echo "KDE_SNAP_BRANCH is $KDE_SNAP_BRANCH thus KDE_SNAP_CHANNEL is publishing to $KDE_SNAP_CHANNEL"
+ snapcraft push --release=$KDE_SNAP_CHANNEL *.snap --verbose 2>&1 | tee publish.log
+ fi
+ allow_failure: true
+ interruptible: true
More information about the Neon-commits
mailing list