Skip to content
Latchkey

Patch Release workflow (cytoscape/cytoscape.js)

The Patch Release workflow from cytoscape/cytoscape.js, 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: cytoscape/cytoscape.js.github/workflows/patch-release.ymlLicense MITView source

What it does

This is the Patch Release workflow from the cytoscape/cytoscape.js 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: Patch Release

on:
  workflow_dispatch:

jobs:
  patch-release:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    environment: prod
    steps:
      - name: Set branch name
        shell: bash
        run: |
          echo "BRANCH=master" >> $GITHUB_ENV
          echo "Branch: master"
      - name: checkout patch branch
        uses: actions/checkout@v6
        with:
          ref: ${{ env.BRANCH }}
      - uses: actions/setup-node@v6
        with:
          node-version-file: .nvmrc
          cache: 'npm'
      - name: Install dependencies
        run: npm install
      - name: Install Playwright Browsers
        run: npx playwright install --with-deps
      - name: Run tests
        run : |
          npm test 
      - name: Get new version string
        id: get_new_patch_version
        run: |
          chmod +rx ./.github/workflows/scripts/new-patch-version.sh
          . ./.github/workflows/scripts/new-patch-version.sh
        shell: bash
      - name: See patch branch
        run: echo branch ${{ env.BRANCH }}
        shell: bash
      - name: See new patch version
        run: echo "# version:" ${{ env.VERSION }}
        shell: bash
      - name: checkout master branch
        uses: actions/checkout@v6
        with:
          ref: master
          fetch-depth: 0
      - name: Set Git Config
        run : |
          # Set git configs
          git config --global user.name "${GITHUB_ACTOR}"
          git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" 
      - name: Update Version on master 
        id: update_backport_version_master
        run: |
          jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
          mv /tmp/temp.json ./documentation/versions.json
          
          git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"
          git push
      - name: checkout unstable branch
        uses: actions/checkout@v6
        with:
          ref: unstable
          fetch-depth: 0
      - name: Update Version on unstable 
        id: update_backport_version_unstable
        run: |
          jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
          mv /tmp/temp.json ./documentation/versions.json
          
          git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"
          git push
          git checkout ${{ env.BRANCH }}
      - name: Set Git Config
        run : |
          # Set git configs
          git config --global user.name "${GITHUB_ACTOR}"
          git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"        
      - name: Make Release
        id: release
        run: |
          chmod +rx .github/workflows/scripts/pre_release_test.sh
          . .github/workflows/scripts/pre_release_test.sh ${{ env.BRANCH }}
      - name: Archive action failure results
        uses: actions/upload-artifact@v4
        if: ${{ failure() && steps.release.conclusion == 'failure' }}
        with:
          name: npm-release--failure-report
          path: /home/runner/.npm/_logs/
      - name: Publish Package to GitHub Releases
        run: |
          curl -L \
          -X POST \
          -H "Accept: application/vnd.github+json" \
          -H "Authorization: Bearer ${{ secrets.MAIN_GH_TOKEN }}" \
          -H "X-GitHub-Api-Version: 2022-11-28" \
          https://api.github.com/repos/${{ github.repository }}/releases \
          -d '{"tag_name":"v${{ env.VERSION }}","target_commitish":"master","name":"v${{ env.VERSION }}","body":"Release version v${{ env.VERSION }}","draft":false,"prerelease":false,"generate_release_notes":false}'
      - name: Deploy to Github Pages 🚀
        if: ${{ env.BRANCH == 'master' }}
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: documentation        

  npm_publish:
    needs: patch-release
    permissions:
      contents: read
      id-token: write
    uses: ./.github/workflows/npm-publish.yml

The same workflow, on Latchkey

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

name: Patch Release
 
on:
  workflow_dispatch:
 
jobs:
  patch-release:
    runs-on: latchkey-small
    timeout-minutes: 10
    environment: prod
    steps:
      - name: Set branch name
        shell: bash
        run: |
          echo "BRANCH=master" >> $GITHUB_ENV
          echo "Branch: master"
      - name: checkout patch branch
        uses: actions/checkout@v6
        with:
          ref: ${{ env.BRANCH }}
      - uses: actions/setup-node@v6
        with:
          node-version-file: .nvmrc
          cache: 'npm'
      - name: Install dependencies
        run: npm install
      - name: Install Playwright Browsers
        run: npx playwright install --with-deps
      - name: Run tests
        run : |
          npm test 
      - name: Get new version string
        id: get_new_patch_version
        run: |
          chmod +rx ./.github/workflows/scripts/new-patch-version.sh
          . ./.github/workflows/scripts/new-patch-version.sh
        shell: bash
      - name: See patch branch
        run: echo branch ${{ env.BRANCH }}
        shell: bash
      - name: See new patch version
        run: echo "# version:" ${{ env.VERSION }}
        shell: bash
      - name: checkout master branch
        uses: actions/checkout@v6
        with:
          ref: master
          fetch-depth: 0
      - name: Set Git Config
        run : |
          # Set git configs
          git config --global user.name "${GITHUB_ACTOR}"
          git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" 
      - name: Update Version on master 
        id: update_backport_version_master
        run: |
          jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
          mv /tmp/temp.json ./documentation/versions.json
          
          git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"
          git push
      - name: checkout unstable branch
        uses: actions/checkout@v6
        with:
          ref: unstable
          fetch-depth: 0
      - name: Update Version on unstable 
        id: update_backport_version_unstable
        run: |
          jq --arg ver "${{ env.VERSION }}" '.versions += [$ver]' ./documentation/versions.json >> /tmp/temp.json
          mv /tmp/temp.json ./documentation/versions.json
          
          git add . && git commit -m "Docs: Add ${{ env.VERSION }} to versions.json"
          git push
          git checkout ${{ env.BRANCH }}
      - name: Set Git Config
        run : |
          # Set git configs
          git config --global user.name "${GITHUB_ACTOR}"
          git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"        
      - name: Make Release
        id: release
        run: |
          chmod +rx .github/workflows/scripts/pre_release_test.sh
          . .github/workflows/scripts/pre_release_test.sh ${{ env.BRANCH }}
      - name: Archive action failure results
        uses: actions/upload-artifact@v4
        if: ${{ failure() && steps.release.conclusion == 'failure' }}
        with:
          name: npm-release--failure-report
          path: /home/runner/.npm/_logs/
      - name: Publish Package to GitHub Releases
        run: |
          curl -L \
          -X POST \
          -H "Accept: application/vnd.github+json" \
          -H "Authorization: Bearer ${{ secrets.MAIN_GH_TOKEN }}" \
          -H "X-GitHub-Api-Version: 2022-11-28" \
          https://api.github.com/repos/${{ github.repository }}/releases \
          -d '{"tag_name":"v${{ env.VERSION }}","target_commitish":"master","name":"v${{ env.VERSION }}","body":"Release version v${{ env.VERSION }}","draft":false,"prerelease":false,"generate_release_notes":false}'
      - name: Deploy to Github Pages 🚀
        if: ${{ env.BRANCH == 'master' }}
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: documentation        
 
  npm_publish:
    timeout-minutes: 30
    needs: patch-release
    permissions:
      contents: read
      id-token: write
    uses: ./.github/workflows/npm-publish.yml
 

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 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