Skip to content

Generate

Generate #882

Workflow file for this run

name: Generate
on:
workflow_dispatch: {}
repository_dispatch: {}
schedule:
- cron: "5 4 * * *"
jobs:
generate:
runs-on: ubuntu-latest
name: Generate
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Checkout newest tag
run: |
git fetch --tags
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $latestTag
working-directory: pmdsky-debug
- name: Check if new tag available
id: check
run: |
git diff --exit-code --quiet pmdsky-debug && echo "::set-output name=newtag::no_new_tag" || echo "::set-output name=newtag::new_tag"
- name: Set up Python 3.11
if: steps.check.outputs.newtag == 'new_tag'
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install generator and yq
if: steps.check.outputs.newtag == 'new_tag'
run: |
python -m pip install --upgrade pip
pip install yq
pip install .
working-directory: generator
- name: Get release
if: steps.check.outputs.newtag == 'new_tag'
run: |
echo "RELEASE=$(git -C "pmdsky-debug" tag -l --points-at HEAD | head -1)" >> $GITHUB_ENV
- name: Run generator
if: steps.check.outputs.newtag == 'new_tag'
run: |
python -m pmdsky_debug_py_generator.main \
-i ../pmdsky-debug \
-o ../src \
-r $RELEASE
working-directory: generator
- name: Commit and Push
if: steps.check.outputs.newtag == 'new_tag'
uses: EndBug/add-and-commit@v9
with:
add: .
message: 'Release ${{ env.RELEASE }}'
push: true
- name: Create tag
if: steps.check.outputs.newtag == 'new_tag'
run: |
VERSION=$(tomlq '.project.version' src/pyproject.toml -r)
git tag $VERSION -m "Release $RELEASE"
git push -u origin $VERSION
- name: Dispatch build workflow
if: steps.check.outputs.newtag == 'new_tag'
uses: peter-evans/repository-dispatch@v3
with:
event-type: generated