summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise Thompson <blaise@untzag.com>2020-05-17 17:02:34 -0500
committerBlaise Thompson <blaise@untzag.com>2020-05-17 17:02:34 -0500
commit3d70e7b6ff9c4993a3c2afe27cedb720adc01f90 (patch)
tree6129ec034e938b543e9ec08757531716f87bf7cb
parent908593022c229a667d0ff2625fd88b65d9331a46 (diff)
releasing-pypi-gitlab
-rwxr-xr-xbuild.py2
-rw-r--r--posts/releasing-pypi-gitlab.md108
-rw-r--r--public/style.css28
-rw-r--r--templates/style.css28
4 files changed, 139 insertions, 27 deletions
diff --git a/build.py b/build.py
index d38dbcd..56196d2 100755
--- a/build.py
+++ b/build.py
@@ -12,7 +12,7 @@ __here__ = pathlib.Path(__file__).resolve().parent
date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
-md = markdown.Markdown(extensions=['meta', "toc"])
+md = markdown.Markdown(extensions=['meta', "toc", "extra"])
env = jinja2.Environment(loader = jinja2.FileSystemLoader(str(__here__ / "templates")))
diff --git a/posts/releasing-pypi-gitlab.md b/posts/releasing-pypi-gitlab.md
new file mode 100644
index 0000000..db0cc70
--- /dev/null
+++ b/posts/releasing-pypi-gitlab.md
@@ -0,0 +1,108 @@
+title: releasing: gitlab to pypi
+date: 2020-05-17
+
+This post contains my notes for how I release a Python project from GitLab to PyPI.
+I love hosting projects on GitLab since I can use the built-in runners to release automatically.
+
+# table of contents
+
+[TOC]
+
+# first release
+
+The very first release is necessarily a very manual process.
+Once the project is on PyPI, subsequent releases can be automated.
+
+## test packaging
+
+First, you want to make sure that your source code is correct.
+There are a lot of little regretable mistakes to be made.
+
+- `python setup.py sdist bdist_wheel`
+- open `dist\<package>.tar.gz`
+- ensure that LICENSE is packaged
+- ensure that VERSION is correct
+- ensure that CHANGELOG is correct
+- ensure that PKG-INFO is correct
+
+## tag on GitLab
+
+- New Tag
+- Tag name should start with v, e.g. v0.1.0, v2020.05.0
+- under release notes: `release [version](link-to-changelog)`
+
+If you already have gitlab-ci setup to release on tag, it will try and surely fail.
+That's OK for this initail release.
+You can cancel it, if you think to.
+
+## release on PyPI
+
+Now we actually release to PyPI.
+
+- `rm -rf dist`
+- `python setup.py sdist bdist_wheel`
+- `twine upload dist/*`
+
+Horray!
+Don't forget to log into PyPI and make other project maintainers into "owners".
+
+# gitlab-ci
+
+In this section we will set up gitlab-ci to automatically release everytime a new tag is made.
+
+## add release to ci
+
+In `.gitlab-ci.yml`:
+
+```
+twine:
+ stage: deploy
+ script:
+ - python setup.py sdist bdist_wheel
+ - twine upload dist/*
+ artifacts:
+ paths:
+ - dist/*
+ only:
+ - tags
+```
+
+## protect tags
+
+Within the GitLab repository, we must mark tags that we intend to release as protected.
+This is intended as a safety feature so that only maintainers are able to release.
+On GitLab:
+
+- Settings > Repository
+- Protected Tags
+- Create wildcard `v*`
+- Allowed to create: Maintainers
+- Protect
+
+## add variables
+
+PyPI allows uploads via tokens.
+This is how we will authenticate and let PyPI know that we are who we say we are.
+First, we need to generate the token.
+On PyPI:
+
+- Account
+- API tokens
+- Create token `gitlab-<project>`, scope only for project
+
+On GitLab:
+
+- Settings > CI/CD
+- Variables > Add Variable
+- (make sure variables are protected)
+- key `TWINE_PASSWORD` value `pypi-<TOKEN>`
+- key `TWINE_USERNAME` value `__token__`
+
+# subsequent releases
+
+On subsequent releases gitlab should release for you on tag.
+
+- update CHANGELOG
+- update VERSION
+- tag
+- watch ci release for you \ No newline at end of file
diff --git a/public/style.css b/public/style.css
index fc599ab..b010808 100644
--- a/public/style.css
+++ b/public/style.css
@@ -17,21 +17,23 @@ body {
overflow-y: scroll;
}
-.singlespaced {
- line-height: 1;
-}
-
-.horizontal {
- display: flex;
- list-style-type: none;
- padding: 0;
- justify-content: space-between;
+h2 {
+ font-size: 16px;
}
-.tab30 {
- margin-left: 30px;
+pre {
+ width: 80ch;
+ padding: 15px;
+ margin-left: auto;
+ margin-right: auto;
+ overflow: auto;
+ overflow-y: hidden;
+ font-size: 15.3px;
+ background: #111314;
+ border: 1px solid #c5c8c6;
}
-.tab60 {
- margin-left: 60px;
+code {
+ background: #111314;
+ color: #de935f
} \ No newline at end of file
diff --git a/templates/style.css b/templates/style.css
index c5c545b..71d74d5 100644
--- a/templates/style.css
+++ b/templates/style.css
@@ -17,21 +17,23 @@ body {
overflow-y: scroll;
}
-.singlespaced {
- line-height: 1;
-}
-
-.horizontal {
- display: flex;
- list-style-type: none;
- padding: 0;
- justify-content: space-between;
+h2 {
+ font-size: 16px;
}
-.tab30 {
- margin-left: 30px;
+pre {
+ width: 80ch;
+ padding: 15px;
+ margin-left: auto;
+ margin-right: auto;
+ overflow: auto;
+ overflow-y: hidden;
+ font-size: 15.3px;
+ background: #111314;
+ border: 1px solid #c5c8c6;
}
-.tab60 {
- margin-left: 60px;
+code {
+ background: #111314;
+ color: #de935f
}