Skip to content

Commit

Permalink
Update CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mardiros committed Nov 2, 2024
1 parent d86f55d commit 0879398
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 87 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Build envsub tarballs for supported python.

name: "Build artifact"

on:
workflow_call:
inputs:
release-version:
required: true
type: string
dry-run:
required: true
type: boolean
python-version:
required: true
type: string
pull_request:
paths:
# When we change pyproject.toml, we want to ensure that the maturin builds still work.
- pyproject.toml
# And when we change this workflow itself...
- .github/workflows/build-artifacts.yml

concurrency:
group: sdist-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
sdist:
name: Build artifact for ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install the project
run: uv sync

- name: Build tarball
run: uv build

- name: "Upload sdist"
uses: actions/upload-artifact@v4
with:
name: pypi_files
path: dist/*
20 changes: 0 additions & 20 deletions .github/workflows/gh-pages.yml

This file was deleted.

67 changes: 0 additions & 67 deletions .github/workflows/main.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/publish-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Doc

on:
workflow_call:
inputs:
release-version:
required: true
type: string
dry-run:
required: true
type: boolean

workflow_dispatch:

jobs:
pages:
runs-on: ubuntu-20.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write # Grants write access for GitHub Pages
id-token: write # Enables id-token for OIDC tokens
steps:
- id: deployment
uses: sphinx-notes/pages@v3
with:
documentation_path: docs/source
publish: ${{ !inputs.dry-run }}
python_version: 3.12
35 changes: 35 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Publish a release to PyPI.
#
name: "Publish to PyPI"

on:
workflow_call:
inputs:
release-version:
required: true
type: string
dry-run:
required: true
type: boolean

jobs:
pypi-publish:
name: Upload to PyPI ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
runs-on: ubuntu-latest
if: ${{ !inputs.dry-run }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: pypi_files
path: dist
merge-multiple: true

- uses: pdm-project/setup-pdm@v4
with:
python-version: 3.12

- name: Publish package distributions to PyPI
run: pdm publish --no-build
105 changes: 105 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Release

on:
push:
tags:
- 'v*' # Automatically trigger on version tags
- 'dry-run'

workflow_dispatch:
inputs:
tag:
description: "Release Tag"
required: true
default: "dry-run"
type: string

env:
PYTHON_VERSION: "3.12"

permissions:
contents: read
id-token: write
pages: write

jobs:
plan:
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.release-version.outputs.release_version }}
dry-run: ${{ steps.release-version.outputs.dry_run }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Release Version
id: release-version
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "release_version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
if [ "${{ github.ref_name }}" == "dry-run" ]; then
echo "dry_run=true" >> $GITHUB_OUTPUT
else
echo "dry_run=false" >> $GITHUB_OUTPUT
fi
else
version="${{ github.event.inputs.tag || 'dry-run' }}"
if [ "${version}" == "dry-run" ]; then
echo "release_version=latest" >> $GITHUB_OUTPUT
echo "dry_run=true" >> $GITHUB_OUTPUT
else
echo "release_version=${version}" >> $GITHUB_OUTPUT
echo "dry_run=false" >> $GITHUB_OUTPUT
fi
fi
- name: Display Release Version
run: echo "The release version is ${{ steps.release-version.outputs.release_version }}"

unit-tests:
uses: ./.github/workflows/tests.yml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build-artifacts:
needs:
- plan
- unit-tests
uses: ./.github/workflows/build-artifacts.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}
python-version: '3.12'

tests-artifacts:
needs:
- plan
- build-artifacts
uses: ./.github/workflows/tests-artifacts.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}

publish-pypi:
needs:
- plan
- tests-artifacts
uses: ./.github/workflows/publish-pypi.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}
permissions:
contents: read
id-token: write

publish-doc:
needs:
- plan
- tests-artifacts
uses: ./.github/workflows/publish-doc.yml
with:
release-version: ${{ needs.plan.outputs.release_version }}
dry-run: ${{ needs.plan.outputs.dry-run == 'true' }}
permissions:
id-token: write
pages: write
34 changes: 34 additions & 0 deletions .github/workflows/tests-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: tests artifacts

# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_call:
inputs:
release-version:
required: true
type: string
description: "release number"
dry-run:
required: true
type: boolean
description: "blank run means that the release will not be pushed"

jobs:
test-sdist:
name: test tarball archive of ${{ inputs.release-version }} ${{ inputs.dry-run && '(dry-run)' || '' }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: pypi_files
path: dist
merge-multiple: true

- name: "Install"
run: |
pip install dist/blacksmith-*.whl --force-reinstall
- name: "Test sdist"
run: |
python -c "from blacksmith import __version__; print(__version__, end='')"
Loading

0 comments on commit 0879398

Please sign in to comment.