Skip to content

pretext-publish

pretext-publish #29

Workflow file for this run

name: deploy
on:
#schedule:
# * is a special character in YAML so you have to quote this string
# - cron: "0 0 * * 0"
repository_dispatch:
types: [pretext-publish]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Sets up python3
- uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Checkout
uses: actions/checkout@v4
- name: Discover latest CLI version
run: |
LATEST_VERSION=$(curl -s https://api.github.com/repos/PreTeXtBook/pretext-cli/releases/latest | jq -r .tag_name)
echo "CLI_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
- name: Get latest static version
run: |
git fetch --tags
git tag -l | sort -V | tail -n 1
echo "THIS_VERSION=$(git tag -l | sort -V | tail -n 1)" >> $GITHUB_ENV
- name: Fetch CLI repository
run: |
git clone https://github.com/pretextbook/pretext-cli.git
cd pretext-cli
#git checkout $CLI_VERSION
# 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 CLI
run: |
cd pretext-cli
poetry install
poetry run python scripts/copy_cdn_files.py ../dist
- 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 dist folder
run: |
git add dist
git commit -m "Update css and js for CDN" || echo "No new commit needed"
git push origin main || echo "All done"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create a new tag at current commit and push it
- name: Create tag
run: |
git tag -a $CLI_VERSION -m "Update css and js for CDN"
git push
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: "${{ env.CLI_VERSION }}"
release_name: "${{ env.CLI_VERSION }}"
draft: false
prerelease: false