mirror of
https://github.com/rendercv/rendercv.git
synced 2025-12-23 21:47:55 -05:00
Improve workflows
This commit is contained in:
35
.github/workflows/create-executables.yaml
vendored
Normal file
35
.github/workflows/create-executables.yaml
vendored
Normal 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/*
|
||||
2
.github/workflows/deploy-docs.yaml
vendored
2
.github/workflows/deploy-docs.yaml
vendored
@@ -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
|
||||
|
||||
90
.github/workflows/publish-a-release.yaml
vendored
90
.github/workflows/publish-a-release.yaml
vendored
@@ -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
|
||||
|
||||
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
@@ -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
|
||||
|
||||
6
.github/workflows/update-files.yaml
vendored
6
.github/workflows/update-files.yaml
vendored
@@ -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
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
def create_executable():
|
||||
# Make sure the current working directory is the root of the project:
|
||||
root = pathlib.Path(__file__).parent.parent
|
||||
os.chdir(root)
|
||||
|
||||
rendercv_file_path = root / "rendercv.py"
|
||||
rendercv_file_path.touch()
|
||||
rendercv_file_path.write_text("import rendercv.cli as cli; cli.app()")
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
# copy rendercv to temp directory
|
||||
shutil.copytree(root / "rendercv", pathlib.Path(temp_dir) / "rendercv")
|
||||
temp_directory = pathlib.Path(temp_dir)
|
||||
rendercv_file_path = temp_directory / "rendercv.py"
|
||||
rendercv_file_path.touch()
|
||||
rendercv_file_path.write_text("import rendercv.cli as cli; cli.app()")
|
||||
|
||||
# Run pyinstaller:
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"PyInstaller",
|
||||
"--onefile",
|
||||
"--clean",
|
||||
"--collect-all",
|
||||
"rendercv",
|
||||
"--collect-all",
|
||||
"rendercv_fonts",
|
||||
"--distpath",
|
||||
"bin",
|
||||
str(rendercv_file_path),
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
# Run pyinstaller:
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"PyInstaller",
|
||||
"--onefile",
|
||||
"--clean",
|
||||
"--collect-all",
|
||||
"rendercv",
|
||||
"--collect-all",
|
||||
"rendercv_fonts",
|
||||
"--distpath",
|
||||
"bin",
|
||||
str(rendercv_file_path),
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
# Remove the temporary file:
|
||||
rendercv_file_path.unlink()
|
||||
(root / "rendercv.spec").unlink()
|
||||
|
||||
# Rename the executable:
|
||||
platform = {
|
||||
"linux": "linux",
|
||||
"darwin": "macos",
|
||||
"win32": "windows",
|
||||
}
|
||||
if sys.platform == "win32":
|
||||
executable_path = root / "bin" / "rendercv.exe"
|
||||
executable_path.rename(
|
||||
# Rename the executable:
|
||||
platform_name = {
|
||||
"linux": "linux",
|
||||
"darwin": "macos",
|
||||
"win32": "windows",
|
||||
}
|
||||
executable_path = {
|
||||
"linux": root / "bin" / "rendercv",
|
||||
"darwin": root / "bin" / "rendercv",
|
||||
"win32": root / "bin" / "rendercv.exe",
|
||||
}
|
||||
new_executable_path = (
|
||||
root
|
||||
/ "bin"
|
||||
/ f"rendercv-{platform[sys.platform]}-{os.environ['PROCESSOR_ARCHITECTURE']}"
|
||||
)
|
||||
else:
|
||||
executable_path = root / "bin" / "rendercv"
|
||||
executable_path.rename(
|
||||
root / "bin" / f"rendercv-{platform[sys.platform]}-{os.uname().machine}"
|
||||
/ f"rendercv-{platform_name[sys.platform]}-{platform.machine()}"
|
||||
)
|
||||
executable_path[sys.platform].rename(new_executable_path)
|
||||
|
||||
print('Executable created at "bin" folder.') # NOQA: T201
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ import pytest
|
||||
"docs:update-entry-figures",
|
||||
],
|
||||
)
|
||||
@pytest.mark.skip(reason="They fail on GitHub Actions")
|
||||
def test_scripts(script_name):
|
||||
# If hatch is not installed, just pass the test
|
||||
# If hatch is not installed, just pass the test (supress FileNotFoundError)
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
subprocess.run(["hatch", "run", script_name], check=True)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="They fail on GitHub Actions")
|
||||
def test_executable():
|
||||
# If hatch is not installed, just pass the test
|
||||
# If hatch is not installed, just pass the test (supress FileNotFoundError)
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
root = pathlib.Path(__file__).parent.parent
|
||||
bin_folder = root / "bin"
|
||||
@@ -37,7 +39,7 @@ def test_executable():
|
||||
file.unlink()
|
||||
bin_folder.rmdir()
|
||||
|
||||
subprocess.run(["hatch", "run", "exe:create"], check=True)
|
||||
subprocess.run(["hatch", "run", "exe:create"], check=True, timeout=60)
|
||||
|
||||
executable_path = next(bin_folder.iterdir())
|
||||
assert executable_path.is_file()
|
||||
@@ -47,5 +49,4 @@ def test_executable():
|
||||
subprocess.run([str(executable_path), "new", "John"], check=True)
|
||||
subprocess.run([str(executable_path), "render", "John_CV.yaml"], check=True)
|
||||
pdf_path = pathlib.Path(temp_dir) / "rendercv_output" / "John_CV.pdf"
|
||||
|
||||
assert pdf_path.exists()
|
||||
assert pdf_path.exists()
|
||||
|
||||
Reference in New Issue
Block a user