Skip to content

deploy-stable

deploy-stable #31

Workflow file for this run

name: deploy-stable
on:
# Currently this workflow only runs when triggered manually. Perhaps we can set it up to run when a tag is pushed. Or when a release is made. Or that it could create a release, on a release it can create a tag?
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
level:
description: "The level of release to make"
required: true
type: choice
default: "patch"
options:
- "patch"
- "minor"
- "major"
branch:
description: "Use main branch for regular releases, legacy-support for 1.8x fixes."
required: false
type: choice
default: "main"
options:
- "main"
- "legacy-support"
jobs:
test:
name: Run tests
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
poetry-version: ["1.5.1"]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry ${{ matrix.poetry-version }}
run: |
python -m ensurepip
python -m pip install --upgrade pip
python -m pip install poetry==${{ matrix.poetry-version }}
- name: Install dependencies
shell: bash
run: |
python -m poetry install
python -m poetry run python scripts/fetch_core.py
python -m poetry run python scripts/zip_templates.py
- name: Test with pytest
run: |
python -m poetry run pytest -v --cov
deploy:
needs: test
name: Deploy to pypi
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
# Sets up python3
- uses: actions/setup-python@v4
with:
python-version: 3.8
# Setup poetry
- name: Install poetry 1.5.1
run: |
python -m ensurepip
python -m pip install --upgrade pip
python -m pip install poetry==1.5.1
- name: Install dependencies
shell: bash
run: poetry install
- name: Build package
run: poetry run python scripts/build_package.py
- name: Update version if needed
if: ${{ inputs.level != 'patch' }}
run: poetry version ${{ inputs.level }}
- name: Discover current version
run: |
poetry run pretext --version
echo "VERSION=$(poetry run pretext --version)" >> $GITHUB_ENV
- name: Publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
- name: Update version for next dev release
run: poetry version patch
- name: Create Release
id: create_release
if: ${{ inputs.level != 'patch' }}
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: v${{ env.VERSION }}
# body: |
# Changes in this Release
draft: false
prerelease: false
- name: setup git config
run: |
# setup the username and email.
git config user.name "${{ github.actor }} via GitHub Actions"
git config user.email "${{ github.actor }}@github_actions.no_reply"
- name: commit version bump via pr
run: |
git checkout -b ${{ env.VERSION }}
git add pyproject.toml
git commit -m "bump version to next patch level for nightly releases"
git push --set-upstream origin ${{ env.VERSION }}
gh pr create --fill
gh pr merge -s -d -t "bump version to next patch level for nightly releases"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.PUSH_CODESPACES }}
repository: oscarlevin/pretext-docker
event-type: pretext-publish
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'