Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions .github/workflows/_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,9 @@ jobs:

- name: Test cli works in cached runtime image
run: docker run --rm tag_for_testing --version

- name: Create tags for publishing image
id: meta
uses: docker/metadata-action@v5

- name: Upload container as artifact
uses: actions/upload-artifact@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest

- name: Push cached image to container registry
if: github.ref_type == 'tag'
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
# This does not build the image again, it will find the image in the
# Docker cache and publish it
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
name: container
path: container
19 changes: 0 additions & 19 deletions .github/workflows/_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,3 @@ jobs:
with:
name: docs
path: build

- name: Sanitize ref name for docs version
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV

- name: Move to versioned directory
run: mv build/html .github/pages/$DOCS_VERSION

- name: Write switcher.json
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json

- name: Publish Docs to gh-pages
if: github.ref_type == 'tag' || github.ref_name == 'main'
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true
35 changes: 35 additions & 0 deletions .github/workflows/_push_container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
workflow_call:

jobs:
push:
runs-on: ubuntu-latest

steps:
- name: Download container artifact
uses: actions/download-artifact@v4
with:
name: container
path: container

- name: Create tags for publishing image
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=raw,value=latest

- name: Push cached image to container registry
if: github.ref_type == 'tag'
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_RECORD_UPLOAD: false
# This does not build the image again, it will find the image in the
# Docker cache and publish it
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
38 changes: 38 additions & 0 deletions .github/workflows/_push_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Need this to get version number from last tag
fetch-depth: 0

- name: Download built docs artifact
uses: actions/download-artifact@v4
with:
name: docs
path: build

- name: Sanitize ref name for docs version
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z-1-9._-]/_}" >> $GITHUB_ENV

- name: Move to versioned directory
run: mv build/html .github/pages/$DOCS_VERSION

- name: Write switcher.json
run: python .github/pages/make_switcher.py --add $DOCS_VERSION ${{ github.repository }} .github/pages/switcher.json

- name: Publish Docs to gh-pages
if: github.ref_type == 'tag' || github.ref_name == 'main'
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
permissions:
contents: write

push_docs:
needs: docs
uses: ./.github/workflows/_push_docs.yml
permissions:
contents: write

example:
needs: test
if: github.ref_name == 'main'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,25 @@ jobs:
permissions:
contents: read
packages: write

push_container:
if: github.ref_type == 'tag'
needs: [container, test]
uses: ./.github/workflows/_push_container.yml
permissions:
contents: read
packages: write
{% endif %}{% if sphinx %}
docs:
needs: check
if: needs.check.outputs.branch-pr == ''
uses: ./.github/workflows/_docs.yml

push_docs:
needs: docs
uses: ./.github/workflows/_push_docs.yml
permissions:
contents: write
{% endif %}
dist:
needs: check
Expand All @@ -54,14 +68,14 @@ jobs:
{% if pypi %}
pypi:
if: github.ref_type == 'tag'
needs: dist
needs: [dist, test]
uses: ./.github/workflows/_pypi.yml
permissions:
id-token: write
{% endif %}
release:
if: github.ref_type == 'tag'
needs: [dist{% if sphinx %}, docs{% endif %}]
needs: [dist, test{% if sphinx %}, docs{% endif %}]
uses: ./.github/workflows/_release.yml
permissions:
contents: write