Skip to content

Commit

Permalink
Merge pull request #55 from zapatacomputing/zqs-1268-fix-orqviz-publi…
Browse files Browse the repository at this point in the history
…sh-release-2

Zqs 1268 fix orqviz publish release 2
  • Loading branch information
Athena Caesura authored Jan 26, 2023
2 parents c2c7eaa + 3d14060 commit ca26e71
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 16 deletions.
65 changes: 61 additions & 4 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,76 @@ name: publish-release

on:
workflow_dispatch:
inputs:
version_override:
description: |
Release version to assign and publish in the semver form (M.m.p). If not passed, the next minor semver bump will be used.
required: false
type: string

jobs:
run-action:
release-project:
runs-on: ubuntu-latest

steps:
# Needed to get access to publish-release action definition
- name: Check out the released repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# Fetch whole repo to get access to tags to read current package
# version.
fetch-depth: 0

- name: Run publish release action
uses: ./subtrees/z_quantum_actions/actions/publish-release
- name: Get next version
id: get-next-version
# Note: We assume library name is the same as repository name
# Outputs: `next_version` - a bumped semver string of form "major.minor.patch"
run: make get-next-version PACKAGE_NAME="${{ github.event.repository.name }}"
# This is needed if we work on the private repositories, doesn't bother us otherwise though
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock

- name: Get release version
id: get-release-version
# Outputs: 'RELEASE_VERSION'
run: |
MANUAL_VER="${{ inputs.version_override }}"
NEXT_VER="${{ steps.get-next-version.outputs.next_version }}"
if [[ ! -z "$MANUAL_VER" ]]; then
RELEASE_VER="$MANUAL_VER"
else
RELEASE_VER="$NEXT_VER"
fi
echo "RELEASE_VERSION=${RELEASE_VER}" >> $GITHUB_OUTPUT
- name: Push release tag
id: push-release-tag
# Input: inferred release version, semver string.
# Output: release version tag.
run: |
TAG="v${{ steps.get-release-version.outputs.RELEASE_VERSION }}"
git tag "$TAG"
git push --tags
echo "RELEASE_TAG=$TAG" >> $GITHUB_OUTPUT
- name: Trigger building+publishing wheels
run: |
CICD_ACTIONS_REF="main"
curl \
-X POST \
"https://api.github.com/repos/zapatacomputing/cicd-actions/actions/workflows/py-wheel-build-and-push.yml/dispatches" \
-H "Authorization: token $GH_ACTIONS_TOKEN" \
-H 'Accept: application/vnd.github.everest-preview+json' \
--data-raw '
{
"ref": "'$CICD_ACTIONS_REF'",
"inputs":
{
"repository": "'"$repository"'",
"ref": "'"$ref"'"
}
}
'
echo ${{github.repository}}
env:
GH_ACTIONS_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }}
repository: ${{github.repository}}
ref: refs/tags/${{ steps.push-release-tag.outputs.RELEASE_TAG }}
11 changes: 7 additions & 4 deletions subtrees/z_quantum_actions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ dev-default: clean

# Why we want to use `python3` and not `$(PYTHON)` here.
# In order to enable running make commands both from CICD and locally
# we need to use virtualenv when running on GitHub Actions, as otherwise
# we need to use virtualenv when running on GitHub Actions, as otherwise
# we might get into rare and hard to debug edge cases (as we did in the past).
# After this action is executed $(PYTHON) will get resolved to the Python version
# from virtual environment.
# This make task is used to create new virtual environment so we want to use
# `python3` here as it's more explicit, because $(PYTHON) would evaluate to
# This make task is used to create new virtual environment so we want to use
# `python3` here as it's more explicit, because $(PYTHON) would evaluate to
# something else after executing this task, which might be confusing.
github_actions-default:
${PYTHON_EXE} -m venv ${VENV_NAME}
Expand Down Expand Up @@ -122,8 +122,11 @@ muster-default: style coverage
build-system-deps-default:
:

# Gets the next version of an installed package
# Note: on CI we only run this step, this means we use the github_actions target as a dependency.
# Because of this, we don't update the $(PYTHON) variable and have to manually build the path to our venv Python.
get-next-version-default: github_actions
$(PYTHON) subtrees/z_quantum_actions/bin/get_next_version.py $(PACKAGE_NAME)
"${VENV_NAME}/${VENV_BINDIR}/${PYTHON_EXE}" subtrees/z_quantum_actions/bin/get_next_version.py $(PACKAGE_NAME)

# This is what converts the -default targets into base target names.
# Do not remove!!!
Expand Down
6 changes: 3 additions & 3 deletions subtrees/z_quantum_actions/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ Files for Github Actions:
* workflow-templates/submit-dev-main-pr.yml
* actions/: All actions folders for *uses:* includes for
workflow-templates should not be modified normally.
* actions/coverage/action.yml
* actions/coverage/action.yml
* actions/publish-release/action.yml
* actions/ssh_setup/action.yml
* actions/style/action.yml

Actions Subtree Setup
==========================
This repo is designed to be subtree added to your git repo.
This repo is designed to be subtree added to your git repo.

.. Note:: We use underscores in the subtree folder name so that python imports
to *subtrees.z_quantum_actions/* work properly.
Expand Down Expand Up @@ -159,7 +159,7 @@ You can also soft-link the file to your top level folder if desired::

If you have other requirements, those must be included as needed.

Pytest Configuraiton
Pytest Configuration
=========================
The included Makefile allows us to simply do a *make test* and *make coverage*.
Because ``pytest.ini`` is fully supported (as compared with ``pyproject.toml``)
Expand Down
2 changes: 1 addition & 1 deletion subtrees/z_quantum_actions/bin/get_next_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Reads current project version, bumps "minor", and sets the "next_version" output
# variable using Github's special stdout syntax.

import sys
import re
import sys
import typing as t
from importlib.metadata import version

Expand Down
10 changes: 9 additions & 1 deletion subtrees/z_quantum_actions/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools_scm>=6.0", "pygit2"]
requires = [
# The pin is a workaround for editable installs breaking IDEs.
# See this mypy issue: https://github.com/python/mypy/issues/13392#issuecomment-1213527559
# and our note: https://zapatacomputing.atlassian.net/wiki/spaces/ORQSRUN/pages/519012482/Editable+installs
"setuptools<=63",
"wheel",
"setuptools_scm>=6.0",
"pygit2"
]

# Including this section is same as 'use_scm_version=True' in setup.py
# See https://github.com/pypa/setuptools_scm for guidance
Expand Down
2 changes: 0 additions & 2 deletions subtrees/z_quantum_actions/tests/test_get_next_version.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
################################################################################
# © Copyright 2022 Zapata Computing Inc.
################################################################################
import re
import subprocess

import pytest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow can be trigerred manually.
# This workflow can be triggered manually.

# Don't extend this workflow. If any more steps are needed please extend the
# "publish-release" action in "z_quantum_actions". Allows reusing between repos.
Expand Down

0 comments on commit ca26e71

Please sign in to comment.