-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- GitHub Actions now supports manually invoking a bump version from CI for releases
- Loading branch information
Showing
3 changed files
with
135 additions
and
141 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,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 |
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,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 |