From a8f8af08245781b0614575212ee975481dea3c8c Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Tue, 3 Sep 2024 19:30:49 +0200 Subject: [PATCH] Spec Versioning --- .github/workflows/pages.yml | 33 ++++++------ .github/workflows/tag-latest.yml | 44 +++++++++++++++ docs/validator/index.md | 2 +- mkdocs.yml | 2 + tools/lottie_markdown.py | 15 ------ tools/mike | 11 ++++ tools/requirements.txt | 2 + tools/theme/css/version-select.css | 15 ++++++ tools/theme/js/version-select.js | 87 ++++++++++++++++++++++++++++++ tools/theme/main.html | 4 +- 10 files changed, 183 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/tag-latest.yml create mode 100755 tools/mike create mode 100644 tools/theme/css/version-select.css create mode 100644 tools/theme/js/version-select.js diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index d7cbfa8..44fc01a 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -3,6 +3,8 @@ on: push: branches: - main + tags: + - '*' workflow_dispatch: # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. @@ -13,7 +15,7 @@ concurrency: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read + contents: write pages: write id-token: write @@ -30,19 +32,20 @@ jobs: sudo apt update -q sudo apt install -yy python3 python3-pip graphviz pip install -r tools/requirements.txt + git config user.name "Lottie CI" + git config user.email "lottie@example.com" + git fetch origin gh-pages --depth=1 - - name: Docs - run: make - - - name: Setup Pages - uses: actions/configure-pages@v4 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - path: 'site' + name: Dev Docs + if: ${{ github.ref == 'refs/heads/main' }} + run: | + make lottie.schema.json + tools/mike deploy dev --push - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v3 - + name: Docs + if: ${{ github.ref != 'refs/heads/main' }} + env: + RELEASE_VERSION: ${{ github.ref_name }} + run: | + make lottie.schema.json + tools/mike deploy "$RELEASE_VERSION" --push diff --git a/.github/workflows/tag-latest.yml b/.github/workflows/tag-latest.yml new file mode 100644 index 0000000..21ef9f8 --- /dev/null +++ b/.github/workflows/tag-latest.yml @@ -0,0 +1,44 @@ +name: Tag Latest +on: + workflow_dispatch: + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: write + pages: write + id-token: write + +jobs: + tag-latest: + runs-on: ubuntu-latest + steps: + - name: Failsafe + if: ${{ ! startsWith(github.ref, 'refs/tags/') }} + run: | + echo "Only run on tags" >&2 + false + - + name: Checkout + uses: actions/checkout@v4 + - + name: Setup + run: | + sudo apt update -q + sudo apt install -yy python3 python3-pip graphviz + pip install -r tools/requirements.txt + git config user.name "Lottie CI" + git config user.email "lottie@example.com" + git fetch origin gh-pages --depth=1 + make lottie.schema.json + - + name: Tag Latest + env: + RELEASE_VERSION: ${{ github.ref_name }} + run: tools/mike alias -u "$RELEASE_VERSION" latest --push + diff --git a/docs/validator/index.md b/docs/validator/index.md index 3dd97f7..9e12871 100644 --- a/docs/validator/index.md +++ b/docs/validator/index.md @@ -4,7 +4,7 @@ disable_toc: 1 # Lottie Validator - +