Skip to content

Commit

Permalink
cd on push
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-p committed Sep 25, 2024
1 parent 8b2d9b8 commit 8f96d58
Showing 1 changed file with 8 additions and 52 deletions.
60 changes: 8 additions & 52 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
name: Continuous Delivery of Python package

on:
workflow_dispatch:
inputs:
compiler_wheel:
description: "Include compiler wheel?"
type: boolean
required: true
default: true
bump_version:
description: "Bump version, set to false to re-publish with current version"
type: boolean
required: true
default: true
publish_github:
description: "Publish to Github?"
type: boolean
required: true
default: true
publish_pypi:
description: "Publish to PyPi?"
type: boolean
required: true
default: true
publish_docs:
description: "Publish Docs?"
type: boolean
required: true
default: true
run_checks:
description: "Run checks?"
type: boolean
required: true
default: true
dry_run:
description: "Dry Run? If true, won't commit or publish anything"
type: boolean
required: true
default: false
push:
branches:
- main
- release/*

concurrency: release

Expand All @@ -54,8 +21,6 @@ jobs:
id-token: write
contents: write
packages: read
env:
DRY_RUN: ${{ inputs.dry_run && '--noop' || '' }}
steps:
- uses: actions/create-github-app-token@v1
id: app-token
Expand Down Expand Up @@ -84,49 +49,40 @@ jobs:
run: pipx install algokit

- name: pre-commit and pytest
if: inputs.run_checks
run: |
set -o pipefail
source $(poetry env info --path)/bin/activate
pre-commit run --all-files && git diff --exit-code
algokit localnet start
pytest
- name: Get branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: get_branch

- name: Set Git user as GitHub actions
run: git config --global user.email "actions@github.com" && git config --global user.name "github-actions"

- name: Update release
if: inputs.bump_version
run: poetry run semantic-release $DRY_RUN --strict version
run: poetry run semantic-release --strict version
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Create Wheel
if: inputs.compiler_wheel
run: poetry build --format wheel

- uses: actions/upload-artifact@v4 # upload artifacts so they are retained on the job
with:
path: dist

- name: Publish to GitHub
if: steps.get_branch.outputs.branch == 'main' && !inputs.dry_run && inputs.publish_github
run: poetry run semantic-release $DRY_RUN publish
run: poetry run semantic-release publish
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Publish to PyPI
if: steps.get_branch.outputs.branch == 'main' && !inputs.dry_run && inputs.publish_pypi && inputs.compiler_wheel
uses: pypa/gh-action-pypi-publish@release/v1

publish-docs:
name: Publish Docs
if: ${{ !inputs.dry_run && inputs.publish_docs }}
# Don't publish canary docs
if: github.ref != 'refs/heads/main'
uses: ./.github/workflows/gh-pages.yaml
permissions:
contents: read
Expand Down

0 comments on commit 8f96d58

Please sign in to comment.