ci: use sourcehut for PyPi deploy

This commit is contained in:
Sumner Evans
2021-05-05 10:14:48 -06:00
parent 3976bffe81
commit faaa6503e8
3 changed files with 41 additions and 41 deletions

View File

@@ -10,12 +10,15 @@ packages:
- xorg-server-xvfb
sources:
- https://git.sr.ht/~sumner/sublime-music
secrets:
# PyPi Deploy Credentials for Sublime Music
- b4190b11-fdf7-4cee-b939-ea9fce44fa12
environment:
REPO_NAME: sublime-music
triggers:
- action: email
condition: failure
to: ~sumner/sublime-music-devel@lists.sr.ht
# triggers:
# - action: email
# condition: failure
# to: ~sumner/sublime-music-devel@lists.sr.ht
tasks:
- setup: |
cd ${REPO_NAME}
@@ -38,12 +41,10 @@ tasks:
- build: |
poetry build
# TODO migrate deploy to sr.ht
# - deploy-pypi: |
# ./cicd/run_if_tagged_with_version \
# "twine upload -r testpypi dist/*" \
# "twine upload dist/*"
- test-deploy-pypi: |
poetry publish --dry-run
# - verify-pypi: |
# ./cicd/run_if_tagged_with_version \
# "pip install ${REPO_NAME}"
- deploy-pypi: |
./cicd/tagged_with_version || echo "Skipping deploy since not tagged with version"
./cicd/tagged_with_version || complete-build
poetry publish

View File

@@ -77,35 +77,6 @@ pages:
paths:
- public
deploy_pypi:
image: python:3.8-alpine
stage: deploy
cache: {}
only:
variables:
# Only do a deploy if it's a version tag.
- $CI_COMMIT_TAG =~ /^v.*/
before_script:
- apk add gcc musl-dev libffi-dev openssl-dev
- pip install twine
- './cicd/create-pypirc.sh'
script:
# Upload to the test PyPi instance, then upload to the real one.
- twine upload -r pypi_test dist/*
- twine upload dist/*
after_script:
- echo "" > ~/.pypirc && rm -f ~/.pypirc
verify_deploy:
stage: verify
cache: {}
only:
variables:
# Only verify the deploy if it's a version tag.
- $CI_COMMIT_TAG =~ /^v.*/
script:
- pip3 install sublime-music
publish_release:
stage: release
only:

28
cicd/tagged_with_version Executable file
View File

@@ -0,0 +1,28 @@
#! /usr/bin/env python
import re
import subprocess
import sys
version_tag_re = re.compile(r"v\d+\.\d+\.\d+")
tags = (
subprocess.run(["git", "tag", "--contains", "HEAD"], capture_output=True)
.stdout.decode()
.strip()
.split()
)
# If one of the tags is a version tag, then run the commands specified in the
# parameters.
for tag in tags:
if match := version_tag_re.match(tag):
print(f"VERSION TAG {tag} FOUND")
sys.exit(0)
# Don't run the else statement of the for loop.
break
else:
print("NO VERSION TAG FOUND")
sys.exit(1)