Improve workflows

This commit is contained in:
Sina Atalay
2025-02-05 18:01:41 -05:00
parent f6f8c490f4
commit 38ffe33138
7 changed files with 129 additions and 101 deletions

View File

@@ -0,0 +1,35 @@
name: Create executables
# GitHub events that triggers the workflow:
on:
workflow_call: # to make the workflow triggerable from other workflows (publish-a-release.yaml)
workflow_dispatch: # to make the workflow triggerable manually
jobs:
create_executables:
name: For ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-22.04-arm, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install Hatch
uses: pypa/hatch@install
- name: Create executable
run: |
hatch run exe:create
- name: Upload executable as an artifact
uses: actions/upload-artifact@v4
with:
name: rendercv-${{ matrix.os }}
path: bin/*

View File

@@ -36,7 +36,7 @@ jobs:
run: |
hatch run docs:build
- name: Upload artifact
- name: Upload the website as an artifact
uses: actions/upload-pages-artifact@v3
with:
path: site

View File

@@ -1,4 +1,4 @@
name: Publish a Release
name: Publish a release
# GitHub events that triggers the workflow:
on:
@@ -6,42 +6,11 @@ on:
types:
- published
permissions:
contents: write
jobs:
call_test_workflow:
name: Run Tests
uses: ./.github/workflows/test.yaml
create_executables:
name: Create Executables
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
runs-on: ${{ matrix.os }}-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install Hatch
uses: pypa/hatch@install
- name: Create executable
run: |
hatch run exe:create
- name: Upload executable
uses: softprops/action-gh-release@v2
with:
files: |
bin/*
publish_to_pypi:
name: Publish to PyPI
needs:
@@ -65,22 +34,19 @@ jobs:
run: |
hatch build
- name: Upload wheel and source distribution
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.whl
dist/*.tar.gz
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish_to_dockerhub:
name: Publish to Docker Hub
- name: Upload the wheel and source distribution as artifacts
uses: actions/upload-artifact@v4
with:
path: dist
publish_to_dockerhub_and_ghcr:
name: Push Docker image to Docker Hub and GitHub Container Registry
runs-on: ubuntu-latest
needs:
- publish_to_pypi
runs-on: ubuntu-latest
environment: release
permissions:
packages: write
contents: read
@@ -90,24 +56,32 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: rendercv/rendercv
images: |
rendercv/rendercv
ghcr.io/${{ github.repository }}
- name: Build and push Docker image
- name: Build and push Docker images
id: push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
@@ -115,7 +89,7 @@ jobs:
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: rendercv/rendercv
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
@@ -124,3 +98,23 @@ jobs:
needs:
- publish_to_pypi
uses: ./.github/workflows/update-files.yaml
call_create_executables_workflow:
name: Create Executables
needs:
- publish_to_pypi
uses: ./.github/workflows/create-executables.yaml
upload_release_files:
name: Create release files
needs:
- publish_to_pypi
- call_create_executables_workflow
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download the executables
uses: actions/download-artifact@v2
with:
name: executables

View File

@@ -35,7 +35,7 @@ jobs:
- name: Rename the coverage file
run: mv .coverage .coverage.${{ matrix.python-version }}.${{ matrix.os }}
- name: Store coverage files
- name: Upload coverage as an artifact
uses: actions/upload-artifact@v4
with:
include-hidden-files: true

View File

@@ -2,7 +2,7 @@ name: Update files
# GitHub events that triggers the workflow:
on:
workflow_call: # to make the workflow triggerable from other workflows (on-publish.yaml)
workflow_call: # to make the workflow triggerable from other workflows (publish-a-release.yaml)
workflow_dispatch: # to make the workflow triggerable manually
jobs:
@@ -29,7 +29,6 @@ jobs:
run: |
hatch run update-schema
git add schema.json
git commit -m "docs: update schema.json"
- name: Update `examples` folder
continue-on-error: true
@@ -37,16 +36,15 @@ jobs:
hatch run update-examples
git add examples/*
git add docs/assets/images/*.png
git commit -m "docs: update examples"
- name: Update entry figures
continue-on-error: true
run: |
hatch run docs:update-entry-figures
git add docs/assets/images/**/*.png
git commit -m "docs: update entry figures"
- name: Push changes
continue-on-error: true
run: |
git commit -m "Update schema.json, examples, and entry figures"
git push origin HEAD:main