From 4c5c591176807dd1663bedd3fea2419a327a3e6b Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 18 Dec 2020 00:13:00 +0200
Subject: [PATCH] Release via GitLab CI.

---
 .gitlab-ci.yml | 32 +++++++++++++++++++++++++++++++-
 README.rst     |  5 -----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a0ebde8..fe838f1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,6 +2,7 @@
 stages:
   - lint
   - test
+  - release
 
 pre-commit:
   stage: lint
@@ -25,7 +26,7 @@ pre-commit:
 test:
   stage: test
   image: $project:$version-slim
-  before_script:
+  before_script: &before_script
     - apt-get update
     - >-
       apt-get install -y
@@ -66,3 +67,32 @@ test:
           - "2.7"
           - "3.6"
           - "3.7"
+
+upload:
+  stage: release
+  image: python:3.6
+  before_script: *before_script
+  script:
+    - mv pypirc $HOME/.pypirc
+    - pipenv run build
+    - pipenv run upload
+  variables: *variables
+  cache: *cache
+  rules:
+    - if: $CI_COMMIT_TAG
+  artifacts:
+    paths:
+      - dist/*.whl
+
+release:
+  stage: release
+  image: registry.gitlab.com/gitlab-org/release-cli:latest
+  script:
+    - echo GitLab release
+  rules:
+    - if: $CI_COMMIT_TAG
+  release:
+    name: Release $CI_COMMIT_TAG
+    tag_name: $CI_COMMIT_TAG
+    ref: $CI_COMMIT_TAG
+    description: GitLab release $CI_COMMIT_TAG
diff --git a/README.rst b/README.rst
index 2edc1d4..b169199 100644
--- a/README.rst
+++ b/README.rst
@@ -93,8 +93,3 @@ Nimrod Adar, `contact me <nimrod@shore.co.il>`_ or visit my `website
 <https://www.shore.co.il/>`_. Patches are welcome via `git send-email
 <http://git-scm.com/book/en/v2/Git-Commands-Email>`_. The repository is located
 at: https://git.shore.co.il/nimrod/.
-
-Pending tasks
--------------
-
-- Release on tagged commits to PyPI in CI.
-- 
GitLab