Skip to content

Commit

Permalink
Create build_and_release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovler-Young authored Jul 29, 2023
1 parent 9d1f2a2 commit 485db52
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and Release

on:
pull_request:
types: [closed] # 监听 PR 的关闭事件
workflow_dispatch:

jobs:
build:
if: github.event.pull_request.merged == true #检查关闭的 PR 是否被合并,只有被合并时才继续执行
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1

- name: Cache NuGet packages
uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup MSBuild Path
uses: warrenbuckley/Setup-MSBuild@v1
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

- name: Setup NuGet
uses: NuGet/[email protected]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

- name: Restore NuGet Packages
run: nuget restore AdnmbBackup-gui/AdnmbBackup-gui.sln

- name: Build
run: msbuild AdnmbBackup-gui/AdnmbBackup-gui.sln /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=None

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./AdnmbBackup-gui/bin/Release/AdnmbBackup-gui.exe
asset_name: AdnmbBackup-gui.exe
asset_content_type: application/octet-stream

0 comments on commit 485db52

Please sign in to comment.