-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
91 lines (84 loc) · 2.52 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
91 lines (84 loc) · 2.52 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
stages:
- build
- upload
- publish
- release
default:
image: python:3.12-slim
variables:
PACKAGE_NAME: kyuncli
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}"
GIT_DEPTH: "0"
workflow:
rules:
- if: $CI_COMMIT_TAG =~ /^v.*/
build-wheel:
stage: build
before_script:
- apt-get update -qq && apt-get install -y -qq git
script:
- pip install --quiet build
- python -m build
- VERSION=$(ls dist/*.whl | head -n1 | xargs basename | cut -d'-' -f2)
- echo "VERSION=$VERSION" >> build.env
- ls dist/
artifacts:
paths:
- dist/
reports:
dotenv: build.env
upload-packages:
stage: upload
needs:
- job: build-wheel
artifacts: true
script:
- apt-get update -qq && apt-get install -y -qq curl
- WHL_FILE=$(ls dist/*.whl | head -n1)
- TAR_FILE=$(ls dist/*.tar.gz | head -n1)
- WHL_NAME=$(basename "$WHL_FILE")
- TAR_NAME=$(basename "$TAR_FILE")
- echo "Uploading $WHL_NAME and $TAR_NAME for version $VERSION"
- |
curl --silent --show-error --fail \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file "$WHL_FILE" \
"${PACKAGE_REGISTRY_URL}/${VERSION}/${WHL_NAME}"
- |
curl --silent --show-error --fail \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file "$TAR_FILE" \
"${PACKAGE_REGISTRY_URL}/${VERSION}/${TAR_NAME}"
- echo "WHL_NAME=$WHL_NAME" >> upload.env
- echo "TAR_NAME=$TAR_NAME" >> upload.env
artifacts:
reports:
dotenv: upload.env
publish-pypi:
stage: publish
needs:
- job: build-wheel
artifacts: true
rules:
- if: $CI_COMMIT_TAG =~ /^v.*/ && $PYPI_API_TOKEN
script:
- pip install --quiet twine
- export TWINE_USERNAME=__token__
- export TWINE_PASSWORD="$PYPI_API_TOKEN"
- twine upload --non-interactive dist/*
create-release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: build-wheel
artifacts: true
- job: upload-packages
artifacts: true
script:
- |
release-cli create \
--name "Release ${CI_COMMIT_TAG}" \
--tag-name "${CI_COMMIT_TAG}" \
--description "Release ${CI_COMMIT_TAG} of kyuncli." \
--assets-link "{\"name\":\"${WHL_NAME} (wheel)\",\"url\":\"${PACKAGE_REGISTRY_URL}/${VERSION}/${WHL_NAME}\",\"link_type\":\"package\"}" \
--assets-link "{\"name\":\"${TAR_NAME} (source)\",\"url\":\"${PACKAGE_REGISTRY_URL}/${VERSION}/${TAR_NAME}\",\"link_type\":\"package\"}"