Skip to content
Latchkey

Publish Github release workflow (Diaoul/subliminal)

The Publish Github release workflow from Diaoul/subliminal, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: Diaoul/subliminal.github/workflows/publish-release.yamlLicense MITView source

What it does

This is the Publish Github release workflow from the Diaoul/subliminal 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

workflow (.yml)
name: Publish Github release

on:
  push:
    tags:
      - "*.*.*"
  workflow_call:
    inputs:
      tag-name:
        description: 'Tag name'
        required: true
        type: 'string'
  workflow_dispatch:
    inputs:
      tag-name:
        description: 'Tag name'
        required: true
        type: 'string'

permissions: {}

env:
  FORCE_COLOR: "1"
  PIP_DISABLE_PIP_VERSION_CHECK: "1"
  PIP_NO_PYTHON_VERSION_WARNING: "1"

jobs:
  # Always build & lint package.
  build-package:
    name: Build & verify package
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        if: github.event_name == 'push'
        with:
          persist-credentials: false
      - name: Checkout
        uses: actions/checkout@v7
        if: |
          github.event_name == 'workflow_dispatch'
          || github.event_name == 'workflow_call'
        with:
          ref: ${{ inputs.tag-name }}
          persist-credentials: false
      - name: Build dist
        uses: hynek/build-and-inspect-python-package@v2
        id: baipp
    outputs:
      tag: ${{ steps.baipp.outputs.package_version }}


  github-release:
    name: Make a GitHub Release
    needs: [build-package]
    if: github.repository == 'Diaoul/subliminal'
    runs-on: ubuntu-latest
    permissions:
      # IMPORTANT: mandatory for making GitHub Releases
      contents: write
      id-token: write

    # Publish a Github release when a tag was pushed, or it's called with a tag.
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-tags: true
          ref: ${{ needs.build-package.outputs.tag }}
          persist-credentials: false

      - name: Download packages built by build-and-inspect-python-package
        uses: actions/download-artifact@v8
        with:
          name: Packages
          path: dist
      - name: Publish GitHub Release
        uses: softprops/action-gh-release@v3
        with:
          files: dist/*
          generate_release_notes: true
          draft: true

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Publish Github release
 
on:
  push:
    tags:
      - "*.*.*"
  workflow_call:
    inputs:
      tag-name:
        description: 'Tag name'
        required: true
        type: 'string'
  workflow_dispatch:
    inputs:
      tag-name:
        description: 'Tag name'
        required: true
        type: 'string'
 
permissions: {}
 
env:
  FORCE_COLOR: "1"
  PIP_DISABLE_PIP_VERSION_CHECK: "1"
  PIP_NO_PYTHON_VERSION_WARNING: "1"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  # Always build & lint package.
  build-package:
    timeout-minutes: 30
    name: Build & verify package
    runs-on: latchkey-small
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        if: github.event_name == 'push'
        with:
          persist-credentials: false
      - name: Checkout
        uses: actions/checkout@v7
        if: |
          github.event_name == 'workflow_dispatch'
          || github.event_name == 'workflow_call'
        with:
          ref: ${{ inputs.tag-name }}
          persist-credentials: false
      - name: Build dist
        uses: hynek/build-and-inspect-python-package@v2
        id: baipp
    outputs:
      tag: ${{ steps.baipp.outputs.package_version }}
 
 
  github-release:
    timeout-minutes: 30
    name: Make a GitHub Release
    needs: [build-package]
    if: github.repository == 'Diaoul/subliminal'
    runs-on: latchkey-small
    permissions:
      # IMPORTANT: mandatory for making GitHub Releases
      contents: write
      id-token: write
 
    # Publish a Github release when a tag was pushed, or it's called with a tag.
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-tags: true
          ref: ${{ needs.build-package.outputs.tag }}
          persist-credentials: false
 
      - name: Download packages built by build-and-inspect-python-package
        uses: actions/download-artifact@v8
        with:
          name: Packages
          path: dist
      - name: Publish GitHub Release
        uses: softprops/action-gh-release@v3
        with:
          files: dist/*
          generate_release_notes: true
          draft: true
 

What changed

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.

This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow