添加更新信息,去除掉版本号多余的0 v1.0.6 #77
This file contains hidden or 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: Building | |
| on: [push, pull_request] | |
| jobs: | |
| Build: | |
| runs-on: ubuntu-latest | |
| name: Building Source | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: get date | |
| id: get-date | |
| run: echo "timestamp=$(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT | |
| - name: Create release archive | |
| run: zip -r out/OIAPI.zip src/ | |
| - name: Extract version from commit message | |
| id: extract_version | |
| shell: pwsh | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| $pattern = 'v\d+(\.\d+)*' | |
| $commit_msg = "${{ github.event.head_commit.message }}" | |
| $jsonContent = Get-Content -Path '.config/version.json' -Raw | ConvertFrom-Json | |
| if ($commit_msg -match $pattern) { | |
| $ver = $Matches[0] -replace 'v', '' | |
| if($ver -ne $jsonContent.version){ | |
| $jsonContent.version = $ver | |
| $newJsonContent = $jsonContent | ConvertTo-Json | |
| Set-Content -Path '.config/version.json' -Value $newJsonContent | |
| git add .config/version.json | |
| git commit -m "自动更新版本文件 [skip ci]" | |
| git push | |
| } | |
| } | |
| else{ | |
| $ver = $jsonContent.version | |
| } | |
| echo "CURRENT_VER=$ver" >> $env:GITHUB_ENV | |
| echo $ver | |
| - name: publish | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: "V${{ env.CURRENT_VER }}" | |
| name: OIAPI V${{ env.CURRENT_VER }} | |
| body: | | |
| ## 🚀 版本更新日志 V${{ env.CURRENT_VER }} | |
| **提交信息** | |
| ```plaintext | |
| ${{ format('{0}', github.event.head_commit.message) }} | |
| ``` | |
| ### 构建详情 | |
| - 提交者: ${{ github.actor }} | |
| - 提交SHA: [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) | |
| - 触发时间: ${{ steps.get-date.outputs.timestamp }} | |
| artifacts: OIAPI.zip | |
| allowUpdates: true | |
| removeArtifacts: true | |
| - name: cleanup zip | |
| run: rm -rf out/OIAPI.zip |