Skip to content

Commit 4fbdb16

Browse files
committed
release for exes
1 parent c5f4698 commit 4fbdb16

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

template/.github/workflows/{% if not deploy_as_executable %}release.yaml{% endif %}.jinja renamed to template/.github/workflows/release.yaml.jinja

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
exit 1
9191
fi
9292
fi
93+
{% endraw %}{% if not deploy_as_executable %}{% raw %}
9394

9495
publish-to-staging:
9596
name: Publish Python distribution to Staging Package Registry
@@ -220,14 +221,15 @@ jobs:
220221
print(f"Installed distribution version: {installed} (expected {expected})")
221222
assert installed == expected, f"Version mismatch: expected {expected}, got {installed}"
222223
PY
224+
{% endraw %}{% endif %}{% raw %}
223225

224226
create-tag:
225227
name: Create the git tag
226228
if: ${{ !inputs.dry_run }}
227229
timeout-minutes: {% endraw %}{{ gha_medium_timeout_minutes }}{% raw %}
228230
needs:
229-
- install-from-staging
230-
- guard
231+
{% endraw %}{% if not deploy_as_executable %}{% raw %} - install-from-staging
232+
{% endraw %}{% endif %}{% raw %} - guard
231233
permissions:
232234
contents: write # needed to push the tag
233235
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
@@ -242,6 +244,7 @@ jobs:
242244
run: python3 ./.github/workflows/git_tag.py --version "${{ needs.guard.outputs.version }}" --confirm-tag-not-present
243245
- name: Create tag
244246
run: python3 ./.github/workflows/git_tag.py --version "${{ needs.guard.outputs.version }}" --push-tag-to-remote
247+
{% endraw %}{% if not deploy_as_executable %}{% raw %}
245248

246249
publish-to-primary:
247250
name: Publish Python distribution to Primary Package Registry
@@ -373,21 +376,39 @@ jobs:
373376
print(f"Installed distribution version: {installed} (expected {expected})")
374377
assert installed == expected, f"Version mismatch: expected {expected}, got {installed}"
375378
PY
379+
{% endraw %}{% endif %}{% raw %}
376380

377381
release:
378382
name: Create GitHub Release
379383
if: ${{ !inputs.dry_run }}
380384
runs-on: {% endraw %}{{ gha_linux_runner }}{% raw %}
381385
timeout-minutes: {% endraw %}{{ gha_short_timeout_minutes }}{% raw %}
382386
needs:
383-
- install-from-primary
384-
- guard
387+
{% endraw %}{% if not deploy_as_executable %}{% raw %} - install-from-primary
388+
{% endraw %}{% else %}{% raw %} - create-tag
389+
{% endraw %}{% endif %}{% raw %} - guard
385390
permissions:
386-
contents: write # needed to create GitHub releases
387-
steps:
391+
contents: write # needed to create GitHub releases{% endraw %}{% if deploy_as_executable %}{% raw %}
392+
actions: read # needed to download the executable artifacts from the CI run{% endraw %}{% endif %}{% raw %}
393+
steps:{% endraw %}{% if deploy_as_executable %}{% set exe_os_list = [gha_linux_runner] + ([gha_windows_runner] if use_windows_in_exe_ci else []) %}{% for exe_os in exe_os_list %}{% for exe_py in python_ci_versions %}{% set ext = "tar" if exe_os == gha_linux_runner else "zip" %}{% raw %}
394+
- name: Download executable artifact ({% endraw %}{{ exe_os }} py{{ exe_py }}{% raw %})
395+
uses: actions/download-artifact@{% endraw %}{{ gha_download_artifact }}{% raw %}
396+
with:
397+
name: exe-{% endraw %}{{ exe_os }}-{{ exe_py }}{% raw %}
398+
path: artifacts/{% endraw %}{{ exe_os }}-{{ exe_py }}{% raw %}
399+
run-id: ${{ needs.guard.outputs.ci-run-id }}
400+
github-token: ${{ github.token }}
401+
- name: Package executable ({% endraw %}{{ exe_os }} py{{ exe_py }}{% raw %})
402+
shell: bash
403+
run: {% endraw %}{% if exe_os == gha_linux_runner %}tar -cf "{{ repo_name }}-{{ exe_os }}-{{ exe_py }}-v{% raw %}${{ needs.guard.outputs.version }}{% endraw %}.{{ ext }}" -C "artifacts/{{ exe_os }}-{{ exe_py }}" .{% else %}(cd "artifacts/{{ exe_os }}-{{ exe_py }}" && zip -r "../../{{ repo_name }}-{{ exe_os }}-{{ exe_py }}-v{% raw %}${{ needs.guard.outputs.version }}{% endraw %}.{{ ext }}" .){% endif %}{% raw %}
404+
{% endraw %}{% endfor %}{% endfor %}{% endif %}{% raw %}
388405
- name: Create GitHub Release
389406
uses: softprops/action-gh-release@{% endraw %}{{ gha_action_gh_release }}{% raw %}
390407
with:
391408
tag_name: v${{ needs.guard.outputs.version }}
392409
name: {% endraw %}{{ repo_name }}{% raw %} v${{ needs.guard.outputs.version }}
393-
generate_release_notes: true{% endraw %}
410+
generate_release_notes: true{% endraw %}{% if deploy_as_executable %}{% raw %}
411+
fail_on_unmatched_files: true
412+
files: |{% endraw %}{% set exe_os_list = [gha_linux_runner] + ([gha_windows_runner] if use_windows_in_exe_ci else []) %}{% for exe_os in exe_os_list %}{% for exe_py in python_ci_versions %}{% set ext = "tar" if exe_os == gha_linux_runner else "zip" %}
413+
{{ repo_name }}-{{ exe_os }}-{{ exe_py }}-v{% raw %}${{ needs.guard.outputs.version }}{% endraw %}.{{ ext }}{% endfor %}{% endfor %}{% endif %}{% raw %}
414+
{% endraw %}

