๐ Auto Release workflow (antvis/F2)
The ๐ Auto Release workflow from antvis/F2, explained and optimized by Latchkey.
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 →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
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 />  <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 />  <hr /> { body } <hr />' notify_footer: '> ๅๅพ [**AntV/F2 Releases**]({ release_url })ๆฅ็ๅฎๆดๆดๆฐๆฅๅฟ.' at_all: false enable_prerelease: false github_token: ${{ secrets.GITHUB_TOKEN }}
What changed
- 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.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.