-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
37 deletions.
There are no files selected for viewing
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
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 }} |
This file was deleted.
Oops, something went wrong.
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
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 |