Skip to content

Commit

Permalink
Supports version bumping from CI
Browse files Browse the repository at this point in the history
- GitHub Actions now supports manually invoking a bump version from CI for releases
  • Loading branch information
idjaw committed Oct 23, 2024
1 parent 00eda74 commit 80c8aec
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 141 deletions.
141 changes: 0 additions & 141 deletions .github/workflows/python-app.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Release

on:
workflow_dispatch:
inputs:
sem_version:
description: 'Semver bump type: major/minor/patch'
required: true
type: choice
options:
- patch
- minor
- major
workflow_call:

jobs:
test:
uses: idjaw/edunet/.github/workflows/test.yml@main

release:
needs: [test]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Install project dependencies
run: |
poetry install
- name: Bump Version
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
poetry version ${{ github.event.inputs.sem_version }}
git add pyproject.toml
git commit -m "Bumps version to $(poetry version -s)" || echo "No changes to commit"
git push origin main
- name: Package application
run: |
poetry build
- name: Get version
run: |
echo "version=$(poetry version -s)" >> $GITHUB_ENV
id: version

- name: Create and push tag
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag -a ${{ env.version }} -m "release for ${{ env.version }}"
git push origin ${{ env.version }}
- name: Publish the package with poetry
env:
API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
poetry config pypi-token.pypi "$API_TOKEN"
poetry publish
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test

on:
push:
branches:
- '*'
pull_request:
branches:
- main
workflow_call:

jobs:
test:
runs-on: ${{ matrix.os }}
env:
ACTIONS_STEP_DEBUG: true
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Install project dependencies
run: |
poetry install
- name: Get Python version for tox
run: |
stripped_py_version=$(echo "${{ matrix.python-version }}" | tr -d '.')
echo "py_version=$stripped_py_version" >> $GITHUB_ENV
id: py_version

- name: Run tests
env:
SKIP_LOAD_TEST: "true"
run: |
poetry run tox -e py${{ env.py_version }}
- name: Upload coverage reports to Codecov
if: github.ref == 'refs/heads/main' # Only run this step if it's the main branch
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: idjaw/edunet

0 comments on commit 80c8aec

Please sign in to comment.