‎template/README.md.jinja‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ Documentation is hosted on [ReadTheDocs](https://{% endraw %}{{ package_name }}{
2525
# Development
2626
This project has a dev container. If you already have VS Code and Docker installed, you can click the badge above or [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url={% endraw %}{{ full_repo_url }}{% raw %}) to get started. Clicking these links will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
2727

28-
To publish a new version of the repository, you can run the `Publish` workflow manually and publish to the staging registry from any branch, and you can check the 'Publish to Primary' option when on `main` to publish to the primary registry and create a git tag.
29-
30-
The `Release` workflow is an alternative that reuses the checks from CI instead of re-running them. Rather than rebuilding and re-testing, it requires that the `CI` workflow has already completed successfully for the current commit (including the `workflow-summary` job) and downloads the distribution that CI built. Trigger it manually with `workflow_dispatch`; a real release must be run from `main`, while the `dry_run` option lets you exercise the workflow from any branch without publishing, tagging, or creating a release. A real run publishes to the staging registry and verifies a fresh install, then pushes the `v<version>` git tag, publishes to the primary registry, verifies the install again, and finally creates a GitHub Release with auto-generated notes.
28+
{% endraw %}{% if not deploy_as_executable %}{% raw %}To publish a new version of the repository, you can run the `Publish` workflow manually and publish to the staging registry from any branch, and you can check the 'Publish to Primary' option when on `main` to publish to the primary registry and create a git tag.
3129

30+
{% endraw %}{% endif %}{% raw %}The `Release` workflow reuses the checks from CI instead of re-running them: it requires that the `CI` workflow has already completed successfully for the current commit (including the `workflow-summary` job) and reuses the artifacts CI built rather than rebuilding. Trigger it manually with `workflow_dispatch`; a real release must be run from `main`, while the `dry_run` option lets you exercise the workflow from any branch without tagging or releasing. {% endraw %}{% if deploy_as_executable %}{% raw %}A real run pushes the `v<version>` git tag and creates a GitHub Release, attaching the executable that CI built for every OS and Python version.{% endraw %}{% else %}{% raw %}A real run publishes the CI-built distribution to the staging registry and verifies a fresh install, then pushes the `v<version>` git tag, publishes to the primary registry, verifies the install again, and finally creates a GitHub Release with auto-generated notes.{% endraw %}{% endif %}{% raw %}
31+
{% endraw %}{% if not deploy_as_executable %}{% raw %}
3232
<!-- TODO: migrate away from the `Publish` and `Publish to Staging` workflows and merge all of their functionality into the `Release` workflow. -->
33+
{% endraw %}{% endif %}{% raw %}
3334

3435

3536

0 commit comments

Comments
 (0)