Skip to content
Latchkey

๐Ÿš€ Auto Release workflow (antvis/F2)

The ๐Ÿš€ Auto Release workflow from antvis/F2, explained and optimized by Latchkey.

F

CI health: F - at risk

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: antvis/F2.github/workflows/auto-release.ymlLicense MITView source

What it does

This is the ๐Ÿš€ Auto Release workflow from the antvis/F2 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: ๐Ÿš€ Auto Release
on:
  push:
    branches:
      - master

jobs:
  release:
    runs-on: macos-14
    if: startsWith(github.event.head_commit.message , 'chore(release):')

    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: "0"

      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 20

      # ๅ‘ๅธƒๅผ€ๅง‹้€š็Ÿฅ
      # https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
      - name: Release start notify
        uses: zcong1993/actions-ding@master
        with:
          dingToken: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
          ignoreError: true
          body: |
            {
              "msgtype": "link",
              "link": {
                "title": "๐Ÿš€ F2 ๅผ€ๅง‹ๅ‘ๅธƒ",
                "text": "๐Ÿ”— ๆŸฅ็œ‹่ฏฆๆƒ…",
                "messageUrl": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
                "picUrl": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/ea88c724-38fb-42aa-8055-0e08155368b9.png"
              }
            }

      - name: Install dependencies
        run: yarn

      - name: lint
        run: |
          npm run lint

      - name: build
        run: |
          npm run build
        env:
          CI: false

      - name: test
        run: |
          npm run test

      - name: Prepare
        # https://github.com/lerna/lerna/issues/2404
        # https://github.com/lerna/lerna/issues/2788
        run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: Get Version
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npm run version

      - name: build
        run: |
          npm run build
        env:
          CI: false

      - name: Release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npm run release

      # ๆๅ–็‰ˆๆœฌไฟกๆฏ
      - name: Extract version info
        id: version
        run: |
          VERSION=$(node -p "require('./packages/f2/package.json').version")
          COMMIT_MSG=$(echo "${{ github.event.head_commit.message }}" | head -n 1)
          echo "version=$VERSION" >> $GITHUB_OUTPUT
          echo "commit_message=$COMMIT_MSG" >> $GITHUB_OUTPUT

      # ๅ‘ๅธƒๅคฑ่ดฅ้€š็Ÿฅๅ†…้ƒจๅผ€ๅ‘็พค
      - name: Release failed notify
        if: ${{ failure() }}
        uses: zcong1993/actions-ding@master
        with:
          dingToken: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
          ignoreError: true
          body: |
            {
              "msgtype": "link",
              "link": {
                "title": "๐Ÿ˜ณ๐Ÿ˜ณ๐Ÿ˜ณ F2 ๅ‘ๅธƒๅคฑ่ดฅ",
                "text": "๐Ÿ”— ่ฏท็‚นๅ‡ป้“พๆŽฅๆŸฅ็œ‹ๅ…ทไฝ“ๅŽŸๅ› , ๅŠๆ—ถไฟฎๅค, ๅฐ่ฏ•็‚นๅ‡ปๅณไธŠ่ง’ [Re-run all jobs] ้‡่ฏ•, ๆˆ–ๆ‰‹ๅŠจๅ‘ๅธƒ",
                "messageUrl": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
                "picUrl": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/ea88c724-38fb-42aa-8055-0e08155368b9.png"
              }
            }

      - name: Release success notify
        if: ${{ success() }}
        uses: visiky/dingtalk-release-notify@main
        with:
          DING_TALK_TOKEN: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
          notify_title: '๐ŸŽ‰ F2 ๆ–ฐ็‰ˆๆœฌ ${{ steps.version.outputs.version }} ๅ‘ๅธƒๅ•ฆ ๐ŸŽ‰'
          notify_body: '## { title } <hr /> ![preview](https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/c833f8c9-c629-4943-a09b-ce1bf17ca937.png) <hr /> { body } <hr />'
          notify_footer: '> ๅ‰ๅพ€ [**AntV/F2 Releases**]({ release_url })ๆŸฅ็œ‹ๅฎŒๆ•ดๆ›ดๆ–ฐๆ—ฅๅฟ—.'
          at_all: false
          enable_prerelease: false
          github_token: ${{ secrets.GITHUB_TOKEN }}

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: ๐Ÿš€ Auto Release
on:
  push:
    branches:
      - master
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  release:
    timeout-minutes: 30
    runs-on: macos-14
    if: startsWith(github.event.head_commit.message , 'chore(release):')
 
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: "0"
 
      - name: Use Node.js
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: 20
 
      # ๅ‘ๅธƒๅผ€ๅง‹้€š็Ÿฅ
      # https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
      - name: Release start notify
        uses: zcong1993/actions-ding@master
        with:
          dingToken: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
          ignoreError: true
          body: |
            {
              "msgtype": "link",
              "link": {
                "title": "๐Ÿš€ F2 ๅผ€ๅง‹ๅ‘ๅธƒ",
                "text": "๐Ÿ”— ๆŸฅ็œ‹่ฏฆๆƒ…",
                "messageUrl": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
                "picUrl": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/ea88c724-38fb-42aa-8055-0e08155368b9.png"
              }
            }
 
      - name: Install dependencies
        run: yarn
 
      - name: lint
        run: |
          npm run lint
 
      - name: build
        run: |
          npm run build
        env:
          CI: false
 
      - name: test
        run: |
          npm run test
 
      - name: Prepare
        # https://github.com/lerna/lerna/issues/2404
        # https://github.com/lerna/lerna/issues/2788
        run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
 
      - name: Get Version
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npm run version
 
      - name: build
        run: |
          npm run build
        env:
          CI: false
 
      - name: Release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npm run release
 
      # ๆๅ–็‰ˆๆœฌไฟกๆฏ
      - name: Extract version info
        id: version
        run: |
          VERSION=$(node -p "require('./packages/f2/package.json').version")
          COMMIT_MSG=$(echo "${{ github.event.head_commit.message }}" | head -n 1)
          echo "version=$VERSION" >> $GITHUB_OUTPUT
          echo "commit_message=$COMMIT_MSG" >> $GITHUB_OUTPUT
 
      # ๅ‘ๅธƒๅคฑ่ดฅ้€š็Ÿฅๅ†…้ƒจๅผ€ๅ‘็พค
      - name: Release failed notify
        if: ${{ failure() }}
        uses: zcong1993/actions-ding@master
        with:
          dingToken: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
          ignoreError: true
          body: |
            {
              "msgtype": "link",
              "link": {
                "title": "๐Ÿ˜ณ๐Ÿ˜ณ๐Ÿ˜ณ F2 ๅ‘ๅธƒๅคฑ่ดฅ",
                "text": "๐Ÿ”— ่ฏท็‚นๅ‡ป้“พๆŽฅๆŸฅ็œ‹ๅ…ทไฝ“ๅŽŸๅ› , ๅŠๆ—ถไฟฎๅค, ๅฐ่ฏ•็‚นๅ‡ปๅณไธŠ่ง’ [Re-run all jobs] ้‡่ฏ•, ๆˆ–ๆ‰‹ๅŠจๅ‘ๅธƒ",
                "messageUrl": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
                "picUrl": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/ea88c724-38fb-42aa-8055-0e08155368b9.png"
              }
            }
 
      - name: Release success notify
        if: ${{ success() }}
        uses: visiky/dingtalk-release-notify@main
        with:
          DING_TALK_TOKEN: ${{ secrets.DING_TALK_ACCESS_TOKEN }}
          notify_title: '๐ŸŽ‰ F2 ๆ–ฐ็‰ˆๆœฌ ${{ steps.version.outputs.version }} ๅ‘ๅธƒๅ•ฆ ๐ŸŽ‰'
          notify_body: '## { title } <hr /> ![preview](https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/c833f8c9-c629-4943-a09b-ce1bf17ca937.png) <hr /> { body } <hr />'
          notify_footer: '> ๅ‰ๅพ€ [**AntV/F2 Releases**]({ release_url })ๆŸฅ็œ‹ๅฎŒๆ•ดๆ›ดๆ–ฐๆ—ฅๅฟ—.'
          at_all: false
          enable_prerelease: false
          github_token: ${{ secrets.GITHUB_TOKEN }}
 

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