Skip to content

[demo]build for cloudflare #6

[demo]build for cloudflare

[demo]build for cloudflare #6

Workflow file for this run

# 当分支 next 有 push 事件,并且此次 push 包含了 packages/stdf/package.json 文件时,执行以下任务
name: RELEASES NEXT
on:
push:
branches:
- next
paths:
- 'packages/stdf/package.json'
jobs:
releases:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# 1. 读取 packages/stdf/package.json 中的 version 字段,作为 Releases tag 和 Releases title
- name: Get version
id: version
run: |
echo version=$(cat packages/stdf/package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]') >> $GITHUB_OUTPUT
# 2. 读取 docs/mds/guide/changelog.md 的第一行内容中 ‘##’ 与 ‘<font’ 之间的内容,再去除空格
- name: Get md_version
id: md_version
run: |
echo md_version=$(cat docs/mds/guide/changelog.md | head -1 | sed 's/## //g' | sed 's/<font.*>//g' | tr -d '[[:space:]]') >> $GITHUB_OUTPUT
# 3. 读取 docs/mds/guide/changelog_en.md 的第一行内容中 ‘##’ 与 ‘<font’ 之间的内容,再去除空格
- name: Get md_version_en
id: md_version_en
run: |
echo md_version_en=$(cat docs/mds/guide/changelog_en.md | head -1 | sed 's/## //g' | sed 's/<font.*>//g' | tr -d '[[:space:]]') >> $GITHUB_OUTPUT
# 4. 比较 Get version 与 Get md_version 和 Get md_version_en 三者的输出内容,如果不相同则此次不需要发布 Release,退出
- name: Check version
run: |
if [[ ${{ steps.version.outputs.version }} != ${{ steps.md_version.outputs.md_version }} ]]; then
echo "This is not a tag push. Skipping."
exit 78
fi
if [[ ${{ steps.version.outputs.version }} != ${{ steps.md_version_en.outputs.md_version_en }} ]]; then
echo "This is not a tag push. Skipping."
exit 78
fi
# 5. 读取 docs/mds/guide/changelog.md 中前两个二级标题之间的内容,包含换行和空格
- name: Get changelog
id: changelog
run: |
echo 'changelog<<EOF' >> $GITHUB_OUTPUT
sed -n '1,/##/{/##/!p;}' docs/mds/guide/changelog.md | sed '/^$/d' >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# 6. 读取 docs/mds/guide/changelog_en.md 中第一个二级标题与第二个二级标题之间的内容,包含换行和空格
- name: Get changelog_en
id: changelog_en
run: |
echo 'changelog_en<<EOF' >> $GITHUB_OUTPUT
sed -n '1,/##/{/##/!p;}' docs/mds/guide/changelog_en.md | sed '/^$/d' >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
# 7. 作为 latest release 发布本次 Release,body 为 changelog 和 changelog_en 的合并内容,中间使用 --- 分隔
- name: Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.STDF_GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.version }}
release_name: v${{ steps.version.outputs.version }}
body: |
${{ steps.changelog.outputs.changelog }}
---
${{ steps.changelog_en.outputs.changelog_en }}
draft: false
prerelease: false