Skip to content
Latchkey

Draft new release workflow (ProjectQ-Framework/ProjectQ)

The Draft new release workflow from ProjectQ-Framework/ProjectQ, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get 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: ProjectQ-Framework/ProjectQ.github/workflows/draft_release.ymlLicense Apache-2.0View source

What it does

This is the Draft new release workflow from the ProjectQ-Framework/ProjectQ repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
---

name: "Draft new release"

on:  # yamllint disable-line rule:truthy
  workflow_dispatch:
    inputs:
      tag:
        description: 'Tag to prepare (format: vXX.YY.ZZ)'
        required: true
jobs:
  new-release:
    name: "Draft a new release"
    runs-on: ubuntu-latest
    steps:
      - name: Install git-flow
        run: sudo apt update && sudo apt install -y git-flow

      - uses: actions/checkout@v3

      - name: Setup Python
        uses: actions/setup-python@v3
        with:
          python-version: '3.11'
          cache: 'pip'
          cache-dependency-path: '**/setup.cfg'

      - name: Configure git-flow
        run: |
          git fetch --tags --depth=1 origin master develop
          git flow init --default --tag v

      - name: Create release branch
        run: git flow release start ${{ github.event.inputs.tag }}

      - name: Initialize mandatory git config
        run: |
          git config user.name "GitHub actions"
          git config user.email noreply@github.com

      - name: Update CHANGELOG
        run: |
          python3 -m pip install mdformat-gfm 'git+https://github.com/Takishima/keepachangelog@v1.0.1'
          python3 -m keepachangelog release "${{ github.event.inputs.tag }}"
          python3 -m mdformat CHANGELOG.md

      - name: Commit changelog and manifest files
        id: make-commit
        run: |
          git add CHANGELOG.md
          git commit --message "Preparing release ${{ github.event.inputs.tag }}"

          echo "::set-output name=commit::$(git rev-parse HEAD)"

      - name: Push new branch
        run: git flow release publish ${{ github.event.inputs.tag }}

      # yamllint disable rule:line-length
      - name: Create pull request
        uses: thomaseizinger/create-pull-request@1.3.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          head: release/${{ github.event.inputs.tag }}
          base: master
          title: Release version ${{ github.event.inputs.tag }}
          reviewers: ${{ github.actor }}
          # Write a nice message to the user.
          # We are claiming things here based on the `publish-new-release.yml` workflow.
          # You should obviously adopt it to say the truth depending on your release workflow :)
          body: |
            Hi @${{ github.actor }}!

            This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
            I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.

            Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.

The same workflow, on Latchkey

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

---
 
name: "Draft new release"
 
on:  # yamllint disable-line rule:truthy
  workflow_dispatch:
    inputs:
      tag:
        description: 'Tag to prepare (format: vXX.YY.ZZ)'
        required: true
jobs:
  new-release:
    timeout-minutes: 30
    name: "Draft a new release"
    runs-on: latchkey-small
    steps:
      - name: Install git-flow
        run: sudo apt update && sudo apt install -y git-flow
 
      - uses: actions/checkout@v3
 
      - name: Setup Python
        uses: actions/setup-python@v3
        with:
          python-version: '3.11'
          cache: 'pip'
          cache-dependency-path: '**/setup.cfg'
 
      - name: Configure git-flow
        run: |
          git fetch --tags --depth=1 origin master develop
          git flow init --default --tag v
 
      - name: Create release branch
        run: git flow release start ${{ github.event.inputs.tag }}
 
      - name: Initialize mandatory git config
        run: |
          git config user.name "GitHub actions"
          git config user.email noreply@github.com
 
      - name: Update CHANGELOG
        run: |
          python3 -m pip install mdformat-gfm 'git+https://github.com/Takishima/keepachangelog@v1.0.1'
          python3 -m keepachangelog release "${{ github.event.inputs.tag }}"
          python3 -m mdformat CHANGELOG.md
 
      - name: Commit changelog and manifest files
        id: make-commit
        run: |
          git add CHANGELOG.md
          git commit --message "Preparing release ${{ github.event.inputs.tag }}"
 
          echo "::set-output name=commit::$(git rev-parse HEAD)"
 
      - name: Push new branch
        run: git flow release publish ${{ github.event.inputs.tag }}
 
      # yamllint disable rule:line-length
      - name: Create pull request
        uses: thomaseizinger/create-pull-request@1.3.1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          head: release/${{ github.event.inputs.tag }}
          base: master
          title: Release version ${{ github.event.inputs.tag }}
          reviewers: ${{ github.actor }}
          # Write a nice message to the user.
          # We are claiming things here based on the `publish-new-release.yml` workflow.
          # You should obviously adopt it to say the truth depending on your release workflow :)
          body: |
            Hi @${{ github.actor }}!
 
            This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
            I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
 
            Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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:

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

Actions used in this workflow