-
Notifications
You must be signed in to change notification settings - Fork 63
/
.gitlab-ci.yml
48 lines (42 loc) · 1.53 KB
/
.gitlab-ci.yml
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
image: python:3.10
stages:
- package
- release
pypi-package:
stage: package
only:
- tags
script:
- apt-get update -y && apt-get install -y curl
- curl -sSL https://install.python-poetry.org | python3 -
- export PATH="/root/.local/bin:$PATH"
- poetry build
- poetry publish
.write_permission: &write_permission |
git config --global user.email "gitlab-ci"; git config --global user.name "gitlab-ci"
url_host=`git remote get-url origin | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
git remote set-url origin "https://gitlab-ci-token:${CI_TAG_UPLOAD_TOKEN}@${url_host}"
tag:
stage: release
only:
- main
script:
- *write_permission
- export VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
- git tag -a $VERSION -m "Version created by gitlab-ci release"
- git push origin $VERSION
build_image:
stage: release
image: docker:latest
services:
- docker:dind
only:
- main
script:
- export VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
- export LATEST_IMAGE_TAG=ghcr.io/${GH_REGISTRY_USER}/humblebundle-downloader:latest
- export VERSION_IMAGE_TAG=ghcr.io/${GH_REGISTRY_USER}/humblebundle-downloader:$VERSION
- echo $GH_REGISTRY_PASSWORD | docker login -u $GH_REGISTRY_USER ghcr.io --password-stdin
- docker build -t $LATEST_IMAGE_TAG -t $VERSION_IMAGE_TAG .
- docker push $LATEST_IMAGE_TAG
- docker push $VERSION_IMAGE_TAG