Build and Release #2
This file contains 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: 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 |