Skip to content

deploy-stable

deploy-stable #71

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"
core-repo:
description: "The repository to use for the core commit."
required: false
type: choice
default: "PreTeXtbook/pretext"
options:
- "PreTeXtbook/pretext"
- "oscarlevin/pretext"
jobs:
tests:
name: Run tests
uses: ./.github/workflows/tests.yml
deploy:
needs: tests
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@v4
with:
ref: ${{ inputs.branch }}
# Sets up python3
- uses: actions/setup-python@v4
with:
python-version: 3.8
# Setup poetry
- name: Install poetry 1.8.4
run: |
python -m ensurepip
python -m pip install --upgrade pip
python -m pip install poetry==1.8.4
- name: Install build dependencies
run: sudo apt-get -y install libcairo2-dev pkg-config python3-dev
- name: Install dependencies
shell: bash
run: poetry install --all-extras
- name: Update version if needed
if: ${{ inputs.level != 'patch' }}
run: poetry version ${{ inputs.level }}
- name: Build package
run: poetry run python scripts/build_package.py ${{ inputs.core-repo }}
- 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 changelog
run: |
poetry run python scripts/update_changelog.py
- name: Update version for next dev release
run: poetry version patch
- 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 }}-deploy
git add CHANGELOG.md
git commit -m "update changelog for release"
git add pyproject.toml
git commit -m "bump version to next patch level for nightly releases"
git push -f --set-upstream origin ${{ env.VERSION }}-deploy
gh pr create --fill
gh pr merge -s -d -t "Update changelog and bump version to next patch level for nightly releases"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.VERSION }}"
release_name: "v${{ env.VERSION }}"
body: |
See the [changelog](CHANGELOG.md) for details.
draft: false
prerelease: false
- 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 }}"}'