Skip to content

Commit

Permalink
213
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Sep 26, 2024
1 parent 20874c9 commit 6708b28
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 37 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/change-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update Version and Tag

on:
release:
types: [created]

jobs:
update-version:
runs-on: ubuntu-latest
env:
TAG_VERSION: ${{ github.ref_name }}
BRANCH_NAME: update-tag-version-${{ github.ref_name }}
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# Step 2: Set up Git with official account
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Step 3: Update Version/version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > Version/version
# Step 4: Commit and push changes
- name: Commit and push changes
run: |
git checkout -b ${{ env.BRANCH_NAME }}
git add Version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin ${{ env.BRANCH_NAME }}
# Step 5: Create and push tag
- name: Create and push tag
run: |
git tag ${{ env.TAG_VERSION }}
git push origin ${{ env.TAG_VERSION }}
37 changes: 0 additions & 37 deletions .github/workflows/update-release-file.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/update-release-file.ymlbak
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update Release with Custom Version

on:
push:
tags:
- 'v*.*.*' # 只有符合 v*.*.* 格式的 tag 才会触发

jobs:
update_release:
runs-on: ubuntu-latest
env:
TAG_VERSION: ${{ github.ref_name }} # 获取当前 tag 版本号

steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取所有历史记录,确保我们可以推送

# Step 2: Update version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > version/version # 将 tag 写入 version 文件

# Step 3: Archive the code
- name: Create source archive
run: |
zip -r source-code-${{ env.TAG_VERSION }}.zip . # 打包修改后的代码

# Step 4: Upload to the Release
- name: Upload modified source to release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }} # 获取当前 Release 的上传 URL
asset_path: ./source-code-${{ env.TAG_VERSION }}.zip # 上传我们刚刚创建的 zip 文件
asset_name: source-code-${{ env.TAG_VERSION }}.zip
asset_content_type: application/zip

0 comments on commit 6708b28

Please sign in to comment.