-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
56 lines (43 loc) · 1.88 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
56 lines (43 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
image: ubuntu:latest
stages:
- release
# --- CREATE THE RELEASE ---
create_release:
stage: release
rules:
# Only run this job when a tag is pushed to the main branch
- if: '$CI_COMMIT_TAG'
before_script:
# Install dependencies
- apt-get update -y && apt-get install -y jq gettext libglib2.0-dev zip python3 curl git
# Install GitLab Release CLI
- curl --location --output /usr/local/bin/release-cli "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages/generic/release-cli/latest/release-cli-linux-amd64"
- chmod +x /usr/local/bin/release-cli
script: |
# Prepare Variables
export RELEASE_VERSION="${CI_COMMIT_TAG#v}"
export RELEASE_TITLE="Version $RELEASE_VERSION"
# Get the commit message for the description
export RELEASE_DESCRIPTION=$(git log -1 --format=%B)
# Build the package
./build.sh package
# Define Asset Name
export ASSET_NAME=$(jq -r '.uuid' gnome-extensions/extension/metadata.json).zip
# Define the Package Registry URL
export PACKAGE_REGISTRY_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${RELEASE_VERSION}/${ASSET_NAME}"
# Upload the ZIP file to GitLab Package Registry
echo "Uploading ${ASSET_NAME}..."
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${ASSET_NAME}" "${PACKAGE_REGISTRY_URL}"
# Prepare Safe Filepath
SAFE_FILEPATH="/$(echo "$ASSET_NAME" | sed 's/@/-/g')"
# Prepare Assets Link JSON
ASSETS_LINK_JSON=$(jq -n \
--arg name "$ASSET_NAME" \
--arg url "$PACKAGE_REGISTRY_URL" \
--arg filepath "$SAFE_FILEPATH" \
'{"name": $name, "url": $url, "filepath": $filepath}')
# Create the Release
echo "Creating release..."
release-cli create --name "$RELEASE_TITLE" --tag-name "$CI_COMMIT_TAG" \
--description "$RELEASE_DESCRIPTION" \
--assets-link "$ASSETS_LINK_JSON"