Skip to content

Commit a3bd59a

Browse files
committed
Update cookiecutter template to use the new mike tools
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent beef96f commit a3bd59a

File tree

6 files changed

+174
-282
lines changed
  • cookiecutter/{{cookiecutter.github_repo_name}}/.github/workflows
  • tests_golden/integration/test_cookiecutter_generation
    • actor/frequenz-actor-test/.github/workflows
    • api/frequenz-api-test/.github/workflows
    • app/frequenz-app-test/.github/workflows
    • lib/frequenz-test-python/.github/workflows
    • model/frequenz-model-test/.github/workflows

6 files changed

+174
-282
lines changed

cookiecutter/{{cookiecutter.github_repo_name}}/.github/workflows/ci.yaml

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -336,78 +336,60 @@ jobs:
336336
permissions:
337337
contents: write
338338
steps:
339-
- name: Calculate and check version
340-
id: mike-metadata
341-
env:
342-
REF: ${{ github.ref }}
343-
REF_NAME: ${{ github.ref_name }}
344-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
345-
run: |
346-
aliases=
347-
version=
348-
if test "$REF_NAME" = "$DEFAULT_BRANCH"
349-
then
350-
version=next
351-
# A tag that starts with vX.Y or X.Y
352-
elif echo "$REF" | grep -q '^refs/tags' && echo "$REF_NAME" | grep -Pq '^v?\d+\.\d+\.'
353-
then
354-
if echo "$REF_NAME" | grep -Pq -- "-" # pre-release
355-
then
356-
echo "::notice title=Documentation was not published::" \
357-
"The tag '$REF_NAME' looks like a pre-release."
358-
exit 0
359-
fi
360-
version=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+\.[0-9]+)\..*$/\1/') # vX.Y
361-
major=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
362-
default_major=$(echo "$DEFAULT_BRANCH" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
363-
aliases=$major
364-
if test "$major" = "$default_major"
365-
then
366-
aliases="$aliases latest"
367-
fi
368-
else
369-
echo "::warning title=Documentation was not published::" \
370-
"Don't know how to handle '$REF' to make 'mike' version."
371-
exit 0
372-
fi
373-
echo "version=$version" >> $GITHUB_OUTPUT
374-
echo "aliases=$aliases" >> $GITHUB_OUTPUT
375-
376339
- name: Fetch sources
377-
if: steps.mike-metadata.outputs.version
378340
uses: actions/checkout@v4
379341
with:
380342
submodules: true
381343

382344
- name: Setup Git user and e-mail
383-
if: steps.mike-metadata.outputs.version
384345
uses: frequenz-floss/setup-git-user@v2
385346

386347
- name: Set up Python
387-
if: steps.mike-metadata.outputs.version
388348
uses: actions/setup-python@v4
389349
with:
390350
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
391351
cache: 'pip'
392352

393353
- name: Install build dependencies
394-
if: steps.mike-metadata.outputs.version
395354
run: |
396355
python -m pip install -U pip
397356
python -m pip install .[dev-mkdocs]
398357
pip freeze
399358
359+
- name: Calculate and check version
360+
id: mike-version
361+
env:
362+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
363+
GITHUB_REPO: ${{ github.repository }}
364+
GIT_REF: ${{ github.ref }}
365+
GIT_SHA: ${{ github.sha }}
366+
run: |
367+
python -m frequenz.repo.config.cli.version.mike.info
368+
400369
- name: Fetch the gh-pages branch
401-
if: steps.mike-metadata.outputs.version
370+
if: steps.mike-version.outputs.version
402371
run: git fetch origin gh-pages --depth=1
403372

404-
- name: Publish site
405-
if: steps.mike-metadata.outputs.version
373+
- name: Build site
374+
if: steps.mike-version.outputs.version
406375
env:
407-
VERSION: ${{ steps.mike-metadata.outputs.version }}
408-
ALIASES: ${{ steps.mike-metadata.outputs.aliases }}
376+
VERSION: ${{ steps.mike-version.outputs.version }}
377+
TITLE: ${{ steps.mike-version.outputs.title }}
378+
ALIASES: ${{ steps.mike-version.outputs.aliases }}
379+
run: |
380+
mike deploy --update-aliases --title "$TITLE" "$VERSION" $ALIASES
381+
382+
- name: Sort site versions
383+
if: steps.mike-version.outputs.version
384+
run: |
385+
git checkout gh-pages
386+
python -m frequenz.repo.config.cli.version.mkdocs.sort versions.json
387+
git commit -a -m "Sort versions.json"
388+
389+
- name: Publish site
390+
if: steps.mike-version.outputs.version
409391
run: |
410-
mike deploy --push --update-aliases "$VERSION" $ALIASES
392+
git push origin gh-pages
411393
412394
create-github-release:
413395
name: Create GitHub release

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/.github/workflows/ci.yaml

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -308,78 +308,60 @@ jobs:
308308
permissions:
309309
contents: write
310310
steps:
311-
- name: Calculate and check version
312-
id: mike-metadata
313-
env:
314-
REF: ${{ github.ref }}
315-
REF_NAME: ${{ github.ref_name }}
316-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
317-
run: |
318-
aliases=
319-
version=
320-
if test "$REF_NAME" = "$DEFAULT_BRANCH"
321-
then
322-
version=next
323-
# A tag that starts with vX.Y or X.Y
324-
elif echo "$REF" | grep -q '^refs/tags' && echo "$REF_NAME" | grep -Pq '^v?\d+\.\d+\.'
325-
then
326-
if echo "$REF_NAME" | grep -Pq -- "-" # pre-release
327-
then
328-
echo "::notice title=Documentation was not published::" \
329-
"The tag '$REF_NAME' looks like a pre-release."
330-
exit 0
331-
fi
332-
version=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+\.[0-9]+)\..*$/\1/') # vX.Y
333-
major=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
334-
default_major=$(echo "$DEFAULT_BRANCH" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
335-
aliases=$major
336-
if test "$major" = "$default_major"
337-
then
338-
aliases="$aliases latest"
339-
fi
340-
else
341-
echo "::warning title=Documentation was not published::" \
342-
"Don't know how to handle '$REF' to make 'mike' version."
343-
exit 0
344-
fi
345-
echo "version=$version" >> $GITHUB_OUTPUT
346-
echo "aliases=$aliases" >> $GITHUB_OUTPUT
347-
348311
- name: Fetch sources
349-
if: steps.mike-metadata.outputs.version
350312
uses: actions/checkout@v4
351313
with:
352314
submodules: true
353315

354316
- name: Setup Git user and e-mail
355-
if: steps.mike-metadata.outputs.version
356317
uses: frequenz-floss/setup-git-user@v2
357318

358319
- name: Set up Python
359-
if: steps.mike-metadata.outputs.version
360320
uses: actions/setup-python@v4
361321
with:
362322
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
363323
cache: 'pip'
364324

365325
- name: Install build dependencies
366-
if: steps.mike-metadata.outputs.version
367326
run: |
368327
python -m pip install -U pip
369328
python -m pip install .[dev-mkdocs]
370329
pip freeze
371330
331+
- name: Calculate and check version
332+
id: mike-version
333+
env:
334+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
335+
GITHUB_REPO: ${{ github.repository }}
336+
GIT_REF: ${{ github.ref }}
337+
GIT_SHA: ${{ github.sha }}
338+
run: |
339+
python -m frequenz.repo.config.cli.version.mike.info
340+
372341
- name: Fetch the gh-pages branch
373-
if: steps.mike-metadata.outputs.version
342+
if: steps.mike-version.outputs.version
374343
run: git fetch origin gh-pages --depth=1
375344

376-
- name: Publish site
377-
if: steps.mike-metadata.outputs.version
345+
- name: Build site
346+
if: steps.mike-version.outputs.version
378347
env:
379-
VERSION: ${{ steps.mike-metadata.outputs.version }}
380-
ALIASES: ${{ steps.mike-metadata.outputs.aliases }}
348+
VERSION: ${{ steps.mike-version.outputs.version }}
349+
TITLE: ${{ steps.mike-version.outputs.title }}
350+
ALIASES: ${{ steps.mike-version.outputs.aliases }}
351+
run: |
352+
mike deploy --update-aliases --title "$TITLE" "$VERSION" $ALIASES
353+
354+
- name: Sort site versions
355+
if: steps.mike-version.outputs.version
356+
run: |
357+
git checkout gh-pages
358+
python -m frequenz.repo.config.cli.version.mkdocs.sort versions.json
359+
git commit -a -m "Sort versions.json"
360+
361+
- name: Publish site
362+
if: steps.mike-version.outputs.version
381363
run: |
382-
mike deploy --push --update-aliases "$VERSION" $ALIASES
364+
git push origin gh-pages
383365
384366
create-github-release:
385367
name: Create GitHub release

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/.github/workflows/ci.yaml

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -331,78 +331,60 @@ jobs:
331331
permissions:
332332
contents: write
333333
steps:
334-
- name: Calculate and check version
335-
id: mike-metadata
336-
env:
337-
REF: ${{ github.ref }}
338-
REF_NAME: ${{ github.ref_name }}
339-
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
340-
run: |
341-
aliases=
342-
version=
343-
if test "$REF_NAME" = "$DEFAULT_BRANCH"
344-
then
345-
version=next
346-
# A tag that starts with vX.Y or X.Y
347-
elif echo "$REF" | grep -q '^refs/tags' && echo "$REF_NAME" | grep -Pq '^v?\d+\.\d+\.'
348-
then
349-
if echo "$REF_NAME" | grep -Pq -- "-" # pre-release
350-
then
351-
echo "::notice title=Documentation was not published::" \
352-
"The tag '$REF_NAME' looks like a pre-release."
353-
exit 0
354-
fi
355-
version=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+\.[0-9]+)\..*$/\1/') # vX.Y
356-
major=$(echo "$REF_NAME" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
357-
default_major=$(echo "$DEFAULT_BRANCH" | sed -r 's/^(v?[0-9]+)\..*$/\1/') # vX
358-
aliases=$major
359-
if test "$major" = "$default_major"
360-
then
361-
aliases="$aliases latest"
362-
fi
363-
else
364-
echo "::warning title=Documentation was not published::" \
365-
"Don't know how to handle '$REF' to make 'mike' version."
366-
exit 0
367-
fi
368-
echo "version=$version" >> $GITHUB_OUTPUT
369-
echo "aliases=$aliases" >> $GITHUB_OUTPUT
370-
371334
- name: Fetch sources
372-
if: steps.mike-metadata.outputs.version
373335
uses: actions/checkout@v4
374336
with:
375337
submodules: true
376338

377339
- name: Setup Git user and e-mail
378-
if: steps.mike-metadata.outputs.version
379340
uses: frequenz-floss/setup-git-user@v2
380341

381342
- name: Set up Python
382-
if: steps.mike-metadata.outputs.version
383343
uses: actions/setup-python@v4
384344
with:
385345
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
386346
cache: 'pip'
387347

388348
- name: Install build dependencies
389-
if: steps.mike-metadata.outputs.version
390349
run: |
391350
python -m pip install -U pip
392351
python -m pip install .[dev-mkdocs]
393352
pip freeze
394353
354+
- name: Calculate and check version
355+
id: mike-version
356+
env:
357+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
358+
GITHUB_REPO: ${{ github.repository }}
359+
GIT_REF: ${{ github.ref }}
360+
GIT_SHA: ${{ github.sha }}
361+
run: |
362+
python -m frequenz.repo.config.cli.version.mike.info
363+
395364
- name: Fetch the gh-pages branch
396-
if: steps.mike-metadata.outputs.version
365+
if: steps.mike-version.outputs.version
397366
run: git fetch origin gh-pages --depth=1
398367

399-
- name: Publish site
400-
if: steps.mike-metadata.outputs.version
368+
- name: Build site
369+
if: steps.mike-version.outputs.version
401370
env:
402-
VERSION: ${{ steps.mike-metadata.outputs.version }}
403-
ALIASES: ${{ steps.mike-metadata.outputs.aliases }}
371+
VERSION: ${{ steps.mike-version.outputs.version }}
372+
TITLE: ${{ steps.mike-version.outputs.title }}
373+
ALIASES: ${{ steps.mike-version.outputs.aliases }}
374+
run: |
375+
mike deploy --update-aliases --title "$TITLE" "$VERSION" $ALIASES
376+
377+
- name: Sort site versions
378+
if: steps.mike-version.outputs.version
379+
run: |
380+
git checkout gh-pages
381+
python -m frequenz.repo.config.cli.version.mkdocs.sort versions.json
382+
git commit -a -m "Sort versions.json"
383+
384+
- name: Publish site
385+
if: steps.mike-version.outputs.version
404386
run: |
405-
mike deploy --push --update-aliases "$VERSION" $ALIASES
387+
git push origin gh-pages
406388
407389
create-github-release:
408390
name: Create GitHub release

0 commit comments

Comments
 (0)