|
| 1 | +name: release packet |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + # 检出代码并包含标签 |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Download linuxbuild |
| 20 | + uses: dawidd6/action-download-artifact@v6 |
| 21 | + with: |
| 22 | + workflow: linuxbuild.yml |
| 23 | + workflow_conclusion: success |
| 24 | + check_artifacts: false |
| 25 | + skip_unpack: true |
| 26 | + if_no_artifact_found: fail |
| 27 | + path: ./XRelease/ |
| 28 | + - name: Download macbuild |
| 29 | + uses: dawidd6/action-download-artifact@v6 |
| 30 | + with: |
| 31 | + workflow: macbuild.yml |
| 32 | + workflow_conclusion: success |
| 33 | + check_artifacts: false |
| 34 | + skip_unpack: true |
| 35 | + if_no_artifact_found: fail |
| 36 | + path: ./XRelease/ |
| 37 | + - name: Download msbuild |
| 38 | + uses: dawidd6/action-download-artifact@v6 |
| 39 | + with: |
| 40 | + workflow: msbuild.yml |
| 41 | + workflow_conclusion: success |
| 42 | + check_artifacts: false |
| 43 | + skip_unpack: true |
| 44 | + if_no_artifact_found: fail |
| 45 | + path: ./XRelease/ |
| 46 | + |
| 47 | + - name: Display structure of downloaded files |
| 48 | + run: ls -al ./XRelease/ |
| 49 | + |
| 50 | + - name: Get current version and increment X |
| 51 | + id: versioning |
| 52 | + run: | |
| 53 | + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 54 | + echo "Latest tag: $latest_tag" |
| 55 | + # 提取 X 的值并递增 |
| 56 | + major=$(echo $latest_tag | cut -d '.' -f 1) |
| 57 | + minor=$(echo $latest_tag | cut -d '.' -f 2) |
| 58 | + patch=$(echo $latest_tag | cut -d '.' -f 3) |
| 59 | + build=$(echo $latest_tag | cut -d '.' -f 4) |
| 60 | +
|
| 61 | + new_minor=$((minor + 1)) |
| 62 | + new_version="$major.$new_minor.$patch.$build" |
| 63 | + echo "New version: $new_version" |
| 64 | + echo "new_tag=$new_version" >> $GITHUB_OUTPUT |
| 65 | + echo "prev_tag=$latest_tag" >> $GITHUB_OUTPUT |
| 66 | +
|
| 67 | + - name: Create and push new tag |
| 68 | + run: | |
| 69 | + git tag ${{ steps.versioning.outputs.new_tag }} |
| 70 | + git push origin ${{ steps.versioning.outputs.new_tag }} |
| 71 | +
|
| 72 | + - name: Generate release notes |
| 73 | + run: | |
| 74 | + logs=$(git log ${{ steps.versioning.outputs.prev_tag }}..${{ steps.versioning.outputs.new_tag }} --pretty=format:"* %h - %s - %an" --no-merges) |
| 75 | + release_notes=$(echo "$logs" | sed 's/ qyt$/ @xengine-qyt/') |
| 76 | + echo "$release_notes" |
| 77 | + echo "$release_notes" > release_notes.txt |
| 78 | + |
| 79 | + - name: Release |
| 80 | + uses: softprops/action-gh-release@v2 |
| 81 | + env: |
| 82 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + with: |
| 84 | + draft: false |
| 85 | + prerelease: false |
| 86 | + tag_name: ${{ steps.versioning.outputs.new_tag }} |
| 87 | + name: XEngine_MQService ${{ steps.versioning.outputs.new_tag }} |
| 88 | + body_path: release_notes.txt |
| 89 | + files: ./XRelease/*.zip |
0 commit comments