From 4eb1b13e746a34e4fdb30c84fc484d79964acf31 Mon Sep 17 00:00:00 2001 From: DrR0X-glitch Date: Wed, 15 Nov 2023 18:10:52 +1100 Subject: [PATCH 1/5] Create new workflows for versioning --- .github/workflows/ci.yml | 25 -------------- .github/workflows/deploy-beta.yml | 27 +++++++++++++++ .github/workflows/deploy-main.yml | 27 +++++++++++++++ .github/workflows/release-beta.yml | 54 ++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy-beta.yml create mode 100644 .github/workflows/deploy-main.yml create mode 100644 .github/workflows/release-beta.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index a9e6b76..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: ci -on: - push: - branches: - - master - - main -permissions: - contents: write -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 - with: - python-version: 3.x - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - - uses: actions/cache@v3 - with: - key: mkdocs-material-${{ env.cache_id }} - path: .cache - restore-keys: | - mkdocs-material- - - run: pip install "mkdocs-material[imaging]" - - run: mkdocs gh-deploy --force diff --git a/.github/workflows/deploy-beta.yml b/.github/workflows/deploy-beta.yml new file mode 100644 index 0000000..9f0fb38 --- /dev/null +++ b/.github/workflows/deploy-beta.yml @@ -0,0 +1,27 @@ +name: Overwrite Beta Version +on: + push: + branches: + - beta +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + cache: "pip" + - run: pip install -r requirements.txt + - name: Fetch full gh-pages branch and create user + run: | + git fetch origin gh-pages --depth=1 + git config user.name ci-bot + git config user.email ci-bot@example.com + - name: Get current beta version number + run: | + echo "version=$(mike list beta | awk -F'[()]' '{print $2}')" >> $GITHUB_ENV + - run: | + mike deploy -u -p ${{ env.version }} beta -t beta diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml new file mode 100644 index 0000000..f2f1ccc --- /dev/null +++ b/.github/workflows/deploy-main.yml @@ -0,0 +1,27 @@ +name: Overwrite Latest Version +on: + push: + branches: + - main +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + cache: "pip" + - run: pip install -r requirements.txt + - name: Fetch full gh-pages branch and create user + run: | + git fetch origin gh-pages --depth=1 + git config user.name ci-bot + git config user.email ci-bot@example.com + - name: Get current latest version number + run: | + echo "version=$(mike list latest | awk -F'[()]' '{print $2}')" >> $GITHUB_ENV + - run: | + mike deploy -u -p ${{ env.version }} latest -t latest diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml new file mode 100644 index 0000000..3cb855d --- /dev/null +++ b/.github/workflows/release-beta.yml @@ -0,0 +1,54 @@ +name: Release Beta Version +on: + workflow_dispatch: + inputs: + confirm_prs_resolved: + description: "I have made sure all PRs are resolved" + required: true + type: boolean + confirm_branch: + description: "I have set this workflow to run from the beta branch" + required: true + type: boolean + new_version: + description: "The new beta version number" + required: true + type: number +permissions: + contents: write +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + cache: "pip" + - run: pip install -r requirements.txt + - name: Fetch full gh-pages and main branches and create user + run: | + git fetch origin gh-pages --depth=1 + git fetch origin main --depth=1 + git config user.name ci-bot + git config user.email ci-bot@example.com + - name: Get version numbers + run: | + echo "beta_version=$(mike list beta | awk -F'[()]' '{print $2}')" >> $GITHUB_ENV + echo "latest_version=$(mike list latest | awk -F'[()]' '{print $2}')" >> $GITHUB_ENV + - name: Rename the current latest version to its version number + run: | + mike retitle -p ${{ env.latest_version }} ${{ env.latest_version }} + - name: Deploy current beta version as latest + run: | + mike deploy -p -u ${{ env.beta_version }} latest -t latest + - name: Deploy copy of beta with incremented version number for development + run: | + mike deploy -p -u ${{ inputs.new_version }} beta -t beta + - name: Merge beta branch with main + run: | + git fetch --unshallow + git checkout main + git pull + git merge --no-ff beta -m "Auto-Merge beta into main" + git push From ae097cb33aaea14a0a95b0654a3014507ce0cbce Mon Sep 17 00:00:00 2001 From: DrR0X-glitch Date: Wed, 15 Nov 2023 18:15:42 +1100 Subject: [PATCH 2/5] Add requirements.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8fa8d9a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +mkdocs-material[imaging]==9.4.8 +mike==2.0.0 \ No newline at end of file From 8e454a738e2839a0562281270da875179236c213 Mon Sep 17 00:00:00 2001 From: DrR0X-glitch Date: Wed, 15 Nov 2023 18:22:25 +1100 Subject: [PATCH 3/5] Add mike version provider --- mkdocs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index a37320d..e7ee41b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -46,6 +46,8 @@ theme: logo: assets/images/logo/logo-128.png plugins: + - mike: + canonical_version: latest # - social: # enabled: !ENV [CI, false] # cards_layout: default/variant @@ -61,6 +63,8 @@ extra_css: # Add social icons to footer extra: + version: + provider: mike analytics: provider: google property: G-415530619 From 2442cccace6d679ab71dd8e41f08b5689443a40d Mon Sep 17 00:00:00 2001 From: DrR0X-glitch Date: Wed, 15 Nov 2023 18:22:36 +1100 Subject: [PATCH 4/5] Add outdated bar --- theme_override_home/main.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/theme_override_home/main.html b/theme_override_home/main.html index d551063..2fea99b 100644 --- a/theme_override_home/main.html +++ b/theme_override_home/main.html @@ -1,6 +1,13 @@ {% extends "base.html" %} + +{% block outdated %} You're not viewing the latest version. + + Click here to go to latest. + +{% endblock %} + {% block announce %} From 667d38cfc39f1ecd6d1a2f3b63f626b1548821a4 Mon Sep 17 00:00:00 2001 From: DrR0X-glitch Date: Wed, 15 Nov 2023 18:24:07 +1100 Subject: [PATCH 5/5] Fix formatting of mike plugin --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index e7ee41b..7d19a27 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -47,7 +47,7 @@ theme: plugins: - mike: - canonical_version: latest + canonical_version: latest # - social: # enabled: !ENV [CI, false] # cards_layout: default/variant