Skip to content

deploy-stable

deploy-stable #43

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:
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@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: |
See the [changelog](CHANGELOG.md) for details.
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: update changelog
run: |
newline="\\n## [${{ env.VERSION }}] - $(date +'%Y-%m-%d')"
sed '/## \[UNRELEASED\]/a\'"$newline" CHANGELOG.md > CHANGELOG.md.tmp
mv CHANGELOG.md.tmp CHANGELOG.md
- name: commit version bump via pr
run: |
git checkout -b ${{ env.VERSION }}
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 --set-upstream origin ${{ env.VERSION }}
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: 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 }}"}'