-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from zapatacomputing/dev
Merge dev to master
- Loading branch information
Showing
11 changed files
with
200 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# z-quantum-actions | ||
|
||
This repo contains definitions of custom GitHub Action used in `z-quantum-*` and `qe-*` | ||
repositories. | ||
|
||
## Usage | ||
|
||
This repo is private, so actions can't be referenced directly via `uses:` [step keyword](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsuses). | ||
The recommended workaround is to add this repo into your "client" repo using git subtree: | ||
|
||
```bash | ||
cd your-client-repo | ||
git subtree add -P vendor/z-quantum-actions git@github.com:zapatacomputing/z-quantum-actions.git master --squash | ||
``` | ||
|
||
Actions can be then referred to via their local paths, like: | ||
```yaml | ||
# inside your GitHub workflow | ||
steps: | ||
- name: Run publish release action | ||
uses: ./vendor/z-quantum-actions/publish-release | ||
``` | ||
## Repo contents | ||
- `publish-release` - single action that wraps a couple of workflow steps | ||
- `workflow-templates` - workflow .ymls that can't be used directly, but can be copied to your repo to set up the release process. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# This workflow is meant to be run on each push to the base branch. It allows executing | ||
# the "publish release" action. | ||
# | ||
# Don't extend this workflow. If any more steps are needed please add them to the | ||
# action instead. This allows reusing it between repos. | ||
name: Publish release | ||
|
||
description: Infers current project version, pushes a tag with a new version, and creates an entry on GitHub Releases | ||
|
||
# Note: this action assumes that the repo was already cloned | ||
|
||
inputs: | ||
new-version: | ||
description: Optional override for the release version. If not provided, will be inferred from current version. | ||
required: false | ||
|
||
|
||
outputs: | ||
release-version: | ||
description: Version that the release ended up running for. | ||
value: ${{ steps.infer-release-version.outputs.inferred_version }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Infer release version | ||
id: infer-release-version | ||
shell: bash | ||
run: | | ||
NEW_VERSION="${{ inputs.new_version }}" | ||
if [ -n "$NEW_VERSION" ]; then | ||
INFERRED_VERSION="$NEW_VERSION" | ||
echo "using $INFERRED_VERSION provided as action input" | ||
else | ||
PKG_VERSION=$(python3 setup.py --version) | ||
MAJOR=$(echo $PKG_VERSION | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)([-\.].+)?$/\1/') | ||
MINOR=$(echo $PKG_VERSION | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)([-\.].+)?$/\2/') | ||
PATCH=$(echo $PKG_VERSION | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)([-\.].+)?$/\3/') | ||
DEV=$(echo $PKG_VERSION | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)([-\.].+)?$/\4/') | ||
echo "read version: $MAJOR.$MINOR.$PATCH$DEV" | ||
INFERRED_VERSION="$MAJOR.$(expr $MINOR + 1).0" | ||
echo "inferred version: $INFERRED_VERSION" | ||
fi | ||
# special github syntax for setting step outputs | ||
# see https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter | ||
echo "::set-output name=inferred_version::$INFERRED_VERSION" | ||
- name: Push new version tag | ||
id: push-new-version-tag | ||
shell: bash | ||
run: | | ||
TAG="v${{steps.infer-release-version.outputs.inferred_version}}" | ||
git tag "$TAG" | ||
git push --tags | ||
echo "::set-output name=tag::$TAG" | ||
- name: Create entry on GH Releases | ||
shell: bash | ||
run: | | ||
curl \ | ||
-X POST \ | ||
curl -H "Authorization: token ${{ github.token }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/releases \ | ||
-d '{"tag_name":"${{ steps.push-new-version-tag.outputs.tag }}"}' | ||
27 changes: 27 additions & 0 deletions
27
subtrees/z-quantum-actions/workflow-templates/publish-release.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This workflow is meant to be triggered by push to master when running the release | ||
# process. | ||
# | ||
# Don't extend this workflow. If any more steps are needed please extend the | ||
# "publish-release" action in "z-quantum-actions". This allows reusing it between repos. | ||
name: publish-release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
run-action: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Needed to get access to publish-release action definition | ||
- name: Check out the released repo | ||
uses: actions/checkout@v2 | ||
with: | ||
# Fetch whole repo to get access to tags. We need tags to read current package | ||
# version. | ||
fetch-depth: 0 | ||
|
||
- name: Run publish release action | ||
uses: ./vendor/z-quantum-actions/publish-release |
23 changes: 23 additions & 0 deletions
23
subtrees/z-quantum-actions/workflow-templates/submit-dev-master-pr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This workflow is meant to be triggered by an Operator with via cURL. | ||
# | ||
# Don't extend this workflow. If any more steps are needed please extract the steps as a | ||
# composite action instead. This allows reusing it between repos. | ||
name: submit-dev-master-pr | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
submit-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Submit dev -> master PR | ||
uses: actions/github-script@v4 | ||
with: | ||
script: | | ||
github.pulls.create({ | ||
...context.repo, | ||
title: "Merge dev to master", | ||
head: "dev", | ||
base: "master", | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters