更新 README.md #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Package and Release Workflow | |
on: | |
push: | |
branches: | |
- main # 只有在 main 分支上推送时触发 | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Read Config File | |
id: read_config | |
run: | | |
echo "::set-output name=contents::$(cat config)" | |
- name: Parse Config JSON | |
id: parse_config | |
run: | | |
echo "${{ steps.read_config.outputs.contents }}" > config.json | |
- name: Install zip | |
run: sudo apt-get install zip | |
- name: Prepare Environment | |
run: | | |
# 从 config.json 文件中读取配置 | |
CONFIG=$(cat config.json) | |
DIRECTORY=$(echo $CONFIG | jq -r '.directory') | |
IGNORE=$(echo $CONFIG | jq -r '.ignore // empty') | |
FILENAME=$(echo $CONFIG | jq -r '.filename // "archive.zip"') | |
PRERELEASE=$(echo $CONFIG | jq -r '.prerelease // false') | |
RELEASE_VERSION=$(echo $CONFIG | jq -r '.version // "1.0.0"') | |
RELEASE_BODY=$(echo $CONFIG | jq -r '.body // "Release notes"') | |
- name: Create Archive | |
run: | | |
# 创建压缩文件 | |
zip -r $FILENAME $DIRECTORY -x "$IGNORE" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: $RELEASE_VERSION | |
release_name: Release $RELEASE_VERSION | |
prerelease: $PRERELEASE | |
body: $RELEASE_BODY | |
asset_paths: $FILENAME |