Skip to content

Commit

Permalink
Merge pull request #8 from algorandfoundation/ci/check_version_increment
Browse files Browse the repository at this point in the history
ci: check version increment before release
  • Loading branch information
joe-p authored Oct 11, 2024
2 parents 91507eb + c9dbbd8 commit 17caf58
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 69 deletions.
42 changes: 42 additions & 0 deletions .github/actions/python-semantic-release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "Python Semantic Release"
description: "An action to run release a python package with semantic release"
inputs:
github_token:
description: "The GitHub token to use for authentication"
required: true

runs:
using: "composite"
steps:
- name: pre-commit and pytest
shell: bash
run: |
set -o pipefail
poetry run pre-commit run --all-files && git diff --exit-code
poetry run pytest
- name: Set Git user as GitHub actions
shell: bash
run: git config --global user.email "actions@github.com" && git config --global user.name "github-actions"

- name: Update release
shell: bash
run: poetry run semantic-release --strict version
env:
GITHUB_TOKEN: ${{ inputs.github_token }}

- name: Create Wheel
shell: bash
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
run: poetry run semantic-release publish
env:
GITHUB_TOKEN: ${{ inputs.github_token }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
26 changes: 26 additions & 0 deletions .github/actions/setup-algokit-python/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Setup Algokit Python Environment"
description: "An action to setup the python environmen with algokit and poetry"
runs:
using: "composite"
steps:
- name: Install poetry
shell: bash
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"

- name: Install dependencies
shell: bash
run: poetry install --no-interaction

- name: Install algokit
shell: bash
run: pipx install algokit

- name: Run localnet
shell: bash
run: algokit localnet start
56 changes: 15 additions & 41 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,31 @@ jobs:
with:
app-id: ${{ secrets.BOT_ID }}
private-key: ${{ secrets.BOT_SK }}

- uses: actions/checkout@v4
with:
# Fetch entire repository history so we can determine version number from it
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction

- name: Install algokit
run: pipx install algokit
- uses: ./.github/actions/setup-algokit-python

- name: pre-commit and pytest
- name: Check if version is already released
id: check_version
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: 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
run: poetry run semantic-release --strict version
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Create Wheel
run: poetry build --format wheel

- uses: actions/upload-artifact@v4 # upload artifacts so they are retained on the job
poetry run semantic-release --strict --noop version
rc=$?
echo "return_code=$rc" >> $GITHUB_OUTPUT
if [ $rc -ne 0 ] && [ $rc -ne 2 ]; then
exit $rc
fi
- name: Semantic Release
if: steps.check_version.outputs.return_code == '0'
uses: ./.github/actions/python-semantic-release
with:
path: dist

- name: Publish to GitHub
run: poetry run semantic-release publish
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github_token: ${{ steps.app-token.outputs.token }}

publish-docs:
name: Publish Docs
Expand Down
30 changes: 2 additions & 28 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction
- uses: ./.github/actions/setup-algokit-python

- name: Check pre-commits
run: |
Expand All @@ -44,23 +34,7 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "poetry"

- name: Install dependencies
run: poetry install --no-interaction

- name: Install algokit
run: pipx install algokit

- name: Start LocalNet
run: algokit localnet start
- uses: ./.github/actions/setup-algokit-python

- name: pytest + coverage
shell: bash
Expand Down

0 comments on commit 17caf58

Please sign in to comment.