Upgrade to Poetry 2.0 & project metadata updates #382
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dist build | |
on: | |
push: | |
paths: | |
- pyproject.toml | |
- poetry.lock | |
- '**.py' | |
- '.github/**' | |
- 'resources/**' | |
- 'scripts/**' | |
tags: | |
- '*' | |
pull_request: | |
paths: | |
- pyproject.toml | |
- poetry.lock | |
- '**.py' | |
- '.github/**' | |
- 'resources/**' | |
- 'scripts/**' | |
merge_group: | |
types: [checks_requested] | |
jobs: | |
# https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional | |
prepare_matrix_linux: | |
name: "Prepare the job's matrix (Linux)" | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.gen_matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate the matrix | |
id: gen_matrix | |
run: scripts/gen_matrix.py linux | |
env: | |
RUYI_PR_TITLE: ${{ github.event.pull_request.title }} | |
prepare_matrix_windows: | |
name: "Prepare the job's matrix (Windows)" | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.gen_matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate the matrix | |
id: gen_matrix | |
run: scripts/gen_matrix.py windows | |
env: | |
RUYI_PR_TITLE: ${{ github.event.pull_request.title }} | |
dist: | |
needs: | |
- prepare_matrix_linux | |
strategy: | |
# arch: str | |
# build_output_name: str | |
# is_windows: bool | |
# job_name: str | |
# runs_on: RunsOn | |
# skip: bool | |
# upload_artifact_name: str | |
matrix: ${{ fromJson(needs.prepare_matrix_linux.outputs.matrix) }} | |
name: ${{ matrix.job_name }} | |
runs-on: ${{ matrix.runs_on }} | |
outputs: | |
run_id: ${{ github.run_id }} | |
release_mirror_url: ${{ steps.run_dist.outputs.release_mirror_url }} | |
container: | |
image: ghcr.io/ruyisdk/ruyi-python-dist:20240827 | |
options: --user root # https://github.com/actions/checkout/issues/1014 | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
volumes: | |
- ${{ github.workspace }}:/home/b/ruyi | |
- tmp-build:/build | |
- tmp-poetry-cache:/poetry-cache | |
- tmp-ccache:/ccache | |
- tmp-ruyi-dist-cache:/ruyi-dist-cache | |
env: | |
# this has to mirror the setup in scripts/dist.sh | |
CCACHE_DIR: /ccache | |
POETRY_CACHE_DIR: /poetry-cache | |
RUYI_DIST_BUILD_DIR: /build | |
RUYI_DIST_CACHE_DIR: /ruyi-dist-cache | |
RUYI_DIST_INNER_CONTAINERIZED: x | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache deps and Nuitka output | |
if: success() && !matrix.skip | |
uses: actions/cache@v4 | |
with: | |
key: ${{ runner.os }}-tgt-${{ matrix.arch }}-r4 | |
path: | | |
/ccache | |
/poetry-cache | |
/ruyi-dist-cache | |
- name: Run dist | |
if: success() && !matrix.skip | |
id: run_dist | |
run: RUYI_DIST_INNER=x /home/b/ruyi/scripts/dist.sh ${{ matrix.arch }} | |
- name: Upload artifact | |
if: success() && !matrix.skip | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.upload_artifact_name }} | |
path: /build/${{ matrix.build_output_name }} | |
compression-level: 0 # the Nuitka onefile payload is already compressed | |
dist-windows: | |
needs: | |
- prepare_matrix_windows | |
strategy: | |
# arch: str | |
# build_output_name: str | |
# is_windows: bool | |
# job_name: str | |
# runs_on: RunsOn | |
# skip: bool | |
# upload_artifact_name: str | |
matrix: ${{ fromJson(needs.prepare_matrix_windows.outputs.matrix) }} | |
name: ${{ matrix.job_name }} | |
runs-on: ${{ matrix.runs_on }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Poetry | |
if: success() && !matrix.skip | |
run: pipx install poetry | |
- uses: actions/setup-python@v5 | |
if: success() && !matrix.skip | |
with: | |
# don't let the ">=" directive bump the Python version without letting | |
# us know | |
# python-version-file: pyproject.toml | |
python-version: '3.12' | |
cache: poetry | |
- name: Cache/restore Nuitka clcache contents | |
if: success() && !matrix.skip | |
uses: actions/cache@v4 | |
with: | |
key: ${{ runner.os }}-tgt-${{ matrix.arch }} | |
path: | | |
/clcache | |
- name: Install deps | |
if: success() && !matrix.skip | |
run: poetry install && mkdir /build | |
- name: Run dist | |
if: success() && !matrix.skip | |
run: "scripts\\dist.ps1" | |
- name: Upload artifact | |
if: success() && !matrix.skip | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.upload_artifact_name }} | |
path: /build/${{ matrix.build_output_name }} | |
compression-level: 0 # the Nuitka onefile payload is already compressed | |
dist-src: | |
name: Source archive | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# for git-describe to work, but also https://github.com/actions/checkout/issues/1467 | |
# fetch-tags: true | |
fetch-depth: 0 | |
- name: Fetch Git tags | |
run: git fetch --tags --force | |
- name: Reproducibly pack the sources | |
id: pack_sources | |
run: ./scripts/make-reproducible-source-tarball.sh /tmp | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.pack_sources.outputs.artifact_name }} | |
path: /tmp/${{ steps.pack_sources.outputs.artifact_name }} | |
compression-level: 0 # the archive is already compressed | |
release: | |
name: Make a GitHub Release | |
runs-on: ubuntu-latest | |
if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
needs: | |
- dist | |
- dist-src | |
- dist-windows | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version-file: 'pyproject.toml' | |
- name: Download dist build artifacts for release | |
uses: actions/download-artifact@v4 | |
with: | |
run-id: ${{ needs.dist.outputs.run_id }} | |
path: tmp/release | |
- name: Organize release artifacts | |
run: scripts/organize-release-artifacts.py tmp/release | |
- name: Render the release notes header | |
run: sed "s!@RELEASE_MIRROR_URL@!${{ needs.dist.outputs.release_mirror_url }}!g" < resources/release-notes-header-template.md > tmp/release-notes-header.md | |
- name: Make the release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: tmp/release-notes-header.md | |
files: tmp/release/ruyi-* | |
generate_release_notes: true | |
prerelease: ${{ contains(needs.dist.outputs.release_mirror_url, 'testing') }} |