Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurora-Nasa-1 authored Oct 19, 2024
1 parent 61b252c commit c96bc80
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,45 @@ name: Release Workflow
on:
push:
tags:
- '*'
- 'v*' # 触发条件,仅当推送符合 v* 模式的 tag 时触发

jobs:
build:
name: Build and Release
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0 # 获取所有历史记录,以便能正确生成版本号等信息
fetch-depth: 0

- name: Get the version
- name: Get the version from tag
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
run: |
echo ::set-output name=VERSION::${GITHUB_REF#refs/*/}
echo "Releasing version ${GITHUB_REF#refs/*/}"
- name: Create zip archive
run: |
zip -r "${GITHUB_REPOSITORY##*/}-${{ steps.get_version.outputs.VERSION }}.zip" . -x "*.git*" "*.zip" ".github/*" # 排除不需要的文件或目录
zip -r "${GITHUB_REPOSITORY##*/}-${GITHUB_REF#refs/*/}.zip" . -x "*.git*" "*.zip" ".github/*"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用默认的 GITHUB_TOKEN
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}-${{ steps.get_version.outputs.VERSION }}.zip
asset_name: ${{ github.event.repository.name }}-${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip

0 comments on commit c96bc80

Please sign in to comment.