Publish On Tag workflow (brentvollebregt/auto-py-to-exe)
The Publish On Tag workflow from brentvollebregt/auto-py-to-exe, explained and optimized by Latchkey.
CI health: F - at risk
Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Publish On Tag workflow from the brentvollebregt/auto-py-to-exe repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Publish On Tag
on:
push:
tags:
- 'v*'
jobs:
initial-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Only allow tags on master to be published
run: |
tag_commit=$(git rev-parse ${{ github.ref }})
master_commit=$(git rev-parse origin/master)
if [ "$tag_commit" = "$master_commit" ]; then
echo "The tag and master are pointing to the same commit."
else
echo "The tag ($tag_commit) and master ($master_commit) are not pointing to the same commit."
exit 1
fi
publish:
needs: [initial-checks]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install setuptools wheel twine
- name: Get module version
id: get_module_version
run: |
version=$(python -c "from auto_py_to_exe import __version__ as v; print(v)")
echo "Module version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Fail on tag and module version mismatch
if: (!endsWith(github.ref, steps.get_module_version.outputs.version))
run: |
echo "Ref that triggered release: ${{ github.ref }}"
echo "Current module version: ${{ steps.get_module_version.outputs.version }}"
exit 1
- name: Get documented version changes from CHANGELOG.md
id: get_documented_changes
run: python get-changelog-for-version.py --version ${{steps.get_module_version.outputs.version }}
working-directory: ./.github/workflow_utils
- name: Build distribution
run: python setup.py sdist bdist_wheel --universal
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create release
id: create_release
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.get_module_version.outputs.version }}
name: v${{ steps.get_module_version.outputs.version }}
draft: false
prerelease: false
body: ${{ steps.get_documented_changes.outputs.changes }}
files: |
./dist/auto_py_to_exe-${{ steps.get_module_version.outputs.version }}-py2.py3-none-any.whl
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Publish On Tag on: push: tags: - 'v*' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: initial-checks: timeout-minutes: 30 runs-on: latchkey-small steps: - uses: actions/checkout@v6 with: fetch-depth: 0 - name: Only allow tags on master to be published run: | tag_commit=$(git rev-parse ${{ github.ref }}) master_commit=$(git rev-parse origin/master) if [ "$tag_commit" = "$master_commit" ]; then echo "The tag and master are pointing to the same commit." else echo "The tag ($tag_commit) and master ($master_commit) are not pointing to the same commit." exit 1 fi publish: timeout-minutes: 30 needs: [initial-checks] runs-on: latchkey-small permissions: id-token: write contents: write steps: - uses: actions/checkout@v6 - name: Set up Python 3.12 uses: actions/setup-python@v6 with: cache: 'pip' python-version: 3.12 - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install setuptools wheel twine - name: Get module version id: get_module_version run: | version=$(python -c "from auto_py_to_exe import __version__ as v; print(v)") echo "Module version: $version" echo "version=$version" >> $GITHUB_OUTPUT - name: Fail on tag and module version mismatch if: (!endsWith(github.ref, steps.get_module_version.outputs.version)) run: | echo "Ref that triggered release: ${{ github.ref }}" echo "Current module version: ${{ steps.get_module_version.outputs.version }}" exit 1 - name: Get documented version changes from CHANGELOG.md id: get_documented_changes run: python get-changelog-for-version.py --version ${{steps.get_module_version.outputs.version }} working-directory: ./.github/workflow_utils - name: Build distribution run: python setup.py sdist bdist_wheel --universal - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 - name: Create release id: create_release uses: softprops/action-gh-release@v3 with: tag_name: v${{ steps.get_module_version.outputs.version }} name: v${{ steps.get_module_version.outputs.version }} draft: false prerelease: false body: ${{ steps.get_documented_changes.outputs.changes }} files: | ./dist/auto_py_to_exe-${{ steps.get_module_version.outputs.version }}-py2.py3-none-any.whl
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.