ci: use sourcehut for PyPi deploy
This commit is contained in:
@@ -10,12 +10,15 @@ packages:
|
|||||||
- xorg-server-xvfb
|
- xorg-server-xvfb
|
||||||
sources:
|
sources:
|
||||||
- https://git.sr.ht/~sumner/sublime-music
|
- https://git.sr.ht/~sumner/sublime-music
|
||||||
|
secrets:
|
||||||
|
# PyPi Deploy Credentials for Sublime Music
|
||||||
|
- b4190b11-fdf7-4cee-b939-ea9fce44fa12
|
||||||
environment:
|
environment:
|
||||||
REPO_NAME: sublime-music
|
REPO_NAME: sublime-music
|
||||||
triggers:
|
# triggers:
|
||||||
- action: email
|
# - action: email
|
||||||
condition: failure
|
# condition: failure
|
||||||
to: ~sumner/sublime-music-devel@lists.sr.ht
|
# to: ~sumner/sublime-music-devel@lists.sr.ht
|
||||||
tasks:
|
tasks:
|
||||||
- setup: |
|
- setup: |
|
||||||
cd ${REPO_NAME}
|
cd ${REPO_NAME}
|
||||||
@@ -38,12 +41,10 @@ tasks:
|
|||||||
- build: |
|
- build: |
|
||||||
poetry build
|
poetry build
|
||||||
|
|
||||||
# TODO migrate deploy to sr.ht
|
- test-deploy-pypi: |
|
||||||
# - deploy-pypi: |
|
poetry publish --dry-run
|
||||||
# ./cicd/run_if_tagged_with_version \
|
|
||||||
# "twine upload -r testpypi dist/*" \
|
|
||||||
# "twine upload dist/*"
|
|
||||||
|
|
||||||
# - verify-pypi: |
|
- deploy-pypi: |
|
||||||
# ./cicd/run_if_tagged_with_version \
|
./cicd/tagged_with_version || echo "Skipping deploy since not tagged with version"
|
||||||
# "pip install ${REPO_NAME}"
|
./cicd/tagged_with_version || complete-build
|
||||||
|
poetry publish
|
||||||
|
@@ -77,35 +77,6 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- 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:
|
publish_release:
|
||||||
stage: release
|
stage: release
|
||||||
only:
|
only:
|
||||||
|
28
cicd/tagged_with_version
Executable file
28
cicd/tagged_with_version
Executable 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)
|
Reference in New Issue
Block a user