v1.0.5 #75
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: Up Load Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: OIAPI | |
| path: 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: Download File | |
| uses: dawidd6/action-download-artifact@v6 | |
| with: | |
| name: OIAPI | |
| path: out # 下载到 out 文件夹 | |
| skip_unpack: true | |
| - 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: | | |
| # 更新内容 | |
| artifacts: out/OIAPI.zip # 确保发布时的路径与下载后的路径一致 | |
| allowUpdates: true | |
| removeArtifacts: true |