Skip to content

chore(lab): update guidebook content #286

chore(lab): update guidebook content

chore(lab): update guidebook content #286

Workflow file for this run

# https://github.com/sveltejs/kit/blob/32afba695088b946aefe96da75b36de9b0667fbe/.github/workflows/release.yml
name: 'Release'
on:
push:
branches: ['main']
jobs:
changesets:
# prevents this action from running on forks
if: github.repository == 'difizen/libro'
name: Changesets
uses: difizen/actions/.github/workflows/release-changesets.yml@main
secrets:
BOT_APP_ID: ${{ secrets.BOT_APP_ID }}
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
permissions:
pull-requests: write
contents: write
ci:
needs: [changesets]
if: |
needs.changesets.outputs.should-release == 'true'
name: Prerelease CI
uses: ./.github/workflows/ci.yml
permissions:
contents: read
actions: read
publish:
needs: [ci]
if: |
needs.ci.result == 'success'
name: Publish
uses: difizen/actions/.github/workflows/release-publish.yml@main
with:
node-version: '20'
python-version: '3.8'
permissions:
contents: write
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# 新增的 release-notes Job
release-notes:
needs: [publish]
if: |
needs.publish.result == 'success'
name: Generate Release Notes
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: wow-actions/use-app-token@v2
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up git
run: |
git fetch --prune --unshallow
git fetch --tags
- name: Get latest tag
id: get_tag
run: |
# 获取最新的符合 @difizen/libro-xxx@ 格式的 tag
LATEST_TAG=$(git describe --tags --abbrev=0)
# 输出最新的 tag
echo "Latest tag: $LATEST_TAG"
# 提取版本号(移除最后一个 '@' 之前的部分)
VERSION=${LATEST_TAG##*@}
# 输出提取的版本号
echo "Extracted version: $VERSION"
# 将版本号设置为输出变量供后续步骤使用
echo "::set-output name=latest_version::$VERSION"
- name: Check if tag exists
id: check_tag
run: |
TAG_EXISTS=$(git tag -l "${{ steps.get_tag.outputs.latest_version }}")
if [ -z "$TAG_EXISTS" ]; then
echo "Tag does not exist"
echo "::set-output name=tag_exists::false"
else
echo "Tag already exists"
echo "::set-output name=tag_exists::true"
fi
# 自动生成 Release Notes
- name: Generate Release Notes
if: steps.check_tag.outputs.tag_exists == 'false'
id: draft_release
uses: release-drafter/release-drafter@v5
with:
version: v${{ steps.get_tag.outputs.latest_version }}
env:
GITHUB_TOKEN: ${{ env.BOT_TOKEN }}
# 发布 Release
- name: Publish Release
if: steps.check_tag.outputs.tag_exists == 'false'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ env.BOT_TOKEN }}
with:
tag_name: v${{ steps.get_tag.outputs.latest_version }} # 使用触发的标签名
release_name: Release v${{ steps.get_tag.outputs.latest_version }} # 使用最近的 tag 作为 release 名
body: ${{ steps.draft_release.outputs.body }} # 使用生成的 Release Notes 内容
draft: false
prerelease: false