~sumner/sublime-music

faaa6503e8b11b67ab968b96b4ed8118306ab0ea — Sumner Evans 5 months ago 3976bff use-srht-for-deploy v0.11.12
ci: use sourcehut for PyPi deploy
3 files changed, 41 insertions(+), 41 deletions(-)

M .builds/build.yml
M .gitlab-ci.yml
A cicd/tagged_with_version
M .builds/build.yml => .builds/build.yml +13 -12
@@ 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

M .gitlab-ci.yml => .gitlab-ci.yml +0 -29
@@ 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:

A cicd/tagged_with_version => cicd/tagged_with_version +28 -0
@@ 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)