|
| 1 | +name: 构建+自动发版 |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v*.*.*dev |
| 6 | + - v*.*.*d*dev |
| 7 | + - v*.*.*rel |
| 8 | + - v*.*.*d*rel |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build_matrix: |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + os: [ubuntu-latest, windows-latest] |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + outputs: |
| 21 | + artiid: ${{ steps.artifact-upload-step.outputs.artifact-id }} |
| 22 | + steps: |
| 23 | + - name: Check-out repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Setup Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: '3.12' |
| 30 | + architecture: 'x64' |
| 31 | + cache: 'pip' |
| 32 | + cache-dependency-path: | |
| 33 | + **/requirements*.txt |
| 34 | +
|
| 35 | + - name: Install Dependencies |
| 36 | + run: | |
| 37 | + pip install -r requirements.txt |
| 38 | + pip install -i https://test.pypi.org/simple/ RinUI --no-deps |
| 39 | +
|
| 40 | + - name: Build Executable |
| 41 | + run: | |
| 42 | + pyinstaller main.spec |
| 43 | + python post_build.py |
| 44 | +
|
| 45 | + - name: Upload Artifacts |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + id: artifact-upload-step |
| 48 | + with: |
| 49 | + name: NamePicker-Action-${{ runner.os }} |
| 50 | + path: | |
| 51 | + ${{ github.workspace }}/dist/main |
| 52 | + include-hidden-files: true |
| 53 | + |
| 54 | + release: |
| 55 | + needs: [build_matrix] |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - name: Check-out repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Prepare release |
| 62 | + run: | |
| 63 | + mkdir release |
| 64 | + mkdir artifacts |
| 65 | +
|
| 66 | + - name: Download artifacts |
| 67 | + uses: actions/download-artifact@v4 |
| 68 | + with: |
| 69 | + path: artifacts |
| 70 | + run-id: ${{needs.build_matrix.outputs.artiid}} |
| 71 | + |
| 72 | + - name: Prepare artifacts |
| 73 | + run: | |
| 74 | + mv ${{ github.workspace }}/artifacts/NamePicker-Action-Windows release/NamePicker-Action-Windows |
| 75 | + mv ${{ github.workspace }}/artifacts/NamePicker-Action-Linux release/NamePicker-Action-Linux |
| 76 | +
|
| 77 | + - name: Zip artifact |
| 78 | + run: | |
| 79 | + zip -r release/NamePicker-${{ github.ref_name }}-Windows.zip release/NamePicker-Action-Windows |
| 80 | + zip -r release/NamePicker-${{ github.ref_name }}-Linux.zip release/NamePicker-Action-Linux |
| 81 | + |
| 82 | + - name: Get release info |
| 83 | + id: release_info |
| 84 | + run: | |
| 85 | + $tag = "${{ github.ref_name }}" |
| 86 | + $version = $tag -replace '^v', '' |
| 87 | + echo "version=$version" >> $env:GITHUB_OUTPUT |
| 88 | + echo "tag=$tag" >> $env:GITHUB_OUTPUT |
| 89 | +
|
| 90 | + - name: Release |
| 91 | + uses: softprops/action-gh-release@v2 |
| 92 | + with: |
| 93 | + files: | |
| 94 | + ${{ github.workspace }}/release/NamePicker-${{ github.ref_name }}-Windows.zip |
| 95 | + ${{ github.workspace }}/release/NamePicker-${{ github.ref_name }}-Linux.zip |
| 96 | + body_path: CHANGELOG.md |
| 97 | + draft: false |
| 98 | + prerelease: ${{ contains(steps.release_info.outputs.version, 'dev') }} |
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments